ipopt和ifopt笔记

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值