Skip to content

Determine time spent in solver for CPLEX#636

Open
danielelerede-oet wants to merge 3 commits intoPyPSA:masterfrom
open-energy-transition:solving_time_cplex
Open

Determine time spent in solver for CPLEX#636
danielelerede-oet wants to merge 3 commits intoPyPSA:masterfrom
open-energy-transition:solving_time_cplex

Conversation

@danielelerede-oet
Copy link
Copy Markdown
Contributor

@danielelerede-oet danielelerede-oet commented Mar 27, 2026

Changes proposed in this Pull Request

When calling CPLEX through linopy, the returned Result object contained only:

  • status
  • solution
  • solver_model = m (the raw cplex.Cplex object)
    but it did NOT include the solver runtime.

This creates of course an issue for benchmarking cplex as we cannot reliably access the solve time from linopy, and of course the profiler misses it completely

Other solvers in Linopy already expose structured metrics:

Knitroreturns a KnitroResult with runtime + gaps + errors
HiGHS runtime accessible via solver info
Gurobi / Xpress can access runtime from API

So I'm proposing here to add a lightweight wrapper, similar to Knitro:

CplexResult = namedtuple("CplexResult", ["model", "reported_runtime"])
and modify the solve steps accordingly.

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

@danielelerede-oet danielelerede-oet marked this pull request as ready for review March 27, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant