Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write if condition with decision variables #86

Open
pedramjazayeri opened this issue Apr 8, 2023 · 1 comment
Open

write if condition with decision variables #86

pedramjazayeri opened this issue Apr 8, 2023 · 1 comment

Comments

@pedramjazayeri
Copy link

Hi,
How can we use decision variables in if conditions?
thanks

@PhilippeCouronne
Copy link

PhilippeCouronne commented Apr 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants