Error creating sparse matrix

  1. Please help me define these binary matrices:

# from the .mod file
param tour > 0 integer;
param slot > 0 integer;
param tours{SURGERY, ROOM, 1..slot, 1..tour} binary;

# from the .dat file
param tour := 4;
param slot := 5;

param: tours :=
   [O01, R1, 1..slot, 1..tour]:
       1 2 3 4 :=
   1   1 0 0 0
   2   1 1 0 0
   3   1 1 1 0
   4   0 1 1 0
   5   0 0 1 0 
   
   [O01, R2, 1..slot, 1..tour]:
       1 2 3 4 :=
   1   0 0 0 0
   2   0 0 0 0
   3   0 0 0 0
   4   0 0 0 0
   5   0 0 0 0 ; 
# error returned to console
 	tours is not a set
context:  [O01, R1, 1..slot, 1..tour] >>> : <<< 

  1. Most of my matrices will contain all zeroes. How do I use the keyword default 0 in my .dat file?

Given that your model has

set SURGERY;
set ROOM;

param tour > 0 integer;
param slot > 0 integer;
param tours {SURGERY, ROOM, 1..slot, 1..tour} binary;

then you can use this format for the data:

set SURGERY := O01;
set ROOM := R1 R2 ;

param tour := 4;
param slot := 5;

param tours default 0 :=
   [O01, R1, *, *]:
       1 2 3 4 :=
   1   1 0 0 0
   2   1 1 0 0
   3   1 1 1 0
   4   0 1 1 0
   5   0 0 1 0 ;

When you solve, the matrix for [O01,R2,*,*] will be set to all zeros.

Thank you. I will try your suggestion now.