Originally posted by: Chrisontherun
I encountered trouble when posting big-M constraints in CPLEX on C# environment, here's my case:
the constraint I want to post can be read as
(Complete[i]-Due[i])/M <= lateness[i] where
Complete[i] and
Due[i] denotes complete and due time of job
i, and
lateness[i], which is a binary variable, is set to be 1 when job
i is late(that is,
Complete[i]-Due[i] < 0 ) and 0 other wise,
M represents a sufficiently large number. To impletement this, I code as follows:
ILinearNumExpr a = cp.LinearNumExpr();
for (
int i = 0; i < nbJobs; i++)
{ a.AddTerm(1 / 100000.0, complete[i]); a.AddTerm(-1, lateness[i]); cplex.AddLe(a, Due[i] / 100000.0);
}
it can be seen that
M is give the value of 100000.0 which is considerably larger than any of
Complete[i] and
Due[i]. the objective is to minimize the number of late jobs by
ILinearNumExpr b = cp.LinearNumExpr();
for (
int i = 0; i < nbJobs; i++)
{ b.AddTerm(1, lateness[i]);
} cplex.AddMinimize(b);
The output shows that even jobs are late, the value of corresponding
lateness[i] stays 0. What shocked me is that as I decrease the value of
M (from 100000.0 to 1000.0), the number of
lateness[i] with value 1 increases as they are not constrained by the big-M constraints posted above. I'm not sure if have missed anything or is there anything wrong with the constraint. Can anybody give me some suggestion?
#DecisionOptimization#OPLusingCPLEXOptimizer