Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex with C++ in vs2008

    Posted 01/15/12 04:57 AM

    Originally posted by: W0M5_lei_cong


    Thanks for your time! I am a freshman in cplex.

    First , I use IloNumVarArray to represent the decision variables in a model.
    How can I use another variable to get the maximum in the IloNumVarArray?
    May I add an obj to minimize the maximum in the IloNumVarArray ?
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex with C++ in vs2008

    Posted 01/15/12 05:06 AM

    Originally posted by: SystemAdmin


    In order to minimize the maximum in an array you can
    • create a new variable x,
    • add constraints that require the new variable to be as large as any variable in the array,
    • minimize x
    Code for this may look like (untested):
    IloNumVarArray array(env, ...);
    ... // Setup 'array' here.
    IloNumVar x(env);
    for (IloInt i = 0; i < array.getSize(); ++i)
       model.add(x >= array[i]);
    model.add(IloMinimize(env, x));
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex with C++ in vs2008

    Posted 01/15/12 06:13 AM

    Originally posted by: W0M5_lei_cong


    Hi Junglas, thanks for your help! I did what you told but the problem remains.
    Actually my problem is a little bit complicated. Maybe I didn't explain well.

    First I use a 3D IloNumVarArray X and a 2D IloNumVarArray Y to represent the
    decision variables like this:
    typedef IloArray<IloNumVarArray> NumVarMatrix2;
    typedef IloArray<NumVarMatrix2> NumVarMatrix3;

    By calculate the X and Y, I get another 2D IloNumVarArray like NumVarMatrix2 Z[i][j],
    then I want to get the Maximum of each Z[i] and minimize their sum. How can I do?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex with C++ in vs2008

    Posted 01/15/12 05:34 AM

    Originally posted by: W0M5_lei_cong


    Hi Junglas, thanks for your help! I did what you told but the problem remains.
    Actually my problem is a little bit complicated. Maybe I didn't explain well.

    First I use a 3D IloNumVarArray X and a 2D IloNumVarArray Y to represent the
    decision variables like this:
    typedef IloArray<IloNumVarArray> NumVarMatrix2;
    typedef IloArray<NumVarMatrix2> NumVarMatrix3;

    By calculate the X and Y, I get another 2D IloNumVarArray like NumVarMatrix2 Z[i][j],
    then I want to get the Maxinum of each Z[i] and minimize their sum. How can I do?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex with C++ in vs2008

    Posted 01/19/12 04:14 AM

    Originally posted by: SystemAdmin


    You need to introduce a new variable for each element in Z that gives the maximum of the variables in Z and then minimize the sum of these new variables:
    IloNumVarArray maxVal(env, Z.getSize(), 0.0, IloInfinity, ILOFLOAT);
    IloExpr sum(env);
    for (IloInt i = 0; i < Z.getSize(); ++i) {
       // Add a constraint that maxVal[i] is at least as large as
       // every element in Z[i]. If we minimize maxVal[i] then this
       // guarantees that maxVal[i] is the maximum of all Z[i].
       for (IloInt j = 0; j < Z[i].getSize(); ++j)
          model.add(maxVal[i] >= Z[i][j]);
       // Add maxVal[i] to the sum used in the objective function.
       sum += maxVal[i];
    }
    // Minimize the sum of the maximum values.
    model.add(IloMinimize(env, sum));
    

    #CPLEXOptimizers
    #DecisionOptimization