Decision Optimization

Decision Optimization

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

 View Only
  • 1.  How to warmstart MIP with three decision variables

    Posted Mon April 07, 2014 04:40 PM

    Originally posted by: Mondano


    Hi,

    in OPL in the CPLEX optimizer, 12.6, I have a MIP with three decision variables l[][], q[][][] and s[][][].

    I read two 2d-arrays q1 and q1 for q (and two 2d-arrays for s) from excel to assemble them in the main block to a 3d helper array (qh and sh) like this:

        for (var i in 1..numberPeriods) {
            
                for (var j in 1..numberDepots) {
                    
                    thisOplModel.qh[i][1][j]=thisOplModel.q1[j][i];
                    thisOplModel.qh[i][2][j]=thisOplModel.q2[j][i];
                }
            }

    I try to warmstart the problem with consecutive vectors.attach and one final setVectors,

        vectors.attach(thisOplModel.q, thisOplModel.qh);
        vectors.attach(thisOplModel.l, thisOplModel.lh);
        vectors.attach(thisOplModel.s, thisOplModel.sh);

        if (vectors.setVectors(cplex)) {
             writeln("MIP start information restored.", vectors.Nrows ,vectors.Ncols,vectors.status);
         }      
         else {
               writeln("Failed to restore MIP start information");
          }

     

    but the log tells me that no feasible solution was found:

    Warning:  No solution found from 1 MIP starts.
    Retaining values of one MIP start for possible repair.

    even though I just read the solution that has been obtained during a previous run as a a valid solution.

    What could be possible ways to track down the cause of this unexpected behaviour? And how can I fix it?

    And, is it possible to use addMIPStart in the main block of a OPL script to add a valid mip start with three decision variables (may be with some kind of array-trick, putting l, q and s in one and lh, qh and sh in another array)? I have come to the conclusion that it usually accepts the solution only for one variable and keeps the other variables as different MIP start, but of course in my case, a valid MIP start needs to consist of all three variables l, q and s. So is there a way to use addMIPstart instead of setVector in my case?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to warmstart MIP with three decision variables

    Posted Tue April 08, 2014 03:53 AM

    Hi,

    a list of attach should work as can be seen in the following code:

    range r = 1..10;

    dvar int+ x[r][r];

    dvar int+ x2[r][r];

    dvar int+ y[r][r];

    // The following array of values (defined as data) will be used as

    // a starting solution to warm-start the CPLEX search.

    float values[i in r,j in r] = (i==5 && j==5)? 10 : 0;

    float values2[i in r,j in r] = (i==3 && j==3)? 10 : 0;

     

     

    minimize

    sum( i in r,j in r) (x[i][j]+x2[i][j]) + sum( i,j in r ) y[i][j];

    subject to{

    ctSum:

    sum( i,j in r ) x[i,j] >= 10;

    ctSum2:

    sum( i,j in r ) x2[i,j] >= 10;

    forall( i,j in r )

    ctEqual:

    y[i][j] == j;

    }

     

    main{

    thisOplModel.generate();

    var def = thisOplModel.modelDefinition;

    // Default behaviour

    writeln("Default Behaviour");

    var cplex1 = new IloCplex();

    var opl1 = new IloOplModel(def, cplex1);

    opl1.generate();

    cplex1.solve();

    writeln(opl1.printSolution());

    // Setting initial solution

    writeln("Setting initial solution");

    var cplex2 = new IloCplex();

    var opl2 = new IloOplModel(def, cplex2);

    opl2.generate();

    var vectors = new IloOplCplexVectors();

    // We attach the values (defined as data) as starting solution

    // for the variables x.

    vectors.attach(opl2.x,opl2.values);

    vectors.attach(opl2.x2,opl2.values2);

    vectors.setVectors(cplex2);

    cplex2.solve();

    writeln(opl2.printSolution());

     

    opl1.end();

    cplex1.end();

    opl2.end();

    cplex2.end();

    0;

    }

     

    In the engine log I got

    1 of 1 MIP starts provided solutions.

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: How to warmstart MIP with three decision variables

    Posted Tue April 08, 2014 04:10 AM

    Originally posted by: Mondano


    Thanks for your quick reply, Alex. Actually, I think I did in my code quite the same as you did in yours and I have your example running on my machine and it gets a valid MIP start.

    What I do not understand is how I can search for the cause, why in my (rather large) model a solution that has been resulted from a previous run does not provide a valid starting solution for a new run. Can you give me a hint how to explore this phenomenon?

    Also: My second question related to the possible use of addMIPStart with an array of all decision variables. Do you think this is a option worth exploring?

    And finally, do you think, it would make a difference, if I obtained the previous solution in the same model run, so without the writing to and reading from Excel? Maybe there are rounding issues or something like that preventing a feasible solution (though the data type is integer). I would really appreciate new impulses for moving forward. Thanks!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: How to warmstart MIP with three decision variables

    Posted Tue April 08, 2014 05:25 AM

    Originally posted by: Mondano


    I think I have found the cause: The assembly of the 3d-arrays from 2d-array did not work because in the main()-block I used a range syntax (i in 1..numberPeriods) instead of a range variable (i in rangePeriods). The IDE gave me a warning but as it was only a warning I did not take it too serious - now I know, that I was wrong.

    So the vectors.attach works perfectly for my purpose (though I am still curious about a possible array solution with addMIPStart)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: How to warmstart MIP with three decision variables



  • 6.  Re: How to warmstart MIP with three decision variables

    Posted Wed April 09, 2014 03:21 PM

    Originally posted by: Mondano


    well, not really, since I do not have a MST-file to start from. Is there a way to create one in OPL?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: How to warmstart MIP with three decision variables

    Posted Thu April 10, 2014 01:19 AM

    Hi,

    let me give you an example:

    in the warmstart example,

    replace

    vectors.attach(opl2.x,opl2.values);
      vectors.setVectors(cplex2);   
     
     by


      cplex2.addMIPStart(opl2.x,opl2.values,1);

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: How to warmstart MIP with three decision variables

    Posted Thu April 10, 2014 02:50 PM

    Originally posted by: Mondano


    Yes, for one variable I know how to use addMIPStart. The problem is, that to my mind , when I use addMIPStart several times consecutively for a problem with more than one decision variable, every given MIPStart substitutes the previous one, so

    cplex2.addMIPStart(opl2.x, opl2.values, 1)

    cplex2.addMIPStart(opl2.y, opl2.values2, 1)

    would add two different MIPstarts and not one with two variables, or am I mistaken on this?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer