How to toggle a Boolean variable and then read the final value
Awaiting user inputHello guys, I am working with a constraint model where I want to toggle a Boolean variable every once in a while and I also want to read the value of the Boolean variable using model runtime.
Python example of what I want to implement in a constraint program:
bool b1 = False
for i in range(5):
if(i%2==0):
bool = !bool
if(bool):
print("It is true")
--------
end the model and return values of decision variable
Is there any way we can toggle a boolean variable in a constraint model and read it during Run time? Or any other way to achieve this using a constraint program?
I would really appreciate your help :)
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Sanket,
I am not sure I got your question right.
Let's start from the easier part: if you want to query the value of any variable during the optimization process, you should use a callback.
Could you please elaborate more on what you mean by "boolean toggling"?
Best regards
Jonasz0
Post is closed for comments.
Comments
2 comments