ryanjoneil / python-zibopt

Automatically exported from code.google.com/p/python-zibopt
2 stars 1 forks source link

add the ability to remove constraints #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Constraints can be added but not deleted from a problem.  It would be nice
to save constraints in a variable and remove them later on.

Original issue reported on code.google.com by ryan%che...@gtempaccount.com on 22 Jan 2010 at 10:47

GoogleCodeExporter commented 9 years ago
This exists in trunk against Python 3.2 and SCIP 2.0.1 now.  It will be part of 
the 0.6 release.  Example code:

Python 3.2 (r32:88445, Mar 25 2011, 19:56:22) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from zibopt import scip
>>> solver = scip.solver()
>>> x1 = solver.variable(scip.INTEGER)
>>> x2 = solver.variable(scip.INTEGER)
>>> c1 = solver.constraint(upper=4, coefficients={x1:2, x2:2})
>>> c2 = solver.constraint(upper=3, coefficients={x1:2, x2:2})
>>> solver.maximize(objective=x1+x2).objective
1.0
>>> solver -= c2
>>> solver.maximize(objective=x1+x2).objective
2.0
>>> solver += c2
>>> solver.maximize(objective=x1+x2).objective
1.0

Original comment by ryanjoneil on 24 May 2011 at 9:34