Ipopt with Metis编译指南

按照该步骤一步一步执行,即可完成安装

安装基本依赖

$ apt-get install libblas-dev liblapack-dev gfortran

下载安装工具coinbrew

$ wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
or
$ git clone git@github.com:coin-or/coinbrew.git
$ cd coinbrew
$ sudo chmod u+x coinbrew # 给可执行权限

下载ipopt

$ ./coinbrew --ssh fetch Ipopt

接下来出现如下界面:

You haven't specified a project version
It appears that the last 10 releases of Ipopt are
3.14.9
3.14.8
3.14.7
3.14.6
3.14.5
3.14.4
3.14.3
3.14.2
3.14.1
3.14.0
Do you want to work with the latest release? (y/n)
=> 

这里需要我们选择一个版本来安装,或者直接输入y,回车。

接下来,coinbrew会克隆github里面的ipopt第三方库和源码,包含:

  • 在当前目录下建立一个ThirdParty文件夹。
  • 克隆asl源码存放在ThirdParty/ASL里面(其实非必须)。
  • 克隆mumps源码存放在ThirdParty/Mumps里面。
  • 克隆hsl源码存放在ThirdParty/HSL里面(注意这里没有源码,需要后面自行从官网下载源码)。
  • 当前目录新建Ipopt文件夹,然后克隆ipopt源码存放在该目录下。

Metis库作为可选项并不是必须的,用于加速线性求解器HSL/Mumps的矩阵排序,可提高性能。

Download, build, and install dependencies
The linear solvers MA57, HSL_MA77, HSL_MA86, HSL_MA97 can make use of the matrix ordering algorithms implemented in METIS.
MUMPS will perform better if the matrix ordering algorithms implemented in METIS are available on the system.

下面安装Metis库:

$ cd ThirdParty
$ git clone git@git.zhlh6.cn:coin-or-tools/ThirdParty-Metis.git Metis
$ mkdir build && cd build
$ ../configure --prefix=${your_path}/coinbrew/install/
$ make -j8
$ make install

将从HSL官网获取的coinhsl-2021.05.05.tar.gz解压到ThirdParty/HSL/目录下,并重命名文件夹coinhsl-2021.05.05/为coinhsl/

下面回到coinbrew所在路径,编译Ipopt及其他第三方依赖:

$ ./coinbrew --ssh --skip-update build Ipopt -j 8 --prefix=${your_path}/coinbrew/install/ \
--with-metis-lflags='-L${your_path}/coinbrew/install/lib/ -lcoinmetis -lm' \
--with-metis-cflags=-I${your_path}/coinbrew/install/include/coin-or/metis/

第一次执行编译会在mumps编译完后报Error: Build failed, see error output above的错误,没关系,再执行一遍上面的命令继续编译,会出现如下界面:

You are trying to run the build again and have specified
configuration options on the command line.

Please choose one of the following options.
 The indicated action will be performed for you AUTOMATICALLY
1. Run the build again with the previously specified options.
   This can also be accomplished invoking the build
   command without any arguments.
2. Configure in a new build directory (whose name you will be
   prmpted to specify) with new options.
3. Re-configure in the same build directory with the new
   options. This option is not recommended unless you know
   what you're doing!.
4. Quit

Please type 1, 2, 3, or 4
=> 

输入1接着编译,即可完成链接了metis库的ipopt库了。

进一步可以检测一下install/include/coin/hsl/CoinHslConfig.h文件中Metis是否被包含,有如下一行说明已经包含:

/* Define to 1 if METIS is available */
#define COINHSL_HAS_METIS 1

将install目录下的文件夹拷贝到自己的工程目录下,就可以用ipopt以及有关依赖库了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值