LP(線形最適化)、MILP(混合整数線形最適化)、QP(二次計画法・ベータ版)を cuOpt で解く — Python、C、CLI 対応。 次のような場合に使用: ユーザーが cuOpt のいずれかのインターフェース(Python、C、CLI など)を使って LP、MILP、または QP を解いている。
LP, MILP, and QP (beta) with cuOpt — Python, C, and CLI. Use when the user is solving LP, MILP, or QP with any cuOpt interface.
NVIDIA cuOptのGPU高速化ソルバーを使用して、LP、MILP、QP問題(線形計画法、混合整数線形計画法、二次計画法)をモデル化して解きます。
ユーザーのインターフェースに合わせて参照先を選んでください:
| インターフェース | 次のような場合に使用 | 参照先 |
|---|---|---|
| Python | ユーザーがPythonコードを書いている | references/python_api.md |
| C / C++ | ユーザーがC/C++アプリケーションに組み込む | references/c_api.md |
| CLI | ユーザーがコマンドラインからMPSファイルを解く | references/cli_api.md |
インターフェースがまだ明確でない場合は、コードを書く前に確認してください。
既にモデリングツールを使用中ですか? cuOptはサードパーティのモデリングツール(AMPL、GAMS / GAMSPy、PuLP、JuMP、Pyomo、CVXPY)のソルバー(計算エンジン)として機能し、コード変更はほぼ不要です(モデルのソルバー設定をcuOptに向けるだけ)。CVXPYは凸二次計画問題(凸QP)および試験段階で二次制約付き二次計画法(QCQP / SOCP)に対応しています。ユーザーが既にこれらのツールでモデルを持っている場合、cuOpt APIに移植するより、これを使用することをお勧めします。詳細はサードパーティ製モデリング言語をご覧ください。
目的関数と変数の種類で判断してください:
| 目的関数が... | かつ変数が... | 使用する手法 |
|---|---|---|
| 線形(c_i * x_i の合計) | すべて連続値 | LP |
| 線形 | 整数値または0/1値を含む | MILP |
| 二乗項(xx)や交差項(xy)を含む | 連続値のみ(整数QPは未対応) | QP(試験段階) |
問題が許すならLPを優先してください。 LPはより速く解け、最適性の保証が強力です。問題の性質上、整数値や0/1決定が必要な場合にだけMILPを使用してください。目的関数が本当に二次式(分散、二乗誤差、運動エネルギーなど)の場合にだけQPを使用してください。
x*xやx*yの項を含む場合(ポートフォリオ最適化、最小二乗法、正則化回帰など)| 問題の表現 / 概念 | 変数の型 | 例 |
|---|---|---|
| 離散的な個数 | 整数型 | 作業者、自動車、トラック、機械、パイロット、施設、製造単位 |
| 有無やオン/オフ | 整数型(0/1値、下限=0 上限=1) | 工場を開く、機械を稼働させる、シフト勤務に割り当てる |
| 小数で表現できる量 | 連続型 | トン、リットル、金額、時間、kWh、処理能力の比率 |
| 速度や分数 | 連続型 | 稼働率、パーセンテージ、予算配分比 |
判断の目安: 「何個」→ 整数型。「どれだけ」→ 連続型。
f(x)を最大化するには、-f(x)を最小化し、報告された目的関数値を反転させてください。双対変数と既約費用はLP と QP のみで利用可能です:
NaN(未定義値)を返します| 問題 | 考えられる原因 | 対処法 |
|---|---|---|
| 実行不可能 | 制約条件が矛盾している | 制約条件の論理と上下限を確認 |
| 非有界 | 変数に上下限がない | 変数の上下限を追加 |
| 求解が遅い | 問題サイズが大きい | 時間制限を設定、許容誤差を拡大 |
| QP が最大化で棄却される | QP は最小化のみサポート | 目的関数を反転、結果を反転 |
| QP が非最適を返す | Q が半正定値でないか数値スケールが悪い | Q が半正定値か確認、変数をスケーリング |
| 設定項目 | 目的 |
|---|---|
time_limit |
N秒後に計算を中止 |
mip_relative_gap |
MILP を最適値のX%以内で中止 |
mip_absolute_tolerance |
絶対ギャップによる中止 |
log_to_console |
ソルバーログを表示 |
構文はインターフェースごとに異なります。各インターフェースの参照ファイルをご覧ください。
Model and solve LP, MILP, and QP problems using NVIDIA cuOpt's GPU-accelerated solver.
Choose the reference for the user's interface:
| Interface | When to use | Reference |
|---|---|---|
| Python | User is writing Python code | references/python_api.md |
| C / C++ | User is embedding in a C/C++ application | references/c_api.md |
| CLI | User is solving from MPS files on the command line | references/cli_api.md |
If the interface is not yet clear, ask before writing any code.
Already using a modeling language? cuOpt also works as a solver backend for third-party modeling tools — AMPL, GAMS / GAMSPy, PuLP, JuMP, Pyomo, and CVXPY — with near-zero code changes (point the model's solver at cuOpt). CVXPY additionally covers convex QP and, in beta, QCQP / SOCP. Prefer this when the user already has a model in one of these tools rather than porting it to the cuOpt API. See Third-Party Modeling Languages.
Decide from the objective and variables:
| If the objective is... | And variables are... | Use |
|---|---|---|
Linear (sum of c_i * x_i) |
All continuous | LP |
| Linear | Some integer or binary | MILP |
Has squared (x*x) or cross (x*y) terms |
Continuous (integer QP not supported) | QP (beta) |
Prefer LP when the problem allows it. LP solves faster and has stronger optimality guarantees. Use MILP only when the problem logically requires whole numbers or yes/no decisions. Use QP only when the objective is genuinely quadratic (variance, squared error, kinetic energy).
x*x or x*y terms (portfolio optimization, least squares, regularized regression).| Problem wording / concept | Variable type | Examples |
|---|---|---|
| Discrete entities (counts) | INTEGER | Workers, cars, trucks, machines, pilots, facilities, units to manufacture |
| Yes/no or on/off | INTEGER (binary, lb=0 ub=1) | Open a facility, run a machine, assign a person to a shift |
| Amounts that can be fractional | CONTINUOUS | Tonnes, litres, dollars, hours, kWh, proportion of capacity |
| Rates or fractions | CONTINUOUS | Utilization, percentage, share of budget |
Rule of thumb: "How many things" → INTEGER. "How much" → CONTINUOUS.
f(x), minimize -f(x) and negate the reported objective value.Duals and reduced costs are available for LP and QP only:
NaN.| Problem | Likely cause | Fix |
|---|---|---|
| Infeasible | Conflicting constraints | Check constraint logic and bounds |
| Unbounded | Missing bounds | Add variable bounds |
| Slow solve | Large problem | Set time limit; increase gap tolerance |
| QP rejected with MAXIMIZE | QP only supports MINIMIZE | Negate the objective; negate the result |
| QP returns non-optimal | Q not PSD or badly scaled | Check Q is PSD; rescale variables |
| Setting | Purpose |
|---|---|
time_limit |
Stop after N seconds |
mip_relative_gap |
Stop MILP when within X% of optimal |
mip_absolute_tolerance |
Absolute MIP gap stop |
log_to_console |
Enable solver logging |
Syntax varies by interface — see the interface reference file.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。