Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add commercial solver default setting#3352

Merged
SteveDiamond merged 1 commit into
masterfrom
ptn/tweaks-default-settings
Jun 4, 2026
Merged

Add commercial solver default setting#3352
SteveDiamond merged 1 commit into
masterfrom
ptn/tweaks-default-settings

Conversation

@PTNobel
Copy link
Copy Markdown
Collaborator

@PTNobel PTNobel commented May 27, 2026

Description

Adds an internal env-backed setting to skip commercial solvers when choosing defaults. This is useful for local development when testing multiple solver interfaces.
Issue link (if applicable):

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.

Comment thread cvxpy/settings.py
value = os.environ.get(name)
if value is None:
return default
return value.strip().lower() not in {"0", "false", "no", "off"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An empty env var (CVXPY_DEFAULT_TO_COMMERCIAL_SOLVERS="") is treated as True here, since "" is not in the falsy set. Some deployment systems and CI environments set env vars to empty strings to effectively unset them, so having that silently enable commercial solver preference is surprising.

Consider adding "" to the falsy set:

return value.strip().lower() not in {"", "0", "false", "no", "off"}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's absolutely my intent since we want it to default to true

@github-actions
Copy link
Copy Markdown

Benchmarks that have improved:

   before           after         ratio
 [6b637368]       [13821d54]
  •     581±0ms          510±0ms     0.88  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
    

Benchmarks that have stayed the same:

   before           after         ratio
 [6b637368]       [13821d54]
      380±0ms          396±0ms     1.04  slow_pruning_1668_benchmark.SlowPruningBenchmark.time_compile_problem
      280±0ms          290±0ms     1.04  simple_QP_benchmarks.SimpleQPBenchmark.time_compile_problem
      30.2±0s          30.7±0s     1.02  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
      5.55±0s          5.56±0s     1.00  optimal_advertising.OptimalAdvertising.time_compile_problem
      1.37±0s          1.38±0s     1.00  matrix_stuffing.ParamConeMatrixStuffing.time_compile_problem
     14.5±0ms         14.5±0ms     1.00  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem
      282±0ms          283±0ms     1.00  matrix_stuffing.ParamSmallMatrixStuffing.time_compile_problem
      878±0ms          875±0ms     1.00  matrix_stuffing.ConeMatrixStuffingBench.time_compile_problem
      5.83±0s          5.81±0s     1.00  huber_regression.HuberRegression.time_compile_problem
      1.71±0s          1.69±0s     0.99  finance.FactorCovarianceModel.time_compile_problem
     46.4±0ms         46.0±0ms     0.99  matrix_stuffing.SmallMatrixStuffing.time_compile_problem
      2.16±0s          2.13±0s     0.99  quantum_hilbert_matrix.QuantumHilbertMatrix.time_compile_problem
      1.16±0s          1.15±0s     0.99  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
      886±0ms          870±0ms     0.98  gini_portfolio.Cajas.time_compile_problem
      1.18±0s          1.16±0s     0.98  simple_QP_benchmarks.LeastSquares.time_compile_problem
      7.06±0s          6.93±0s     0.98  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem
      19.4±0s          19.1±0s     0.98  finance.CVaRBenchmark.time_compile_problem
      14.9±0s          14.6±0s     0.98  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
      1.94±0s          1.90±0s     0.98  tv_inpainting.TvInpainting.time_compile_problem
     14.8±0ms         14.4±0ms     0.98  simple_QP_benchmarks.ParametrizedQPBenchmark.time_compile_problem
      330±0ms          316±0ms     0.96  gini_portfolio.Murray.time_compile_problem
     23.6±0ms         22.1±0ms     0.94  high_dim_convex_plasticity.ConvexPlasticity.time_compile_problem
      3.31±0s          3.10±0s     0.94  simple_QP_benchmarks.UnconstrainedQP.time_compile_problem
      419±0ms          391±0ms     0.93  gini_portfolio.Yitzhaki.time_compile_problem

Copy link
Copy Markdown
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

@SteveDiamond SteveDiamond merged commit 903ae19 into master Jun 4, 2026
56 checks passed
@PTNobel PTNobel deleted the ptn/tweaks-default-settings branch June 5, 2026 00:15
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.

2 participants