Skip to content

Conversation

@jonathanberthias
Copy link
Contributor

Description

Please include a short summary of the change.

The SCIP interface currently doesn't return any information about the solving process to the end user, despite retrieving it after the optimization.

This PR ensures the information is passed along the solving chain.

I added the usual attributes as well as the model itself to the extra stats to enable more advanced analysis without having to extract all available fields in the interface. One field I was unsure about is SETUP_TIME, I wasn't able to find a clear definition and an equivalent in SCIP.

Closes #2591
Closes #2910

Type of change

  • New feature (backwards compatible)
  • New feature (breaking API changes)
  • Bug fix
  • Other (Documentation, CI, ...)

Contribution checklist

  • Add our license to new files.
  • Check that your code adheres to our coding style.
  • Write unittests.
  • Run the unittests and check that they’re passing.
  • Run the benchmarks to make sure your change doesn’t introduce a regression.

raise error.SolverError(f"All solvers failed: {solvers}")

def solve(self, *args, **kwargs):
def solve(self, *args, **kwargs) -> float:
Copy link
Contributor Author

@jonathanberthias jonathanberthias Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated change but it has bugged me a few times when typing downstream projects 😄
I added a check that the value is a float and it seems to always be the case in the test suite, but I'm not 100% sure it's guaranteed in all cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into this, and the result could be None if the solver status is something like INFEASIBLE_OR_UNBOUNDED. See https://github.com/cvxpy/cvxpy/blob/master/cvxpy/reductions/solution.py#L30 So the return type should be float | None

Copy link
Contributor Author

@jonathanberthias jonathanberthias Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed my test setup wasn't in the correct place, there seems to be a lot of possible return types (though I'm not sure it's correct). Here are some types generated during the tests:

  • float, int OK
  • None OK
  • np.complex128? (the imaginary part is 0 up to numerical precision)
  • tuple? (I think this is using custom solve methods)

So I'll just revert this change for now, it should be handled more thoroughly.

Suggested change
def solve(self, *args, **kwargs) -> float:
def solve(self, *args, **kwargs):

Copy link
Collaborator

@SteveDiamond SteveDiamond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than changing solve return type to float | None

@github-actions
Copy link

Benchmarks that have stayed the same:

   before           after         ratio
 [f33600eb]       [e547bb61]
      518±0ms          530±0ms     1.02  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
      15.7±0s          16.0±0s     1.02  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
      276±0ms          282±0ms     1.02  matrix_stuffing.ParamSmallMatrixStuffing.time_compile_problem
      2.06±0s          2.09±0s     1.02  quantum_hilbert_matrix.QuantumHilbertMatrix.time_compile_problem
      1.15±0s          1.17±0s     1.02  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
      281±0ms          284±0ms     1.01  simple_QP_benchmarks.SimpleQPBenchmark.time_compile_problem
      308±0ms          311±0ms     1.01  high_dim_convex_plasticity.ConvexPlasticity.time_compile_problem
      1.33±0s          1.34±0s     1.01  matrix_stuffing.ParamConeMatrixStuffing.time_compile_problem
      6.47±0s          6.51±0s     1.01  huber_regression.HuberRegression.time_compile_problem
      33.0±0s          33.1±0s     1.01  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
      3.09±0s          3.11±0s     1.01  simple_QP_benchmarks.UnconstrainedQP.time_compile_problem
      552±0ms          554±0ms     1.00  simple_QP_benchmarks.ParametrizedQPBenchmark.time_compile_problem
      2.31±0s          2.32±0s     1.00  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem
      19.4±0s          19.5±0s     1.00  finance.CVaRBenchmark.time_compile_problem
      5.27±0s          5.28±0s     1.00  optimal_advertising.OptimalAdvertising.time_compile_problem
      1.25±0s          1.24±0s     1.00  simple_QP_benchmarks.LeastSquares.time_compile_problem
     36.1±0ms         35.8±0ms     0.99  matrix_stuffing.SmallMatrixStuffing.time_compile_problem
      770±0ms          757±0ms     0.98  matrix_stuffing.ConeMatrixStuffingBench.time_compile_problem
      1.91±0s          1.86±0s     0.97  tv_inpainting.TvInpainting.time_compile_problem
      431±0ms          420±0ms     0.97  gini_portfolio.Yitzhaki.time_compile_problem
      7.87±0s          7.65±0s     0.97  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem
      390±0ms          377±0ms     0.97  slow_pruning_1668_benchmark.SlowPruningBenchmark.time_compile_problem
      991±0ms          946±0ms     0.95  gini_portfolio.Cajas.time_compile_problem
      1.79±0s          1.70±0s     0.95  finance.FactorCovarianceModel.time_compile_problem
      331±0ms          315±0ms     0.95  gini_portfolio.Murray.time_compile_problem

@SteveDiamond SteveDiamond merged commit 828f519 into cvxpy:master Dec 18, 2025
44 checks passed
@jonathanberthias jonathanberthias deleted the scip-extra-stats branch December 18, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MIPGap retrieval for SCIP solver SolverStats not reported for SCIP

3 participants