APMonitor.com 是用于求解大型非线性方程组(超过 100 万)的免费网络服务。有一个浏览器界面和一个 Python / MATLAB API。Python 的 API 是一个脚本 (apm.py),可从 apmonitor.com 主页下载。一旦脚本被加载到 Python 代码中,它就可以解决以下问题:
- 非线性方程
- 微分和代数方程
- 最小二乘模型拟合
- 移动水平估计
- 非线性模型预测控制
- 等等
对于新用户,APM Python 软件有一个 Google Groups 论坛,用户可以在其中发布问题。每两周举行一次网络研讨会,展示运筹学和工程中的优化问题。
下面是一个优化问题的示例 (hs71.apm)。
Model
Variables
x[1] = 1, >=1, <=5
x[2] = 5, >=1, <=5
x[3] = 5, >=1, <=5
x[4] = 1, >=1, <=5
End Variables
Equations
x[1] * x[2] * x[3] * x[4] > 25
x[1]^2 + x[2]^2 + x[3]^2 + x[4]^2 = 40
minimize x[1] * x[4] * (x[1]+x[2]+x[3]) + x[3]
End Equations
End Model
使用以下 Python 脚本解决了优化问题:
# Import
from apm import *
# Select server
server = 'http://xps.apmonitor.com'
# Application name
app = 'eqn'
# Clear previous application
apm(server,app,'clear all')
# Load model file
apm_load(server,app,'hs71.apm')
# Option to select solver (1=APOPT, 2=BPOPT, 3=IPOPT)
apm_option(server,app,'nlc.solver',3)
# Solve on APM server
solver_output = apm(server,app,'solve')
# Display solver output
print solver_output
# Retrieve results
results = apm_sol(server,app)
# Display results
print '--- Results of the Optimization Problem ---'
print results
# Display Results in Web Viewer
url = apm_var(server,app)
print "Opened Web Viewer: " + url