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