diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 29818db2..8f2e2799 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -17,6 +17,7 @@ Upcoming Version * Add ``active`` parameter to ``piecewise()`` for gating piecewise linear functions with a binary variable (e.g. unit commitment). Supported for incremental, SOS2, and disjunctive methods. * Add the `sphinx-copybutton` to the documentation * Add SOS1 and SOS2 reformulations for solvers not supporting them. +* Improve handling of CPLEX solver quality attributes to ensure metrics such are extracted correctly when available. * Fix Xpress IIS label mapping for masked constraints and add a regression test for matching infeasible coordinates. * Enable quadratic problems with SCIP on windows. diff --git a/linopy/solvers.py b/linopy/solvers.py index 474459fe..10731547 100644 --- a/linopy/solvers.py +++ b/linopy/solvers.py @@ -1405,14 +1405,16 @@ def get_solver_solution() -> Solution: m.solution.get_values(), m.variables.get_names(), dtype=float ) - if is_lp: + try: dual = pd.Series( m.solution.get_dual_values(), m.linear_constraints.get_names(), dtype=float, ) - else: - logger.warning("Dual values of MILP couldn't be parsed") + except Exception: + logger.warning( + "Dual values not available (e.g. barrier solution without crossover)" + ) dual = pd.Series(dtype=float) return Solution(solution, dual, objective)