[BUG]: cuopt_json_to_cvxpy.py ignores --solver unless it is CUOPT

Open Beginner friendly
#195 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 16 days

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start in benchmark_apis/cuopt_json_to_cvxpy.py at the -s/--solver handling; the CUOPT branch passes the requested solver, while the other branch calls prob.solve without a solver= argument. Add the requested solver to that non-CUOPT call, then rerun the issue's loop with -s SCIPY, -s OSQP, and -s SCS and confirm the log prints the matching Invoking solver ... line for each. Done means the requested solver is actually used for every named solver, not just CUOPT.

Written by the indexing model from the issue text.

Description

Version

cuopt-examples main (8c00164); cvxpy 1.7.5

Which installation method(s) does this occur on?

Pip

Describe the bug.

benchmark_apis/cuopt_json_to_cvxpy.py has a -s/--solver option ("solver to use (default: CUOPT)"), but the value is only used when it is CUOPT. For any other solver the script calls

result = prob.solve(verbose=verbose,
                    solver_verbose=verbose or solver_verbose)

with no solver= argument, so CVXPY falls back to its own default solver. -s SCIPY, -s OSQP, -s SCS all end up running CLARABEL here, and the printed objective and timing belong to that solver, not the one requested.

Expected: -s NAME runs the problem with solver NAME, as it already does for CUOPT.

Minimum reproducible example
cat > lp.json <<'JSON'
{"csr_constraint_matrix":{"offsets":[0,2,4],"indices":[0,1,0,1],"values":[1.0,1.0,1.0,3.0]},
 "constraint_bounds":{"lower_bounds":["ninf","ninf"],"upper_bounds":[4.0,6.0]},
 "objective_data":{"coefficients":[3.0,5.0],"scaling_factor":1.0,"offset":0.0},
 "variable_bounds":{"lower_bounds":[0.0,0.0],"upper_bounds":["inf","inf"]},
 "maximize":true,"variable_types":["C","C"]}
JSON
pip install cvxpy
for s in SCIPY OSQP SCS; do
  python cuopt_json_to_cvxpy.py -s $s --verbose lp.json 2>&1 | grep "Invoking solver"
done
Relevant log output
(CVXPY) ...: Invoking solver CLARABEL  to obtain a solution.
(CVXPY) ...: Invoking solver CLARABEL  to obtain a solution.
(CVXPY) ...: Invoking solver CLARABEL  to obtain a solution.
Environment details
macOS, CPU only, Python 3.9, cvxpy 1.7.5 (installed solvers: CLARABEL, OSQP, SCIPY, SCS)
Other/Misc.

Passing solver=solver in the non-CUOPT branch fixes it; with that change the same loop prints Invoking solver SCIPY, OSQP and SCS. I can open a PR.

Dominant language
Jupyter Notebook
Stars
473
Forks
90
Avg merge
14d 10h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/cuopt-examples

All issues in NVIDIA/cuopt-examples

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.