Ask Your Question
1

Get index of a set constraint

asked 2016-01-09 13:04:36 +0100

tom123 gravatar image

Using SageMath I'm trying to implement a method for the solution of a problem where I in an iterative way add a set of constraints, try to solve the problem to check if exist a solution, if not i remove the constraints and restart.

 try:
    p.solve()           
 except RuntimeError:
    p.remove_constraint(index)

Given a set of constraint that I add, how to get their indexes so that I can remove them?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-01-09 13:53:57 +0100

vdelecroix gravatar image

The constraints should be in the order you entered them. To remove the last just do

sage: p.remove_constraint(p.number_of_constraints() - 1)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-01-09 13:04:36 +0100

Seen: 271 times

Last updated: Jan 09 '16