Decision Optimization

 View Only
Expand all | Collapse all

Variables annotations in CPLEX for Automatic Benders decomposition Java API

  • 1.  Variables annotations in CPLEX for Automatic Benders decomposition Java API

    Posted Tue September 13, 2022 09:50 AM

    Hello everyone,

    I am trying to implement the automatic benders decomposition to my problem using CPLEX version 20.10. I want to use USER strategy to decompose the model according to my annotations.

    So first I initialize the strategy of benders algorithm and cplex.newLongAnnotation to specify cpxBendersPartition of variables.

    cplex.setParam(IloCplex.Param.Benders.Strategy, IloCplex.BendersStrategy.User);
    IloCplex.LongAnnotation benders = cplex.newLongAnnotation(IloCplex.CPX_BENDERS_ANNOTATION,IloCplex.CPX_BENDERS_MASTERVALUE + 1);

    Then after initializing the integer variable x in X.

    IloIntVar [] x = new IloIntVar[NumofRoute]; //integer

    I tried to annotate it as following and add it to the master problem (value = 0)

    for(int k=0; k < x.length; k++) {
         x [k] = cplex.intVar(0,cluster.getNbVeh(),"x_"+k);
         cplex.setAnnotation(benders, x[k],IloCplex.CPX_BENDERS_MASTERVALUE);
    }

    However at this point I got the following errors:

    ilog.cplex.IloCplex$UnknownObjectException: CPLEX Error: object is unknown to IloCplex
    at ilog.cplex.IloCplex.getIndexOrException(IloCplex.java:11470)
    at ilog.cplex.IloCplex.access$7400(IloCplex.java:453)
    at ilog.cplex.IloCplex$AnnotationList.getIndexAndType(IloCplex.java:22273)
    at ilog.cplex.IloCplex$AnnotationList.setAnnotation(IloCplex.java:22302)
    at ilog.cplex.IloCplex.setAnnotation(IloCplex.java:22851)

    So my questions are why am I getting this error ? and how to annotate the variables to use in an annotated decomposition for Benders algorithm?
    And is there a way to export the .LP files of the master and the sub-problem(s) ?

    Thank you so much in advance.








    ------------------------------
    ISSA bou zeid
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Variables annotations in CPLEX for Automatic Benders decomposition Java API

    IBM Champion
    Posted Tue September 13, 2022 03:47 PM
    Even though you have created the variable x[k], it is not yet part of the model. There are two ways you can fix the code. One is to wait until after some expression containing x[k] as been added in a constraint or objective function and then set the annotation. (Note that it is not enough that x[k] appear in a constraint or objective expression; you have to wait until that constraint/objective has been added to the model using cplex.addLe() or cplex.addMinimize() or equivalent.) The other solution, which makes minimal disruption to your code, is simply to add the line "cplex.add(x[k]);" in between the line that defines x[k] and the line that adds the annotation.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Variables annotations in CPLEX for Automatic Benders decomposition Java API

    Posted Thu September 15, 2022 04:57 AM
    Thank you so much Paul for your help. It is much appreciated.

    ------------------------------
    ISSA bou zeid
    ------------------------------