Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/11/19 01:26 PM

    Originally posted by: Kate1592


    Hi,

    Im trying to use benders strategy in cplex to solve a scenario based problem. I used the strategy 2 and provided annotations to define the master and sub problem variables. But, I'm getting this error "Cannot convert to an Integer" and I'm not sure what does that indicate. Can someone please help me understand this error?

     

     Following is the code lines for strategy 2. The error is in the highlighted line and B is a continuous variable

    var masterDef = thisOplModel.modelDefinition;
    var masterElts = thisOplModel.dataElements;

    var subCplex2 = new IloCplex();
    var subOpl2 = new IloOplModel(masterDef, subCplex2);
    subOpl2.addDataSource(masterElts);
    subOpl2.generate();
    subCplex2.bendersstrategy = 2;

    subCplex2.newLongAnnotation("cpxBendersPartition");
    for(var sc=1; sc<=thisOplModel.scenarios;sc++){
        for(var cj=1; cj<=thisOplModel.numclientjobs;cj++){    
            for(var s=1; s<=thisOplModel.statesizes[cj];s++){            
                for(var t=1;t <= thisOplModel.numTU[thisOplModel.TSin[cj][s]]; t++){    
    subCplex2.setLongAnnotation("cpxBendersPartition", subOpl2.B[sc][cj][s][t],  subOpl2.bendersPartition);

                }
            }
        }
    }
    subCplex2.solve();

    t
    cplex.exportModel("benders.lp");
    subCplex2.writeBendersAnnotation("cplex2.ann");
    writeln(subCplex2.getObjValue());

     

    In the beginning, I partition the model as:

    int bendersPartition[sc in 1..scenarios][i in 1..numclientjobs][s in 1..bigstatesize][1..maxTU] = sc;
    int bendersPartition2[sc in 1..scenarios] = sc;

     

     

    Can someone please help me understand this error?

     

     

    Thanks in advance!


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/12/19 06:06 AM

    Which is the highlighted line? Could you attach all the files that are required to actually run your model?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/12/19 06:11 PM

    Originally posted by: Kate1592


    Thank you so much for getting back to me.

     

    I'm so sorry that I couldn't get back to you earlier. I forgot to highlight the line before. The following is the line which gives the error.

    subCplex2.setLongAnnotation("cpxBendersPartition", subOpl2.B[sc][cj][s][t],  subOpl2.bendersPartition);

     

    I have also attached my files.

     

    Thanks so much in Advance!

    Kate


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/15/19 02:32 AM

    It seems you forgot to attach your files but I figured it out anyway :-) The problem in this statement

    subCplex2.setLongAnnotation("cpxBendersPartition", subOpl2.B[sc][cj][s][t],  subOpl2.bendersPartition);

    is that subOpl2.B[sc][c][s][t] is a single variable wihle subOpl2.bendersPartition is a four-dimensional array. You cannot set the partition of a single variable to an array of values. What you want to do is to set it to a single value:

    subCplex2.setLongAnnotation("cpxBendersPartition", subOpl2.B[sc][cj][s][t],  subOpl2.bendersPartition[sc][cj][s][t]);

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/15/19 10:25 AM

    Originally posted by: Kate1592


    Hi Daniel,

     

    Thank you so much for helping me. I got the model running, but it took much longer to solve than the original MILP. I could see in the .ann file that modle was considering only one sub-problem instead of 'sc' sub-problems. I had partitioned the problem as:

    int bendersPartition[sc in 1..scenarios][i in 1..numclientjobs][s in 1..bigstatesize][1..maxTU] = sc;
    int bendersPartition2[sc in 1..scenarios] = sc;

     

    I have also attached the files, Could you please let me know if I'm doing something wrong. I would really appreciate it.

     

    Thanks,

    Kate


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/16/19 02:15 AM

    Did you ask the exact same question here: https://www.ibm.com/developerworks/community/forums/html/topic?id=d36e6ab5-d559-4fba-9e47-8570d904db87 ?

    And did you have Alex and me help you independently? Please try to avoid cross posts. And if you feel you have to then please at least link the posts. It is not nice to have several people work on the same question without knowing about each other.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/16/19 11:46 PM

    Originally posted by: Kate1592


    I'm extremely sorry that happened. At first when I posted this problem, I didn't get any response, that is why I posted it in this forum as well, (as I was working with cplex specifically ). I was stuck in the problem and really had to get the solution very soon. Even though the suggested solution got the error fixed, I couldn't get the model run in the way benders is supposed to be and I couldn't hear back from anyone regarding the second issue of model not partitioning into many sub-problems. That is why I continued to ask you as well. I'm really sorry that I didn't mention about that here. Sorry again:(

     

    Kate


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/18/19 11:57 AM

    Originally posted by: Kate1592


    I would greatly appreciate it if you are still willing to help me. I have deleted the second question from the other post and if you could please have a look at the issue with my model, it would be of great help to me. I'm kind of stuck and don't know why the model is not partitioning into many sub-problems as defined.

     

    Thanks

    Kate

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Benders cplex error: Cannot convert to an integer. Can someone please help me understand this error?

    Posted 07/19/19 11:10 AM

    You dumped the annotation via subCplex2.writeBendersAnnotation("cplex2.ann"); However, writeBendersAnnotation (from the docs here)

    <quote>

    Writes the annotation that CPLEX would generate automatically for Benders decomposition to a file with the specified name.

    </quote>

    Try to output annotations with writeAnnotations(). That should give you the annotations you specified. I did not check your actual model/solution process but it could well be that for certain data Benders decomposition is slower than default CPLEX.


    #CPLEXOptimizers
    #DecisionOptimization