Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to identify decision variables from clone model c++

    Posted 10/12/22 11:54 AM
    Hi,

    Now I am trying to generate multiple clones from the original model for branch and bound algorithm.

    Original model is for example

    Min 3x+2y

    subject to x+y<=10, 0<=x<=10 and 0<=y<=10 integers

    And I want to modify the upper and lower bound of a certain variable, for example 0<=x<=5.

    However, I could not get access to the variable because the model is simply a clone.

    Is there any way I can modify the cloned model?

    Thank you in advance and I attach the sample code for reference.

    Following is the sample code. 

    #include"ilcplex/ilocplex.h";
    using namespace std;

    int main()
    {
    IloNumVar Y(env, 0, 10, ILOFLOAT);
    IloNumVar X(env, 0, 10, ILOFLOAT);
    IloEnv env;
    IloModel Model(env);
    Model.add(IloMinimize(env, 3*X+2*Y));
    Model.add(X+2Y <= 10);
    IloModel Model1 = Model.getClone(env);
    //I want to add Model1.add(X<=5); for example. However, it identifies this X as a totally new variable in the cloned model in this case, which different from X in the original model.
    }

    Best,
    Samuel

    ------------------------------
    Sangjeong Lee
    ------------------------------

    #DecisionOptimization


  • 2.  RE: How to identify decision variables from clone model c++

    Posted 11/16/22 10:41 AM
    The clone method will clone the tree and is working only once per env if I don't mistake. (You have to use N env if you want to create N clones).
    there can only 1 clone for each object per env.
    So calling X.getClone(env) will return the copy of X in the IloEnv env. It will be the object that is created during the call of Model.getClone(env) when going through the model tree.
    (Calling a 2nd time Model.getClone(env) will in fact return the 1st clone).

    ------------------------------
    Vincent Beraudier
    ------------------------------