| 1 | initial version |
This is not specific to glpk solver, and absence of solutions is serious enough to raise an excepting rather than giving just a warning. Anyway, you can easily catch this exception by enclosing .solve() into try and except like in the example below:
from sage.numerical.mip import MIPSolverException
M = MixedIntegerLinearProgram()
x = M.new_variable()
M.add_constraint(x[0] == 0)
M.add_constraint(x[0] == 1)
try:
M.solve()
except MIPSolverException:
print("No feasible solution")
| 2 | No.2 Revision |
This is not specific to glpk solver, and absence of solutions is serious enough to raise an excepting exception rather than giving just a warning. Anyway, you can easily catch this exception by enclosing .solve() into try and except like in the example below:
from sage.numerical.mip import MIPSolverException
M = MixedIntegerLinearProgram()
x = M.new_variable()
M.add_constraint(x[0] == 0)
M.add_constraint(x[0] == 1)
try:
M.solve()
except MIPSolverException:
print("No feasible solution")
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.