MATH 441 Section 201
Some sample inputs for LINGO
Online Course Material 

MODEL:
!xij=1 if jth job assigned to machine i and 0 otherwise
!yi=1 if machine i turned on;

Sets:
machine / 1..5/: y;
job /1..18/: duration;
pairs(job, machine): x ;
endsets

[objective] Min=@sum( machine(j) : startcost*y(j) );

@for(job(j): [jobassigned] @sum(machine(k): x(j,k))=1);
@for(machine(k): [machineload] @sum(job(j) :
duration(j)*x(j,k)) < completetime);
@for(machine(k): @for( job(j): [machineturnedon] y(k)-x(j,k) > 0));
@for(pairs: @gin(x));
@for(machine : @gin(y));


Data:
duration = 20 19 17 16 16 16 12 11 9 9 9 5 4 4 4 4 2 1;
completetime=45;
startcost=1000;
enddata

end

An alternate formulation that seems to run faster is the following
MODEL:
!xij=1 if jth job assigned to machine i and 0 otherwise
!yi=1 if machine i turned on;

Sets:
machine / 1..5/: y;
job /1..18/: duration;
pairs(job, machine): x ;
endsets

[objective] Min=@sum( machine(j) : startcost*y(j) );

@for(job(j): [jobassigned] @sum(machine(k): x(j,k))=1);
@for(machine(k): [machineload] @sum(job(j) :
duration(j)*x(j,k)) < completetime*y(k));
@for(pairs: @gin(x));
@for(machine : @gin(y));


Data:
duration = 20 19 17 16 16 16 12 11 9 9 9 5 4 4 4 4 2 1;
completetime=45;
startcost=1000;
enddata

end

This particular problem introduces some of the syntax for so called derived sets. Thus the set named `pairs' (this is not a keyword but my choice for a name) consists of all pairs of elements where the first part of the pair is a job (and hence 1,2,3,4,... or 18) and the second is a machine (1,2,3,4 or 5). Mathematically we would call this the cartesian product of the two sets. Some of the syntax includes sets: endsets Data: enddata Model MAX= or MIN= Most lines/constraints end in semicolons. This can be a useful tool in debugging. You can comment out a line merely by putting a ! at the beginning and everything up to the semicolon in that line becomes a comment. I introduced labels to every constraint for convenience while debugging but it helps to read the output.