Ipopt 被设计为灵活适用于各种应用程序,并且有多种方式与 Ipopt 接口,允许特定的数据结构和线性求解器技术。尽管如此,已经包含了一个标准表示,应该满足大多数用户。
这个教程将讨论MALTAB中AMPL调用Ipopt去解NLP问题。
AMPL 是一种建模语言工具,它允许用户以类似于数学方式编写问题的语法编写优化问题。一旦在 AMPL 中制定了问题,就可以使用(已编译的)Ipopt AMPL 求解器可执行文件 ipopt 轻松解决问题。通过直接链接代码来连接您的问题需要花费点时间来编写,但对于大型问题可能更有效。
接下来使用例子来测试:

开始点:

最优解:

matlab 中通过AMPL使用Ipopt
# tell ampl to use the ipopt executable as a solver
# make sure ipopt is in the path!
option solver ipopt;
# declare the variables and their bounds,
# set notation could be used, but this is straightforward
var x1 >= 1, <= 5;
var x2 >= 1, <= 5;
var x3 >= 1, <= 5;
var x4 >= 1, <= 5;
# specify the objective function
minimize obj:
x1 * x4 * (x1 + x2 + x3) + x3;
# specify the constraints
s.t.
inequality:
x1 * x2 * x3 * x4 >= 25;
equality:
x1^2 + x2^2 + x3^2 +x4^2 = 40;
# specify the starting point
let x1 := 1;
let x2 := 5;
let x3 := 5;
let x4 := 1;
# solve the pr

该教程介绍了如何在MATLAB环境中通过AMPL接口使用Ipopt求解非线性规划(NLP)问题。首先,解释了Ipopt的灵活性和适用性,然后展示了如何在AMPL中定义变量、目标函数和约束条件。接着,提供了一个具体的NLP问题实例,包括初始点设定和问题求解。最后,展示了运行结果,包括迭代过程和解的详细信息。
最低0.47元/天 解锁文章

6107

被折叠的 条评论
为什么被折叠?



