Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Initial Solution using Concert - Help

    Posted 10/10/11 08:55 AM

    Originally posted by: renatocuri


    Hello,

    I wrote a time indexed model for a scheduling problem and I'm trying to solve it with CPLEX using C++. I have a heuristic procedure that gives me an initial solution and I want to pass this solution to the optimizer. More specifically, I have an initial 0-1 Matrix that represents a feasible solution to the problem. I tried to use the addMIPstart method but it only accepts Arrays as parameters. I also tried to add each row of the matrix at a time on a loop, but it doesn't seem to work.

    Can anybody help me?

    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Initial Solution using Concert - Help

    Posted 10/10/11 03:49 PM

    Originally posted by: SystemAdmin


    One way to do so will be with the use of the setVectors() method. If var2D is a 2D bool decision variable, var2D_startingVals is the 2D IloNumVar array containing the starting values and i is the 1st dimension of the decision variable, then one such call could look like the following:

    for(int c=0;c<i;c++){
     cplex.setVectors(var2D_startingVals[c], 0, var2D[c],0,0,0);
    }
    


    Also, do make sure that this code is placed after the 'cplex.extract(model);' line.

    Hope this helps.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Initial Solution using Concert - Help

    Posted 10/25/11 07:19 AM

    Originally posted by: SystemAdmin


    This has been asked several times on this Forum. addMIPStart() accepts only a one-dimensional array as argument and you have to convert your matrix to a flat array. Assuming you have a matrix x that stores your variables and a matrix v that stores the initial solution, the code looks something like this:
    IloNumVarArray startVars(env);
    IloNumArray    startVals(env);
    for (int i = 0; i < rows; ++i) {
       for (int j = 0; j < cols; ++j) {
          startVars.add(x[i][j]);
          startVals.add(v[i][j]);
       }
    }
    cplex.addMIPStart(startVars, startVals);
    startVals.end();
    startVars.end();
    

    As you can see, all you have to do is to store the variables and values in a temporary one-dimensional array.
    #CPLEXOptimizers
    #DecisionOptimization