Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  A problem about column generation,modeled in c++ by calling cplex

    Posted 12/04/18 01:54 AM

    Originally posted by: arronlee11


    hi~

    if i want to define a decision variable ,and i define as follow:

    y  = IloNumVarArray (env);

    i want to know : the decision variable y is a Continuous decision variable or a Integer decision variable?

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: A problem about column generation,modeled in c++ by calling cplex

    Posted 12/04/18 02:55 AM

    The constructor IloNumVarArray::IloNumVarArray(const IloEnv, IloInt = 0) is documented at https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/refcppcplex/html/classes/IloNumVarArray.html#method_IloNumVarArray.  As you used it, it doesn't create any variable: the array is empty. If you would specifie a non-null size, it would create empty handles, and therefore you would still not have created any variable.

     

    If you were to use IloNumVarArray::IloNumVarArray(const IloEnv env, IloInt n, IloNum lb, IloNum ub, IloNumVar::Type type=ILOFLOAT) instead, specifying the lower and upper bounds of the variables, you would indeed have created variables. They would be continuous by default, but you could decide otherwise by specifying a non-default value for the type parameter.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: A problem about column generation,modeled in c++ by calling cplex

    Posted 12/06/18 09:12 AM

    Originally posted by: arronlee11


    hi~

      i define my decision variable y as follow:

    y  = IloNumVarArray (env,ILOINT);

    .....after model and solve .....

    if i want to know the size of y,i write as follow:

    y.getSize();

    if i want to output the value of y,i write as follow :

    for(int i=0;i<y.getSize();i++)

    {

          cout<<modelSolver.getValue(y[i]);

    }

    now i can't output the value of y;

    but if i write as follow:

    for(int i=1;i<y.getSize();i++)

    {

          cout<<modelSolver.getValue(y[i]);

    }

    now the value of y is output successfully.

    i want to know why the Size number i begin at 1,but not 0?

    if i want the Size num i begin at 0,how shoulde i do?


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: A problem about column generation,modeled in c++ by calling cplex

    Posted 12/06/18 09:45 AM

    It would be clearer for everybody if you would create a new topic when you have a new question, as is the case here.

    Also, when you say that "you can't output the value of y", it would probably help to state what exactly the error is, with as many details as possible, so that we don't have to guess.

    Thanks.

     

    You used:

       y  = IloNumVarArray (env,ILOINT);

    This almost certainly doesn't do what you expect.  The constructor that you are using here is IloNumVarArray(const IloEnv env, IloInt n=0), with the value ILOINT (of type IloNumVar::Type) casted to an integer (IloInt). It seems you want to create an array of integer variables. Assuming that all your variables should have the same upper and lower bounds, you should use the constructor IloNumVarArray(const IloEnv env, IloInt n, IloNum lb, IloNum ub, IloNumVar::Type type=ILOFLOAT) as such:

    y = IloNumVarArray(env,
       n, /* number of variables to create */
       lb, /* lower bound of the variables */
       ub, /* upper bound */
       ILOINT /* type of variables to create */);
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: A problem about column generation,modeled in c++ by calling cplex

    Posted 12/06/18 10:12 PM

    Originally posted by: arronlee11


    thank you for you reply,

    the  constructor IloNumVarArray(const IloEnv envIloInt nIloNum lbIloNum ubIloNumVar::Typetype=ILOFLOAT) need i input(1) the number of variables, (2)lower bound of the variables,(3)upper bound of the variables ,(4)the type of variables;

    but i just want to create a extensible array with the integer variables , i don't want define (1)the number of variables, (2)lower bound of the variables,(3)upper bound of the variables ;

    how should i do?


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: A problem about column generation,modeled in c++ by calling cplex

    Posted 12/07/18 02:43 AM

    Depending on how you create an IloNumVarArray, it can be in 3 different states:

    • It can be empty. You then create the variables later, and add them to the array. This is what happens when you use IloNumVar(env).
    • It can be filled with a number of empty handles. It's not empty, but it only has empty handles to variables, instead of variables already created.  You still have to create the variables and assign them to the slots in the array. This is what happens when you use IloNumVar(env,n) with n > 0.
    • It can be filled with variables that are created at the same time as the array, and this requires that you specify the bounds that the variables should be created with. This is what happens when you use any of the other constructors that don't relate to column arrays.

    If you don't want to specify the number of variables or their bounds, I assume this must be because you don't want these variables to be created when you create the array.  You will then create these variables later in your code. But then you don't need to specify beforehand that the array will contain only integer variables.  Whether the variable is integer or floating point, it will still be an instance of IloNumVar, and the array can store any type of IloNumVar, even mixing their type.

    You can then use the constructor IloNumVar(env). And, when you create the variables to put them in the array, you create them as integer variables.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: A problem about column generation,modeled in c++ by calling cplex

    Posted 12/07/18 02:56 AM

    Originally posted by: arronlee11


    your repley is very clear,thank you very much~


    #CPLEXOptimizers
    #DecisionOptimization