PyOptInterface icon indicating copy to clipboard operation
PyOptInterface copied to clipboard

Support for cuOpt

Open rlloretb opened this issue 7 months ago • 3 comments

Are there any plans to support Nvidia's cuOpt? PuLP had recently included it.

rlloretb avatar Jun 12 '25 22:06 rlloretb

There are no plans to add new solvers in the short term.

Meanwhile, according to https://discourse.julialang.org/t/need-help-wrapping-cuopt-in-julia/129808/5

Based on the current implementation and our discussion, I don’t really see the advantage compared to cu-pdlp or HiGHS with the support of it.

Using GPU support for LP implemented in COPT and HiGHS seems to be a better option now.

metab0t avatar Jun 13 '25 03:06 metab0t

Note that cuOpt also provides a hybrid CPU/GPU MILP solver. See the note here. Thus I think it would make for an interesting solver addition. CVXPY added support for it in their recent 1.7 release.

For a small example, I can now use the CUOPT solver backend to solve a MILP in CVXPY as such.

import cvxpy as cp

x = cp.Variable(3, integer=True)
y = cp.Variable(2)

objective = cp.Maximize(3*x[0] + 2*x[1] + x[2] + 4*y[0] + y[1])

constraints = [
    x[0] + x[1] + x[2] <= 10,
    2*x[0] + x[1] + 3*x[2] + y[0] <= 15,
    y[0] + y[1] <= 5,
    x >= 0,
    y >= 0,
    x <= 5,
    y[0] <= 3
]

problem = cp.Problem(objective, constraints)
problem.solve(solver=cp.CUOPT, time_limit=10, verbose=True)

print(f"Status: {problem.status}")
print(f"Optimal value: {problem.value:.2f}")
print(f"Integer variables x: {x.value}")
print(f"Continuous variables y: {y.value}")

This will give me solver chatter like this.

(CVXPY) Aug 04 08:47:32 PM: Invoking solver CUOPT  to obtain a solution.
Setting parameter log_to_console to true
Setting parameter time_limit to 1.000000e+01
Solving a problem with 12 constraints 5 variables (3 integers) and 18 nonzeros
Objective offset 0.000000 scaling_factor 1.000000
Free variable found! Make sure the correct bounds are given.
After trivial presolve updated 12 constraints 10 variables. Objective offset 0.000000
Running presolve!
Solving LP root relaxation
Scaling matrix. Maximum column norm 1.662036e+00
Dual Simplex Phase 1
 Iter     Objective           Num Inf.  Sum Inf.     Perturb  Time
    1 -5.7569932099778791e+00       7 2.19459220e+00 0.00e+00 0.00
Dual phase I complete. Iterations 5. Time 0.00
Dual feasible solution found.
Dual Simplex Phase 2
Found 3 singleton rows for steepest edge norms in 0.00s
 Iter     Objective           Num Inf.  Sum Inf.     Perturb  Time
    6 -3.9000000000000000e+01       1 4.29031474e-01 1.00e-07 0.00

Root relaxation solution found in 8 iterations and 0.00s
Root relaxation objective -3.45000000e+01

Strong branching on 1 fractional variables
| Explored | Unexplored | Objective   |    Bound    | Depth | Iter/Node |  Gap   |    Time 
        0        1                +inf  -3.450000e+01      1   0.0e+00       -        0.00
B       3        3       -3.400000e+01  -3.450000e+01      2   1.0e+00      1.5%      0.00
B&B added a solution to population, solution queue size 0 with objective -34
Generated fast solution in 0.133711 seconds with objective -31.000100
Consuming B&B solutions, solution queue size 1
Running recombiners on B&B solutions with size 1
    35000    34999       -3.400000e+01  -3.450000e+01   2518   1.1e-04      1.5%      1.04
    47000    46999       -3.400000e+01  -3.450000e+01   3268   8.5e-05      1.5%      2.12
    54000    53999       -3.400000e+01  -3.450000e+01   3706   7.4e-05      1.5%      3.30
    59000    58999       -3.400000e+01  -3.450000e+01   4018   6.8e-05      1.5%      4.58
    63000    62999       -3.400000e+01  -3.450000e+01   4268   6.3e-05      1.5%      5.77
    67000    66999       -3.400000e+01  -3.450000e+01   4513   6.0e-05      1.5%      7.09
    70000    69999       -3.400000e+01  -3.450000e+01   4689   5.7e-05      1.5%      8.11
    73000    72999       -3.400000e+01  -3.450000e+01   4866   5.5e-05      1.5%      9.27
    74569    74568       -3.400000e+01  -3.450000e+01   4958   5.4e-05      1.5%      9.91
Hit time limit. Stoppping
Explored 74569 nodes in 9.91s.
Absolute Gap 5.000000e-01 Objective -3.4000000000000000e+01 Lower Bound -3.4500000000000000e+01
Solution objective: -34.000000 , relative_mip_gap 0.014706 solution_bound -34.500000 presolve_time 0.020840 total_solve_time 10.002259 max constraint violation 0.000000 max int violation 0.000000 max var bounds violation 0.000000 nodes 74569 simplex_iterations 4
Termination reason:  FeasibleFound

The spikes in this image (CPU above, GPU below) show the hybrid solver using different compute resources on my machine.

Image

ryanjoneil avatar Aug 04 '25 20:08 ryanjoneil

Also, I realize you're not planning on supporting additional solvers, but if you would like to support cuOpt then perhaps a PR is in order.

ryanjoneil avatar Aug 04 '25 20:08 ryanjoneil