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

Solve several problems without restarting Python #39

Closed
bilelouahmed opened this issue Nov 19, 2023 · 1 comment
Closed

Solve several problems without restarting Python #39

bilelouahmed opened this issue Nov 19, 2023 · 1 comment

Comments

@bilelouahmed
Copy link

Hello !

I have a use case in which I have to solve several constraint problems but I don't know how to assign new variables without restarting the Python kernel.

Example :

for i in range(10):
  x = VarArray(10, [0,1])
  satisfy( blablabla)
  solve()

ERROR: The identifier x is used twice. This is not possible
(add option -ev to your command if you want to see the trace of the error)
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1

Thanks !

@xcsp3team
Copy link
Owner

Hello,

Two ways you can try:

  • call clear() after solve() in order to discard everything (variables and constraints)

  • declare the array x before starting the loop
    Please, tell us if this addresses your problem.

    Best.

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