write if condition with decision variables
Opened this issue · 1 comments
Hi,
How can we use decision variables in if conditions?
thanks
Short answer is no. Decision variables receive a value only after the solve algorithm has succeeded to compute a solution.
However, there are techniques to add constraints only when certain conditions are satisfied, thiey are called logical constraints,; this can be achieved with indicator constraints, or equivalence constraints. This is explained in depth
in this notebook: https://github.com/IBMDecisionOptimization/docplex-examples/blob/master/examples/mp/jupyter/logical_cts.ipynb.
A more detailed answer would require that you explain more what problem are you trying to model.
Finally, the preferred chanell to ask for general questions like this is stackoverflow.com
; add the docplex
tag to your question and a large community of users may answer