ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 13 Jan 2022 17:13:10 +0100MixedIntegerLinearProgram with non feasible problemhttps://ask.sagemath.org/question/60667/mixedintegerlinearprogram-with-non-feasible-problem/ This is a simple reflexion : when `glpk` diagnose that a Linear programming program has no solution this is not an error but a diagnose in `MixedIntegerLinearProgram`. So the result should be only a warning that there is not feasible solution not a list of errors
Thu, 13 Jan 2022 14:03:35 +0100https://ask.sagemath.org/question/60667/mixedintegerlinearprogram-with-non-feasible-problem/Answer by Max Alekseyev for <p>This is a simple reflexion : when <code>glpk</code> diagnose that a Linear programming program has no solution this is not an error but a diagnose in <code>MixedIntegerLinearProgram</code>. So the result should be only a warning that there is not feasible solution not a list of errors</p>
https://ask.sagemath.org/question/60667/mixedintegerlinearprogram-with-non-feasible-problem/?answer=60669#post-id-60669This is not specific to `glpk` solver, and absence of solutions is serious enough to raise an 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")Thu, 13 Jan 2022 17:13:10 +0100https://ask.sagemath.org/question/60667/mixedintegerlinearprogram-with-non-feasible-problem/?answer=60669#post-id-60669