简体   繁体   中英

How to use a older version of NLopt in R

I am trying to replicate a code that uses the nloptr function. The only difference is that I am using another version:

As you can see here in my output I am using version 2.7.1

> # optimization result
> opt_result

Call:
nloptr(x0 = theta_init, eval_f = obj, eval_grad_f = grad, lb = lb,     ub = ub, opts = opts)


Minimization using NLopt version 2.7.1 

NLopt solver status: 4 ( NLOPT_XTOL_REACHED: Optimization stopped because xtol_rel or xtol_abs 
(above) was reached. )

Number of Iterations....: 15 
Termination conditions:  xtol_rel: 0.001    maxeval: 10000 
Number of inequality constraints:  0 
Number of equality constraints:    0 
Optimal value of objective function:  121997.975378908 
Optimal value of controls: 10.04425 52.50066 1 0.218371

However, in the original code they are using the 2.4.2 version of NLopt

在此处输入图像描述

Is there a way I can use the 2.4.2 version now? Because I want to have the exact same values (the code is the same, I just copied and pasted it).

Thanks in advance!

Old versions of the NLopt sources are available at the NLopt GitHub page, under releases , starting with version 2.4.2. You can install on the command line in the usual way:

$ curl -LO https://github.com/stevengj/nlopt/archive/refs/tags/nlopt-2.4.2.tar.gz
$ tar -xvf nlopt-2.4.2.tar.gz
$ cd nlopt-2.4.2
$ ./configure
$ make
$ sudo make install

Run sudo make uninstall in the same directory to uninstall, eg, if you later decide to revert to the newest version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM