Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

CPLEX Indicator Constraints in Java API

  • 1.  CPLEX Indicator Constraints in Java API

    Posted Tue June 08, 2021 07:15 PM

    I'm using the Java API of CPLEX (12.6.1 version) to solve a MILP problem.

    This is how I create 'normal' constraints:

    public void charge_discharge_constraints() throws IloException { for (int k = 0; k < periods; k++) { for (int p = 0; p < num_p; p++) { IloLinearNumExpr exp = model.linearNumExpr(); for (int n = 0; n < num_n; n++) exp.addTerm(1, bc_p[n][p][k]); exp.addTerm(1.0, bd_p[p][k]); IloRange constr = model.addGe(1, exp, "Non simultaneous charge discharge"); } } }

    Now, I'm trying to add an 'indicator constraint' such as:

    if bd_p[p][k] == 1, -> (then) h_p[p][k] <= 4800.0

    for every `p` and `k` indices.

    I tried to achieve this by doing:

    public void indicator_constraints() throws IloException { for (int p = 0; p < num_p; p++) { for (int k = 0; k < periods; k++) { IloLinearNumExpr exp = model.linearNumExpr(); exp.addTerm(1, h_p[p][k]); model.add(model.ifThen(model.eq(bd_p[p][k], 1.0), model.le(exp, 4800.0))); } } }

    But, after having observed the generated ".lp" file, I noticed that the indicator constraints I created use the double-arrow simbol (<->), while my aim is to use the right-arrow symbol (->).

    Which is the problem? How could I achieve my goal?






    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: CPLEX Indicator Constraints in Java API

    Posted Tue June 08, 2021 10:40 PM

    symbol <-> alone is not surprising. It can be the way CPLEX linearizes the indicator constraints. If you are curious, you can write a model with just one indicator constraint and see how CPLEX linearizes it.

    If you need further discussion, please open a case if you are entitled. Otherwise, please discuss your question in Data Science Community https://community.ibm.com/community/user/datascience/communities/community-home/digestviewer?communitykey=ab7de0fd-6f43-47a9-8261-33578a231bb7&tab=digestviewer






    #DecisionOptimization
    #Support
    #SupportMigration