Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  warm start opl

    Posted 03/12/19 12:33 PM

    Originally posted by: brown_rice


    I want to warm start my model by giving the values of three variables. Here is what I do;

            var vectors = new IloOplCplexVectors();

            vectors.attach(m1Opl.Y,  initial.Y.solutionValue);
            vectors.attach(m1Opl.X,  initial.X.solutionValue);
            vectors.attach(m1Opl.shipment, initial.shipment.solutionValue);
            vectors.setStart(m1Cplex);

     

    I am little worried if this is correct or not. Do you think that it only sets the values for shipment variables? Should I create and independent vector for each variable?

     

    Another question is if I use mip start rather than vector, would that be the same thing?

    cplex.addMIPStart(m1Opl.Y,  initial.Y.solutionValue);

    cplex.addMIPStart(m1Opl.X,  initial.X.solutionValue);

    cplex.addMIPStart(m1Opl.shipment, initial.shipment.solutionValue);

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: warm start opl



  • 3.  Re: warm start opl

    Posted 03/12/19 01:32 PM

    Originally posted by: brown_rice


    Hi Alex,

    I looked at https://www.ibm.com/developerworks/community/forums/html/topic?id=75766584-44c5-4400-977f-03363feea776. However, I still did not understand. Is using SetVecor wrong in my example? Also, I still cannot see the difference between addMIPstart and setVector. 

    Edit: By the way, I just want to warm start, I do not want to fix a value for any variable.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: warm start opl

    Posted 03/12/19 01:53 PM

    Hi

    setVector and addMIPStart can deliver the same result. You may see the warmstart example in the OPL examples:

    range r = 1..10;
    dvar int+ x[r];
    dvar int+ y[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] = (i==5)? 10 : 0;


    minimize
      sum( i in r ) x[i] + sum( j in r ) y[j];
    subject to{
      ctSum:    
        sum( i in r ) x[i] >= 10;
      forall( j in r )
        ctEqual:
          y[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.setStart(cplex2);  
     
      cplex2.addMIPStart(opl2.x,opl2.values);
     
      cplex2.solve();   
      writeln(opl2.printSolution());

      opl1.end();
      cplex1.end();
      opl2.end();
      cplex2.end();
      0;
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: warm start opl

    Posted 03/12/19 02:01 PM

    Originally posted by: brown_rice


    Okay, thanks. What about my initial question? Is this right ? vectors.attach(m1Opl.Y,  initial.Y.solutionValue); vectors.attach(m1Opl.X,  initial.X.solutionValue);

     

    or should I create and individual vector for each variables and attach cplex to each vector separately? or is what I shared correct?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: warm start opl

    Posted 03/12/19 02:17 PM

    Hi

    use one vector

    see

     

    range r = 1..10;
    dvar int+ x[r];
    dvar int+ y[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] = (i==5)? 10 : 0;
    float values2[i in r] = i;

    minimize
      sum( i in r ) x[i] + sum( j in r ) y[j];
    subject to{
      ctSum:    
        sum( i in r ) x[i] >= 10;
      forall( j in r )
        ctEqual:
          y[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.y,opl2.values2);
      vectors.setStart(cplex2);  
     
      //cplex2.addMIPStart(opl2.x,opl2.values);
     
      cplex2.solve();   
      writeln(opl2.printSolution());

      opl1.end();
      cplex1.end();
      opl2.end();
      cplex2.end();
      0;
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer