建模语言的背景
数学规划问题在社会各领域均有广泛应用。例如电网中的能源调度与定价,航班与高铁的排班排程,共享出行的人车匹配,物流寄送的路径规划,供应链中的仓储调拨,搜索推荐的流量分发和内容推荐等。优化大规模数学规划问题一般都采用建立数学模型,然后将数学模型转化为代码的形式调用优化求解器的方式,所以数学建模是尤为关键的一部分。如何将实际问题建模,需要一种专门的语言,能够方便地表达和求解代数模型。
MAPL简介
MindOpt APL (MindOpt Algebraic Programming Language, MAPL) 是一种高效且通用的代数建模语言,由阿里达摩院研发,主要用于数学规划问题的建模,并支持调用多种求解器求解。它当前支持通用的线性、非线性、混合整数问题的建模。其语法贴近数学语言,与代数数学公式很接近,易学易写易读易维护。且MindOpt APL支持对接20+种优化求解器,可用一行命令就切换,大大提升了用户在优化问题求解环节的方案丰富度,降低风险和使用门槛。
支持的求解器
商用求解器
支持的商用求解器包含:
求解器 |
描述 |
MindOpt(自研) |
https://solver.damo.alibaba.com/,适合LP、MILP、Convex QP、SDP。 |
Knitro |
|
Gurobi |
|
CPLEX |
http://www.ibm.com/software/integration/optimization/cplex-optimizer/ |
IBM CPLEX CP Optimizer(ilogcp) |
http://www-01.ibm.com/software/commerce/optimization/cplex-cp-optimizer/ |
SCIP |
|
BARON |
https://minlp.com/baron-solver LP, NLP, MIP, and MINLP |
lgo |
https://tomopt.com/tomlab/products/lgo/ NLP, Global |
LINDO (lindoglobal) |
https://lindo.com/index.php/products/solver-suite LP, MIP, BAR, MIQP, NLP, MINLP |
LOQO |
https://vanderbei.princeton.edu/loqo/LOQO.html LP, QP, NLP |
MINOS |
http://www.sbsi-sol-optimize.com/asp/sol_products_minos_desc.htm LP, QP, NLP |
SNOPT |
http://www.sbsi-sol-optimize.com/asp/sol_product_snopt.htm NLP |
XPRESS |
https://www.solver.com/xpress-solver-engine LP, MIP, BAR, MIQP |
开源求解器
支持的开源求解器包含:
求解器 |
描述 |
适合问题 |
Ipopt |
来自COIN-OR, Eclipse Public License,可获取源码 https://github.com/coin-or/Ipopt |
Nonlinear optimization (NLP) |
Cbc |
来自COIN-OR, Eclipse Public License,可获取源码 https://github.com/coin-or/Cbc |
Mixed integer linear programming(MILP) |
Gecode |
https://www.gecode.org/,MIT license,可获取源码https://github.com/Gecode/gecode |
Constraint solver (约束规划) |
Bonmin |
来自COIN-OR, Eclipse Public License,可获取源码:https://github.com/coin-or/Bonmin |
Mixed-Integer Nonlinear Programming(MINLP) |
HiGHS |
https://highs.dev,MIT license,可获取源码https://github.com/ERGO-Code/HiGHS |
large-scale sparse linear programming (LP), mixed-integer programming (MIP), and quadratic programming (QP) |
Couenne |
https://www.coin-or.org/Couenne/,来自COIN-OR, Eclipse Public License,可获取源码https://www.coin-or.org/download/source/ |
Mixed-Integer Nonlinear Programming(MINLP) |
JaCoP |
GNU Affero General Public License,可获取源码:https://github.com/radsz/jacop |
Constraint Programming(约束规划) |
应用
一个简单的示例:
clear model; #清除模型,多次运行使用 # -----建模---- var xa >= 3; var xb >= 3; maximize reward: 100 * xa + 150 * xb; subject to cons: xa + xb = 8; # -----求解---- option solver mindopt; #(可选)选择求解器,默认就是MindOpt solve; option solver cbc; solve;
结果如下:
Running mindoptampl wantsol=1 MindOpt Version 1.0.1 (Build date: 20231114) Copyright (c) 2020-2023 Alibaba Cloud. Start license validation (current time : 01-DEC-2023 17:59:41). License validation terminated. Time : 0.005s Model summary. - Num. variables : 2 - Num. constraints : 1 - Num. nonzeros : 2 - Bound range : [3.0e+00,8.0e+00] - Objective range : [1.0e+02,1.5e+02] - Matrix range : [1.0e+00,1.0e+00] Presolver started. Model has been fully presolved. Presolver terminated. Time : 0.000s Simplex method started. Model fingerprint: ==wZ3d2dnd3Z Postsolver started. Simplex method terminated. Time : 0.001s OPTIMAL; objective 1050.00 0 simplex iterations Completed. Running cbc CBC 2.10.5Completed.