Originally posted by: A.Omidi
Dear community team,
I was trying to solve a MIP model that contains a chance constraint. An OPL example is:
https://www.ibm.com/developerworks/community/forums/html/topic?id=662dda0c-f72b-44ef-9da3-9f12022ea6b0&ps=25
I try to write the mentioned model (OPL) in Java and I have some issues on it. The model is as follows:
// variables
IloNumVar x = cplex.numVar(0, Double.MAX_VALUE, "x");
IloNumVar y = cplex.numVar(0, Double.MAX_VALUE, "y");
// expressions
IloLinearNumExpr objective = cplex.linearNumExpr();
objective.addTerm(5, x);
objective.addTerm(6, y);
// define objective
cplex.addMinimize(objective);
// define constraints
double alfa = 0.5;
double[] a1 = new double[] {1,2,3,4,5,6};
double[] a2 = new double[] {1,2,3,4,5,6};
IloLinearNumExpr logic = cplex.linearNumExpr();
for (int i = 0; i < a1.length; i++) {
logic.addTerm(a1[i], x);
logic.addTerm(a2[i], y);
IloLinearNumExpr num_expr = cplex.linearNumExpr();
cplex.add(cplex.ifThen(cplex.ge(logic, 3), cplex.ge(num_expr, (1-alfa)/(1/36))));
}
When it's solved log file is:
Found incumbent of value 0.000000 after 0.00 sec. (0.00 ticks)
Root node processing (before b&c):
Real time = 0.00 sec. (0.00 ticks)
Parallel b&c, 4 threads:
Real time = 0.00 sec. (0.00 ticks)
Sync time (average) = 0.00 sec.
Wait time (average) = 0.00 sec.
------------
Total (root+branch&cut) = 0.00 sec. (0.00 ticks)
obj = 0.0
x = 0.0
y = 0.0
I think the probabilistic model is a little bit different from the logical constraints model. In if-clause, in my model, I do not have a parameter and it is an expression. I added an IloLinearNumExpr "num_expr " to add the result to the if-clause but, it did not work.
Would you please, say that how can I interpret such expressions using "add method"?
Regards
#CPLEXOptimizers#DecisionOptimization