Originally posted by: beth834
I have just started to use Cplex (concert technology for c++) to implement the following ILP
min d
s.t. constraint 1...
sum x[i][j] <= d
constraint 3....
I tried to write the model as follows
IloEnv env;
IloModel mod(env);
IloNumVarArray2 x(env,sigma);
IloNumVar d(env, 0, m, ILOINT);
IloCplex cplex(mod);
mod.add(IloMinimize(env, d));
for(int i=0;i<sigma;i++)
{
x[i] = IloNumVarArray(env, m, 0, 1, ILOINT);
}
//constraint 1....
.....
.......
//constraint2
for(int t=0;t<sigma;t++)
{
IloExpr constraint2(env);
for (int j = 0; j < m; j++)
{
constraint2+=x[t][j];
}
IloRange eq2(env, -IloInfinity, constraint2, cplex.getValue(d));
constraint2.end();
mod.add(eq2);
}
.....
...........
.........
........
I got an Error message (CPLEX Error 1217: No solution exists.), it seems that cplex.getValue(d) is empty.
I think that the problem is the variable to minimize is present also in the constraint.
If I use IloInt d instead of IloNumVar d and if I initialize d=k (k is an integer), the model is solved for d=k, but d is not minimized.
#CPLEXOptimizers#DecisionOptimization