Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  LP Relaxation

    Posted 06/09/15 01:59 PM

    Originally posted by: Thaher


    Hi All,

     

    In my OPL model I have binary variables and integer variables. Is there  any way I can solve the LP relaxation of the problem without re-declaring the variables.  Will this code, if exists, include the integer variables in addition to the binary variables ?. I have, indeed, added the following code at the end of my model, I got no solution. I am not sure if my syntax is correct, placed at right place and serve the intended purpose.

     

    main {
     
      thisOplModel.convertAllIntVars();
      if (cplex.solve()) {
        writeln("Relaxed Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());  
       
      }
       
    }

     

    Regards,

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: LP Relaxation

    Posted 06/10/15 02:24 AM

    Hi,

    this is the right method and you have an example in

    CPLEX_Studio1261\opl\examples\opl\convert_example

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: LP Relaxation

    Posted 06/11/15 07:28 AM

    Originally posted by: Thaher


    Hi,

    Thanks indeed. I get no solution though.  I had this message in the engine log :

    Tried aggregator 1 time.
    No LP presolve or aggregator reductions.
    Presolve time = 0.00 sec. (0.00 ticks)

     

    I am afraid  I am missing something. Appreciate your advice.

    Regards,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: LP Relaxation

    Posted 06/11/15 11:57 AM


  • 5.  Re: LP Relaxation

    Posted 06/11/15 12:04 PM

    Originally posted by: Thaher


    Hi,

    I get the following in scripting log :

     

    Relaxed Model
    OBJECTIVE: 0

     

    Regards,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: LP Relaxation

    Posted 06/11/15 12:10 PM

    Hi,

    so

    if (cplex.solve()) {
        writeln("Relaxed Model");   
        writeln("OBJECTIVE: ",cplex.getObjValue());  
       
      }

    worked and you got 0

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: LP Relaxation

    Posted 06/12/15 08:44 AM

    Originally posted by: Thaher


    Hi,

    Thanks, I understand, I am suspecting this 0 if it was a valid LP relaxation solution. I will try for other models.

    Thanks,


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: LP Relaxation

    Posted 05/09/16 05:53 AM

    Let me share an example about how to use the relaxation in the original problem:

    int Fixed        = 1000;
    int NbWarehouses = 50;
    int NbStores     = 2000;

     

    assert( NbStores > NbWarehouses );

    range Warehouses = 1..NbWarehouses;
    range Stores     = 1..NbStores;
    int Capacity[w in Warehouses] =
      NbStores div NbWarehouses +
      w % ( NbStores div NbWarehouses );
    int SupplyCost[s in Stores][w in Warehouses] =
      1 + ( ( s + 10 * w ) % 100 );
    dvar int Open[Warehouses] in 0..1;
    dvar boolean Supply[Stores][Warehouses] in 0..1;
    dexpr int TotalFixedCost = sum( w in Warehouses ) Fixed * Open[w];
    dexpr float TotalSupplyCost = sum( w in Warehouses, s in Stores )  SupplyCost[s][w] * Supply[s][w];
    minimize TotalFixedCost + TotalSupplyCost;

    subject to {
      forall( s in Stores )
        ctStoreHasOneWarehouse:
          sum( w in Warehouses )
            Supply[s][w] == 1;
      forall( w in Warehouses )
        ctOpen:
          sum( s in Stores )
            Supply[s][w] <= Open[w] * Capacity[w];
    }

    main
    {
    thisOplModel.generate();

    thisOplModel.convertAllIntVars();
     cplex.solve();
     thisOplModel.postProcess();
     writeln(thisOplModel.Open) ;
     
     var sol=new Array(50);
     for(var w in thisOplModel.Warehouses)
     {
        (sol[w]=thisOplModel.Open[w].solutionValue)  
     }
     
     cplex.epgap=0.02;
     thisOplModel.unconvertAllIntVars();
     writeln("unconvert");
     for(w in thisOplModel.Warehouses)
     {
       if (sol[w]>=0.99) thisOplModel.Open[w].LB=1;
       if (sol[w]<=0.01) thisOplModel.Open[w].UB=0;
     }
      cplex.solve();
      thisOplModel.postProcess();
     
    }  

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer