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")