Originally posted by: wang7160
Suppose there are 4 jobs (each is a set of items) and 2 machines. An item allocated to the same machine will be processed only once. For example, let Job 1={1,2,3}, Job 2={2,3,4} be allocated to machine 1 and we only take 4 time units on machine 1. We need to obtain the maximum completion time of the two machines, i.e. makespan=4. However, the following cplex code always gives the wrong answer 8. How do I fix the bug? Thank you very much for your kindly comments.
{int} Job[1..4] = [{1,2,3},{2,3,4},{5,6,7},{6,7,8}];
dvar int x[1..2][1..4] in 0..1;
//objective function
dexpr int cost=max(i in 1..2) card(union(j in 1..4) Job[j]);
//model
minimize cost;
subject to
{ c1:
forall (j in 1..4)
sum(i in 1..2) x[i][j] == 1;
}
execute {
writeln("x="+x.solutionValue);
}
#CPLEXOptimizers#DecisionOptimization