Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  coding problem in addusercut

    Posted 01/03/13 09:38 AM

    Originally posted by: geffer


    I am a new learner in addusercut and coding a very simple to experiment, but feedback is “ Not a mixed-integer problem” what's the problem?

    my coding is very easy

    #include <ilcplex/ilocplex.h>
    ILOSTLBEGIN
    void makeCuts(IloRangeArray cuts, const IloNumVarArray& vars) {
    IloNumVar x21,x22,x23;
    IloInt num = vars.getSize();
    x21 = vars[0];
    x22 = vars[1];
    x23 = vars[2];
    cuts.add(x21<=20);
    cuts.add(x22<=20);
    cuts.add(x23<=20);
    }
    int
    main(int argc, char** argv)
    {
    IloEnv env;
    try {
    IloModel m(env);
    IloCplex cplex(env);
    IloObjective obj;
    IloNumVarArray vars(env);
    IloRangeArray rngs(env);

    vars.add(IloNumVar(env, 0.0, 40.0));
    vars.add(IloNumVar(env));
    vars.add(IloNumVar(env));
    m.add(IloMaximize(env, vars[0] + 2 * vars[1] + 3 * vars[2]));
    m.add( - vars[0] + vars[1] + vars[2] <= 20);
    m.add( vars[0] - 3 * vars[1] + vars[2] <= 30);
    cplex.extract(m);
    IloRangeArray cuts(env);
    makeCuts(cuts, vars);
    cplex.addUsercuts(cuts);
    cuts.endElements();
    cuts.end();
    cplex.setParam(IloCplex::MIPInterval, 1000);
    env.out() << "solving model ...\n";
    cplex.solve();
    env.out() << "solution status is " << cplex.getStatus() << endl;
    env.out() << "solution value is " << cplex.getObjValue() << endl;
    IloNumArray vals(env);
    cplex.getValues(vals, vars);
    env.out() << "Values = " << vals << endl;

    }
    catch (IloException& ex) {
    cerr << "Error: " << ex << endl;
    }
    env.end();
    return 0;
    }
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: coding problem in addusercut

    Posted 01/03/13 04:08 PM

    Originally posted by: SystemAdmin


    I think that addUserCuts may be restricted to MIP models. Your model is an LP, not a MIP -- none of your variables are declared to be integer or boolean (binary).

    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