Ipopt安装指北
安装 Ipopt
$ wget https://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.7.zip
$ unzip Ipopt-3.12.7.zip
$ rm Ipopt-3.12.7.zip
$ cd Ipopt-3.12.7
$ ./configure
......
configure: Main configuration of Ipopt successful
$ make
$ make test
$ make install
参考:https://www.jianshu.com/p/4cdaa93d460b
参考:https://github.com/bapaden/ipopt-cmake-demo
下载 HSL MA21求解器 :
http://www.hsl.rl.ac.uk/ipopt/ https://github.com/casadi/casadi/wiki/Obtaining-HSL
没有学校邮箱的同学,可以选择下载个人版的。
为了避免后续问题,建议安装源码版本的。
#确保安装环境
$ sudo apt-get install libblas3 libblas-dev liblapack3 liblapack-dev gfortran
#方式2:源代码编译
$ tar -xf coinhsl-archive-2014.01.17.tar.gz
$ cd Ipopt-3.12.7/ThirdParty/HSL
$ ln -s ../../../coinhsl-archive-2014.01.17/ coinhsl
$ ./configure --enable-loadable-library
#出现
configure: Configuration of ThirdPartyHSL successful
$ make install
在$ make test 过程中出现问题:
# 出现错误:
Exception of type: OPTION_INVALID in file "IpAlgBuilder.cpp" at line 271:
Exception message: Selected linear solver MA27 not available.
Tried to obtain MA27 from shared library "libhsl.so", but the following error occured:
libhsl.so: cannot open shared object file: No such file or directory
# 解决:
# 将lib copy到根目录下:
$ cd Ipopt-3.12.7/ThirdParty/HSL/lib
$ ln -s libcoinhsl.so.1.5.6 libhsl.so
$ sudo cp -rd * /usr/local/lib
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
#$ env | grep LD #确认设置好环境变量
$ cd Ipopt-3.12.7/lib
$ sudo cp * /usr/local/lib/
回到IPOPT环境下进行编译
$ make test
$ make install
编译成功后,可以看到目录下有这几个文件夹”bin”, “lib” and “include”
有时候需要安装CppAd,安装方法:
sudo apt-get update -y
sudo apt-get install -y cppad
没有装CppAd可能会出现下面的问题:
example.cpp:1:33: fatal error: cppad/ipopt/solve.hpp: No such file or directory
出现问题:
/usr/include/cppad/ipopt/solve_callback.hpp:16:40: fatal error: coin/IpIpoptApplication.hpp: No such file or directory
解决办法:(参考:https://zhuanlan.zhihu.com/p/34650692)
$ sudo cp ~/Ipopt-3.12.7/include/* /usr/local/include
AMPL 的C++ API
方法:https://ampl.com/api/latest/cpp/getting-started.html
下载:https://ampl.com/products/api/
学习例子参考:
1)https://github.com/mez/model_predictive_controller_cpp
2)https://github.com/tianchenji/CarND-MPC-Project