cuopt-numerical-optimization-api-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesecuOpt Numerical Optimization — CLI
cuOpt数值优化——CLI
Solve LP, MILP, and QP problems from MPS files via . The same command, options, and MPS workflow apply across all three; QP uses the standard MPS quadratic-objective extension.
cuopt_cliConfirm problem type and formulation (variables, objective, constraints, variable types) before coding.
This skill is CLI only (MPS input).
通过从MPS文件求解LP、MILP和QP问题。三者适用相同的命令、选项和MPS工作流程;QP使用标准MPS二次目标扩展。
cuopt_cli在编码前确认问题类型和公式(变量、目标函数、约束条件、变量类型)。
本技能仅支持CLI(MPS输入)。
Basic usage
基本用法
bash
undefinedbash
undefinedSolve LP or MILP from MPS file
从MPS文件求解LP或MILP
cuopt_cli problem.mps
cuopt_cli problem.mps
With options
使用选项
cuopt_cli problem.mps --time-limit 120 --mip-relative-tolerance 0.01
undefinedcuopt_cli problem.mps --time-limit 120 --mip-relative-tolerance 0.01
undefinedCommon options
常用选项
bash
cuopt_cli --helpbash
cuopt_cli --helpTime limit (seconds)
时间限制(秒)
cuopt_cli problem.mps --time-limit 120
cuopt_cli problem.mps --time-limit 120
MIP gap tolerance (stop when within X% of optimal)
MIP间隙容差(当与最优解相差X%以内时停止)
cuopt_cli problem.mps --mip-relative-tolerance 0.001
cuopt_cli problem.mps --mip-relative-tolerance 0.001
MIP absolute tolerance
MIP绝对容差
cuopt_cli problem.mps --mip-absolute-tolerance 0.0001
cuopt_cli problem.mps --mip-absolute-tolerance 0.0001
Presolve, iteration limit, method
预求解、迭代限制、方法
cuopt_cli problem.mps --presolve --iteration-limit 10000 --method 1
undefinedcuopt_cli problem.mps --presolve --iteration-limit 10000 --method 1
undefinedMPS format (required sections, in order)
MPS格式(必填部分,按顺序)
- NAME — problem name
- ROWS — N (objective), L/G/E (constraints)
- COLUMNS — variable names, row names, coefficients
- RHS — right-hand side values
- BOUNDS (optional) — LO, UP, FX, BV, LI, UI
- ENDATA
Integer variables: use before and after the integer columns.
'MARKER' 'INTORG''MARKER' 'INTEND'- NAME — 问题名称
- ROWS — N(目标函数)、L/G/E(约束条件)
- COLUMNS — 变量名、行名、系数
- RHS — 右侧值
- BOUNDS(可选)—— LO、UP、FX、BV、LI、UI
- ENDATA
整数变量:在整数列之前使用,之后使用。
'MARKER' 'INTORG''MARKER' 'INTEND'QP via CLI (beta)
基于CLI的QP(测试版)
Quadratic objectives extend the standard MPS workflow — same command, same options. Check for QP-specific flags and the repo docs at for the quadratic-objective MPS format.
cuopt_clicuopt_cli --helpdocs/cuopt/source/cuopt-cli/QP rules:
- MINIMIZE only. For maximization, negate the objective coefficients (and Q entries) in the MPS file.
- Continuous variables only — do not mix integer markers with quadratic objectives.
二次目标扩展了标准MPS工作流程——使用相同的命令和选项。查看获取QP特定标志,以及仓库文档了解二次目标的MPS格式。
cuopt_clicuopt_cli --helpdocs/cuopt/source/cuopt-cli/QP规则:
- 仅支持最小化。若要最大化,请在MPS文件中取反目标系数(以及Q项)。
- 仅支持连续变量——不要将整数标记与二次目标混合使用。
Troubleshooting
故障排除
- Failed to parse MPS — Check ENDATA, section order (NAME, ROWS, COLUMNS, RHS, [BOUNDS], ENDATA), integer markers.
- Infeasible — Check constraint directions (L/G/E) and RHS values.
- 解析MPS失败——检查ENDATA、部分顺序(NAME、ROWS、COLUMNS、RHS、[BOUNDS]、ENDATA)、整数标记。
- 不可行——检查约束方向(L/G/E)和RHS值。
Examples
示例
- assets/README.md — Build/run for sample MPS files
- lp_simple — Minimal LP (PROD_X, PROD_Y, two constraints)
- lp_production — Production planning: chairs + tables, wood/labor
- milp_facility — Facility location with binary open/close
- assets/README.md — 构建/运行示例MPS文件
- lp_simple — 最简LP问题(PROD_X、PROD_Y,两个约束)
- lp_production — 生产规划:椅子+桌子,木材/劳动力约束
- milp_facility — 带二进制开闭选项的设施选址
Getting the CLI
获取CLI
CLI is included with the Python package (). Install via pip or conda; then run to verify.
cuoptcuopt_cli --helpCLI包含在Python包中。通过pip或conda安装;然后运行验证安装。
cuoptcuopt_cli --help