1 Introduction
先看IPOPT的官方说明[1]
Ipopt (Interior Point Optimizer, pronounced “Eye-Pea-Opt”) is an open source software package for large-scale nonlinear optimization. It can be used to solve general nonlinear programming problems of the form
2 Installation
2.1 安装IPOPT
通过coinbrew安装更加方便一些,非常关键的一步是把HSL的source code/coinhsl-archive-X.Y 复制到ThirdParty
# step1:建一个文件夹,准备开始编译
mkdir coinbrewfolder
cd coinbrewfolder
# step2:下载coinbrew脚本文件,通过wget或者去对应网址上另存:
wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
chmod u+x coinbrew
# step3: 下载相关的文件
./coinbrew fetch Ipopt --no-prompt
# step4: 将HSL source code 复制到/coinbrewfolder/ThirdParty/HSL
# step4.1: 在https://www.hsl.rl.ac.uk/ipopt/下载coinhsl-archive-X.Y.tar.gz
# step4.2:
tar xzvf coinhsl-archive-X.Y.tar.gz
mv ThirdParty/HSL/coinhsl xx/coinhsl-archive-X.Y
# step5: 编译和安装IPOPT到/usr/local
sudo ./coinbrew build Ipopt --prefix=/usr/local --test --no-prompt --verbosity=3
sudo ./coinbrew install Ipopt --no-prompt
2.2 安装ifopt
根据[4],安装ifopt。
# step1: 安装ifopt
sudo apt-get install ros-<distro>-ifopt
# step2: 在catkin_ws/src下载source code,并进行编译
cd catkin_ws/src
git clone https://github.com/ethz-adrl/ifopt.git
catkin build ifopt
# step3: 进行test
cd catkin_ws/build/ifopt # catkin build
make test
如果IPOPT安装成功的话,make test会提示passed.
2.3 在ROS上使用ifopt的库
调用在ros上调用ifopt还是很方便的,按照[4]的说明,在CMakeLists.txt上修改成
add_compile_options(-std=c++11)
find_package(catkin COMPONENTS ifopt)
include_directories(${catkin_INCLUDE_DIRS})
target_link_libraries(foo ${catkin_LIBRARIES})
在package.xml上加上
<depend>ifopt</depend>
在程序中通过实例化VariableSet、ConstraintSet、CostTerm分别设置变量、constraitns和objective,只要按照ifopt_ipopt/test/ex_test_ipopt.cc文件进行设置就没啥问题。
和matlab fmincon 计算的结果也是一致的。
References
[1] https://coin-or.github.io/Ipopt/
[2] https://github.com/coin-or/Ipopt
[3] https://coin-or.github.io/coinbrew/
[4] https://github.com/ethz-adrl/ifopt
[5] https://coin-or.github.io/Ipopt/index.html