Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Float to Int Conversion in Column Generation not hap

    Posted Wed May 25, 2016 10:30 PM

    Originally posted by: abhzap


    Hi All,

         In the final step of CG, we do the LP to MIP conversion and solve the master problem (MIP version).

         However, I am not able to change my model variables from float to int.

         Here is how I go about doing it (looking at cutstock. java example)

          //convert to an integer version of the problem


                 //converting the X variables
                 for ( Map.Entry<MpVarX, IloNumVar> var : usedVarX.entrySet() ) {                
                     master_problem.add(master_problem.conversion(var.getValue(), IloNumVarType.Int));          
                 }


                 //converting the Y variables
                 for ( Map.Entry<MpVarY, IloNumVar> var : usedVarY.entrySet() ) {                 
                     master_problem.add(master_problem.conversion(var.getValue(), IloNumVarType.Int));
                 }


                 //converting the Z variables
                 for ( Map.Entry<MpVarZ, IloNumVar> var : usedVarZ.entrySet()  ) {
                     master_problem.add(master_problem.conversion(var.getValue(), IloNumVarType.Int));            
                 }

                 I check the type of the variables after solving the master problem and find that it is still float!

                 Is there a issue with the way I am using Java?

    -abhzap

     

         

                

         


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Float to Int Conversion in Column Generation not hap

    Posted Thu May 26, 2016 03:36 PM

    Assuming the map values are the IloNumVars in your master problem, this looks correct to me. Have you tried either tracing execution in a debugger or sticking print statements in the loops to verify that the calls to IloCplex.add() are actually occurring (with the expected arguments)?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Float to Int Conversion in Column Generation not hap

    Posted Thu May 26, 2016 09:27 PM

    Originally posted by: abhzap


    Hi Paul,

         Thank you for the reply. I checked and it seems the IloConversion object is being added. For e.g. the code below

               //converting the X variables
                 for ( Map.Entry<MpVarX, IloNumVar> var : usedVarX.entrySet() ) {                
                     master_problem.add(master_problem.conversion(var.getValue(), IloNumVarType.Int)); 
                     IloConversion convObj = master_problem.conversion(var.getValue(), IloNumVarType.Int);
                     master_problem.add(convObj);                  
                 }

             gives the error -> CPLEX Error: multiple type conversions on a variable' caught; so the IloCoversion object is being added to the model.

            

              Also, when write the solution using : master_problem.writeSolution("jsol"); The information included there actually shows the model is solved as an MIP.  A part of the information is shown below

     

     <?xml version = "1.0" standalone="yes"?>

    <CPLEXSolution version="1.2">

     <header
       problemName="ilog.cplex"
       solutionName="incumbent"
       solutionIndex="-1"
       objectiveValue="7000"
       solutionTypeValue="3"
       solutionTypeString="primal"
       solutionStatusValue="101"
       solutionStatusString="integer optimal solution"
       solutionMethodString="mip"
       primalFeasible="1"
       dualFeasible="1"
       MIPNodes="0"
       MIPIterations="0"
       writeLevel="1"/>


     <quality
       epInt="1e-05"
       epRHS="1e-06"
       maxIntInfeas="1.00000010050394e-07"
       maxPrimalInfeas="0"
       maxX="1"
       maxSlack="9999998"/>

        

               The solution is however still like below:

     X_1 = 1.0
     X_2 = 1.00000010000001E-7
     X_3 = 1.00000010000001E-7
     X_4 = 1.00000010000001E-7
     X_5 = 1.00000010000001E-7
     Y_1 = 1.00000010000001E-7
     Y_2 =  1.00000010000001E-7
     Y_3 = 1.0
     Y_4 = 0.99999989999999
     Y_5 = 0.99999989999999

             

          


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Float to Int Conversion in Column Generation not hap

    Posted Thu May 26, 2016 11:08 PM

    So the integer conversion actually is working. All those values are within rounding tolerance of integer. The default integrality tolerance for CPLEX (the IloCplex.Param.MIP.Tolerances.Integrality parameter) is 1E-5, and all those values are well within 1e-5 of either 0 or 1.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Float to Int Conversion in Column Generation not hap

    Posted Fri May 27, 2016 04:05 AM

    Originally posted by: abhzap


    Thanks for the help Paul! This resolves one of my issues.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Float to Int Conversion in Column Generation not hap

    Posted Wed March 07, 2018 11:09 AM

    Originally posted by: TOYSED


    Hello,

    I also have a problem with the use of IloConversion. I have a Column Generation code. At the last step, I convert the parameters of my MasterModel to boolean with IloConversion but the code could not compute the minimum value.

     

    here is the conversion;

    IloModel IntegerMaster(env);
     IloCplex cplex1(IntegerMaster);
     IntegerMaster.add(Mmodel);
     
     for (j = 0; j <nofG; j++)
      IntegerMaster.add(IloConversion (env, P[j], ILOBOOL));
     
     cplex1.solve();
     cplex1.exportModel("d://IntegerMasterModel.LP");
     cout<<"Objective ="<< cplex1.getObjValue()<<endl;

     

    And the resultant model;

     

    Minimize
     obj: 538 x1 + 509 x2 + 242 x3 + 338 x4 + 89 x5 + 35 x6 + 146 x7 + 155 x8
    Subject To
     c1: x1 + x6 + x7 - x9  = 0
     c2: x2 + x8 - x10  = 0
     c3: x3 + x7 + x8 - x11  = 0
     c4: x4 - x12  = 0
     c5: x5 + x6 - x13  = 0
     c6: x1 + x2 + x3 + x4 + x5 + 5 x6 + 5 x7 + 5 x8  = 2
    Bounds
     0 <= x1 <= 1
     0 <= x2 <= 1
     0 <= x3 <= 1
     0 <= x4 <= 1
     0 <= x5 <= 1
     0 <= x6 <= 1
     0 <= x7 <= 1
     0 <= x8 <= 1
     0 <= x9 <= 1
     0 <= x10 <= 1
     0 <= x11 <= 1
     0 <= x12 <= 1
     0 <= x13 <= 1
    Binaries
     x1  x2  x3  x4  x5  x6  x7  x8
    End

     

     

    Original models 


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Float to Int Conversion in Column Generation not hap

    Posted Wed March 07, 2018 12:09 PM

    What do you mean by "could not compute minimum value"? Can you please elaborate?

    When I put your model into an LP file then it solves here in a blink.


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Float to Int Conversion in Column Generation not hap

    Posted Wed March 07, 2018 12:30 PM

    Originally posted by: TOYSED


    Thanks for your fast response. 

    When I solve this model, I obtain an objective function value of 331 where x3 and x5 are 1. But this solution is not the minimum . I expect to obtain a solution of 190.

     It seems like that the code only considers the first five variables which are there before column generation. Although I see all the variables in the final model 

    the following code does not consider variables x6, x7 and x8 added to the Master Model. Thus I obtain an objective function value of 331 instead of 190. I wonder if this is related to wrong use of IloConversion or not? How can I solve this issue?


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Float to Int Conversion in Column Generation not hap

    Posted Wed March 07, 2018 12:37 PM

    Originally posted by: TOYSED


    I figured out my problem...I taught it is related with IloConversion because I focused on that. Thanks...:)


    #CPLEXOptimizers
    #DecisionOptimization