Skip to content

Commit

Permalink
fix(core): catch missing reduced costs and shadow prices. Fixes #1381
Browse files Browse the repository at this point in the history
…and #1372
  • Loading branch information
Palaract committed Mar 19, 2024
1 parent d6632a4 commit 9a42a83
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cobra/core/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,15 @@ def get_solution(
reduced = np.empty(len(reactions))
var_primals = model.solver.primal_values
shadow = np.empty(len(metabolites))
if model.solver.is_integer:

try:
var_duals = model.solver.reduced_costs
constr_duals = model.solver.shadow_prices
duals_available = True
except Exception:
duals_available = False

if model.solver.is_integer or not duals_available:
reduced.fill(np.nan)
shadow.fill(np.nan)
for i, rxn in enumerate(reactions):
Expand Down

0 comments on commit 9a42a83

Please sign in to comment.