Skip to content

Conversation

@Transurgeon
Copy link
Member

This PR adds the Uno interface to DNLP.
CC. @cvanaret could you double check that our implementation makes sense? (I have mostly used claude code for it so there might be things that are not done well). The good news is that almost all tests pass directly using uno's SQP (except one which converges to a sub-optimal point.. uno's IPM is used instead for that test).

BTW, I also tried to install uno directly through pip (by running pip install unopy). But I seemed to be getting errors that a linear solver was not available when importing unopy after that. I can try to replicate the error if needed.. just wanted to let you know for now.

@dance858
Copy link
Collaborator

I think this looks very reasonable.

On my ubuntu laptop, I can do pip install unopy and run https://github.com/cvanaret/Uno/blob/main/interfaces/Python/example/example_hs015.py, so I don't encounter the same build issuze as you @Transurgeon

@cvanaret
Copy link

cvanaret commented Dec 18, 2025

Hi @Transurgeon,
I'll have a look at the interface. I'm also curious to see what happens on the one instance for which Uno's SQP method doesn't find the optimum.

I have added some more Python wheels a couple of days ago, can you try again to install unopy? Unless you have Windows, in which case unopy is built from the sources. Happy to look at the log :)

@github-actions
Copy link

github-actions bot commented Dec 24, 2025

Benchmarks that have stayed the same:

   before           after         ratio
 [496bbf35]       [dd6f4269]
      924±0ms          944±0ms     1.02  simple_LP_benchmarks.SimpleScalarParametrizedLPBenchmark.time_compile_problem
      256±0ms          261±0ms     1.02  simple_QP_benchmarks.SimpleQPBenchmark.time_compile_problem
      5.07±0s          5.17±0s     1.02  svm_l1_regularization.SVMWithL1Regularization.time_compile_problem
      1.66±0s          1.69±0s     1.02  tv_inpainting.TvInpainting.time_compile_problem
      292±0ms          297±0ms     1.01  slow_pruning_1668_benchmark.SlowPruningBenchmark.time_compile_problem
      4.94±0s          5.01±0s     1.01  optimal_advertising.OptimalAdvertising.time_compile_problem
      11.4±0s          11.5±0s     1.01  simple_LP_benchmarks.SimpleLPBenchmark.time_compile_problem
      4.55±0s          4.59±0s     1.01  huber_regression.HuberRegression.time_compile_problem
      673±0ms          677±0ms     1.01  matrix_stuffing.ConeMatrixStuffingBench.time_compile_problem
      1.07±0s          1.08±0s     1.01  finance.FactorCovarianceModel.time_compile_problem
      335±0ms          337±0ms     1.01  gini_portfolio.Yitzhaki.time_compile_problem
      22.3±0s          22.4±0s     1.01  sdp_segfault_1132_benchmark.SDPSegfault1132Benchmark.time_compile_problem
     38.8±0ms         39.0±0ms     1.01  matrix_stuffing.SmallMatrixStuffing.time_compile_problem
      2.83±0s          2.83±0s     1.00  quantum_hilbert_matrix.QuantumHilbertMatrix.time_compile_problem
      167±0ms          167±0ms     1.00  high_dim_convex_plasticity.ConvexPlasticity.time_compile_problem
      1.86±0s          1.87±0s     1.00  simple_QP_benchmarks.UnconstrainedQP.time_compile_problem
      281±0ms          281±0ms     1.00  matrix_stuffing.ParamSmallMatrixStuffing.time_compile_problem
      1.37±0s          1.37±0s     1.00  matrix_stuffing.ParamConeMatrixStuffing.time_compile_problem
     14.5±0ms         14.5±0ms     1.00  simple_LP_benchmarks.SimpleFullyParametrizedLPBenchmark.time_compile_problem
      532±0ms          531±0ms     1.00  semidefinite_programming.SemidefiniteProgramming.time_compile_problem
      1.11±0s          1.10±0s     1.00  gini_portfolio.Cajas.time_compile_problem
     14.5±0ms         14.4±0ms     1.00  simple_QP_benchmarks.ParametrizedQPBenchmark.time_compile_problem
      232±0ms          231±0ms     0.99  gini_portfolio.Murray.time_compile_problem
      13.0±0s          12.9±0s     0.99  finance.CVaRBenchmark.time_compile_problem
      850±0ms          828±0ms     0.97  simple_QP_benchmarks.LeastSquares.time_compile_problem

@Transurgeon
Copy link
Member Author

Hi @Transurgeon, I'll have a look at the interface. I'm also curious to see what happens on the one instance for which Uno's SQP method doesn't find the optimum.

Sorry for the late reply. The example which fails for SQP is as follows (written in cvxpy syntax):

  def test_qcp(self, solver):
      # Use IPM for UNO on this test, SQP converges to a suboptimal point: (0, 0, 1)
      if solver == 'UNO':
          solver = 'UNO_IPM'
      x = cp.Variable(1)
      y = cp.Variable(1, bounds=[0, np.inf])
      z = cp.Variable(1, bounds=[0, np.inf])

      objective = cp.Maximize(x)

      constraints = [
          x + y + z == 1,
          x**2 + y**2 - z**2 <= 0,
          x**2 - cp.multiply(y, z) <= 0
      ]
      problem = cp.Problem(objective, constraints)
      problem.solve(solver=solver, nlp=True)
      assert problem.status == cp.OPTIMAL
      assert np.allclose(x.value, np.array([0.32699284]))
      assert np.allclose(y.value, np.array([0.25706586]))
      assert np.allclose(z.value, np.array([0.4159413]))

it was found from the JuMP examples.
Please let us know about the interface.. if it looks good we can merge it!

I have added some more Python wheels a couple of days ago, can you try again to install unopy? Unless you have Windows, in which case unopy is built from the sources. Happy to look at the log :)

Thanks for doing this! It seems to work. uno is now running in our CI successfully. We removed the windows tests since they were also causing some problems on cvxpy master.

@Transurgeon
Copy link
Member Author

@dance858 the failing tests in test_nlp_solvers have been fixed by @PTNobel in #120. We should review it and merge before following up on this PR.

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.

4 participants