Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Initial values for a binary variable - warmstart

    Posted 05/08/15 12:35 PM

    Originally posted by: Thaher


    Hi All,  I really appreciate your help and assistance on below. 

    I am inputting some initial values for a binary variable y to warmstart my OPL  model, y was declared as :  dvar boolean y[Plants][PlantCapacity];

    In order to load initial values of y I did the following : 

    1.  I declared a new variable as :

    int valY[Plants][PlantCapacity];
    int sizeY = r*k;
    int flatValY[1..sizeY]=...;

    2. to attach subject data I coded as follows :

    execute {
    var i = 1;
     
    for(var n in Plants)
     {
         for(var m in PlantCapacity)
         {
     
         valY[n][m] = flatValY[i];
         i++;
     
         }
      }
    }

    3. and I inserted these values at data file as follows : 

    flatValY = [
    0
    0
    1
    0
    1
    0
    0
    0
    1
    0
    0
    0
    ];

    4. Finally I have added the following code after the constraint block :

    main
    {
      var src = new IloOplModelSource("Class 1.2.mod");
      var def = new IloOplModelDefinition(src);
      cplex = new IloCplex();
     
      writeln("Solving the problem with initial solution");
      var opl = new IloOplModel(def, cplex);
      var data = new IloOplDataSource("Class 1.2.dat");
      opl.addDataSource(data);
      opl.generate();
     
      var vectors = new IloOplCplexVectors();
      vectors.attach(opl.y, opl.valY);
      
      vectors.setVectors(cplex);
      cplex.solve();
     

    When I run the model,  I observe the impact of loading those values on the search expressed  in the gap values at engine log, However, though engine log showed 3 solutions were found I get no solution in the problem browser. 

    I am not really sure weather my code is really correct, and if so why I am not getting solution at the end. Knowing that initial values were obtained from an optimal solution. 

     

    Regards,

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Initial values for a binary variable - warmstart

    Posted 05/09/15 04:32 AM

    Hi,

    this sounds ok.

    Can you add some execute blovk after the subject to block in order to display the solution and call opl.postProcess(); after cplex.solve(); in the main block ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Initial values for a binary variable - warmstart

    Posted 05/09/15 10:10 AM

    Originally posted by: Thaher


    Hi Alex, 

    I am not exactly clear on : Can you add some execute block after the subject to block in order to display the solution 

    would you please clarify apologies ! On the same note I have added opl.postProcess(); after cplex.solve(); in the main block , things remain same insofar. 

    Regards,

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Initial values for a binary variable - warmstart

    Posted 05/09/15 03:15 PM

    Hi

    let me give you an example:

    dvar float+ Gas;
    dvar float+ Chloride;


    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
      ctMaxTotal2:    
        3 * Gas + 4 * Chloride <= 180;
        ctEmpty:Gas<=100;
     
    }

    execute
    {
    writeln("Gas and Chloride");
    writeln(Gas," ",Chloride);
    }

    main
    {


    thisOplModel.generate();
    writeln(cplex.solve());;
    thisOplModel.postProcess();
    }

    which gives

    true
    Gas and Chloride
    20 30

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Initial values for a binary variable - warmstart

    Posted 05/09/15 05:32 PM

    Originally posted by: Thaher


    Hi Alex,

    This was clear and implemented as such, however I got a display for Objective function and its components at scripting log not at the problem browser which still shows no solution. Last line in engine log shows :

    Elapsed time = 46.66 sec. (6909.41 ticks, tree = 0.33 MB, solutions = 4)

        653   132  3.03912e+008   425  3.04139e+008  3.03789e+008   108388    0.12

    any hint could help ?

    Regards, 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Initial values for a binary variable - warmstart

    Posted 05/11/15 06:56 AM

    Hi

    can you post your model ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Initial values for a binary variable - warmstart

    Posted 05/11/15 09:39 AM

    Originally posted by: Thaher


    Hi Alex,

    Attached as requested. I intended to initialize x,y,g,z . However, I started with y as shown in data file.  

    Regards,

    Fadi 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Initial values for a binary variable - warmstart

    Posted 05/11/15 02:30 PM

    Hi,

    that is normal.

    If you have a look at the example warmstart, it is the same, you get no solution in the problem browser but a solution in the log. The problem browser does not display solutions all the time when you have a main.

    Regards

    PS:

    do not hesitate to log an RFE at https://www.ibm.com/developerworks/rfe/?BRAND_ID=343

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: Initial values for a binary variable - warmstart

    Posted 05/11/15 03:51 PM

    Originally posted by: Thaher


    Hi, 

    Thank you indeed for this clarification, is there any way I still initialize and get a display of other variables in addition to solution. 

    Regards,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: Initial values for a binary variable - warmstart

    Posted 05/11/15 04:08 PM

    Hi

    after

    opl.postProcess();

    you may add


     writeln(opl.printSolution());

     

    in the main block

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer