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:
Run
sudo make uninstallin the same directory to uninstall, e.g., if you later decide to revert to the newest version.