Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  min d s.t. constraint1 <=d

    Posted 01/21/11 12:16 PM

    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


  • 2.  Re: min d s.t. constraint1 <=d

    Posted 01/21/11 08:05 PM

    Originally posted by: SystemAdmin


    > beth834 wrote:
    > IloRange eq2(env, -IloInfinity, constraint2, cplex.getValue(d));

    Change this to

    IloRange eq2(env, -IloInfinity, constraint2 - d, 0);
    


    The getValue function returns the value of d after solving the model, not while solving it.

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: min d s.t. constraint1 <=d

    Posted 01/21/11 08:19 PM

    Originally posted by: beth834


    Thank you very much for your suggestion,
    I got so confused about the model that I missed the easiest way...
    #CPLEXOptimizers
    #DecisionOptimization