Logical expressions in CPLEX
Learn logical expressions from docplex.cp.modeler:
http://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.modeler.py.html
Use logical_and to express “if”:
ct = modeler.logical_and(xr <= modeler.element(temp_a, xd), modeler.element(temp_a, xd) != -1)
cplex_model.add(ct)
Remember to use modeler.xxx to override the python function
For example, if you want to find the minimum of two expressions, do not use “min” but instead “modeler.min”, which takes an array as input.
In the example below, temp_obj_expr is the objective function. xl and xu are decision variables, and the others are data.
The