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 :)
-
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
Please sign in to leave a comment.
Comments
1 comment