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

オープン 初心者向け
#195 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 16 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
90/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

benchmark_apis/cuopt_json_to_cvxpy.py の -s/--solver の処理から始めてください。CUOPT の分岐は要求された solver を渡しますが、もう一方の分岐は prob.solve を solver= 引数なしで呼び出します。その非 CUOPT の呼び出しに要求された solver を追加し、その後、-s SCIPY、-s OSQP、-s SCS で issue のループを再実行し、それぞれについてログが一致する Invoking solver ... の行を出力することを確認してください。完了とは、CUOPT だけでなく、名前付きの各 solver に対して要求された solver が実際に使用されることを意味します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Jupyter Notebook
スター
473
フォーク
90
平均マージ
14日 10時間
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/cuopt-examples のほかの issue

NVIDIA/cuopt-examples の issue をすべて見る

似ている issue

CLI の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。