Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): catch missing reduced costs and shadow prices. #1383

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading