Infeasibility and the run_model status.
Chapter: II — Reading the solver · lesson id solver-status · practice lesson
If you ask for x >= 5 and x <= 2 at the same time, no value of x satisfies both. The model is infeasible.
The clean way to know what happened: capture what elytica.run_model(...) hands back — a status string from the underlying solver. Values like "Optimal", "Infeasible", "Unbounded".
Run the deliberately broken model, capture the status, and print it. The check below passes once your output reports an infeasibility status.
What status will the solver report for x >= 5 and x <= 2?
model broken
var x
constr x >= 5
constr x <= 2
max x
end
import elytica
def main():
elytica.init_model("broken")
elytica.run_model("broken")
# TODO: capture the return of elytica.run_model above and print it as "status ="
return 0
status = elytica.run_model("broken"); then print("status =", status)
stdout-regex — Output reports an infeasibility statusmodel broken
var x
constr x >= 5
constr x <= 2
max x
end
import elytica
def main():
elytica.init_model("broken")
status = elytica.run_model("broken")
print("status =", status)
if "infeas" in str(status).lower():
print("No feasible point exists for this model.")
return 0
A different infeasible model. Capture and print the status the same way.
model broken_v
var z
constr z >= 10
constr z <= 3
min z
end
import elytica
def main():
elytica.init_model("broken_v")
elytica.run_model("broken_v")
# TODO: capture the return of elytica.run_model above and print it as "status ="
return 0
Read this through MCP: read with path: "lessons/solver-status", or resource hlpl://lessons/solver-status.