Luca
December 6, 2022, 2:46pm
1
Dear all,
I want to solve a bunch of nonlinear optimization problems, whose nl. files are available. Hence I would like to charge the .nl files directly in Julia and solve the corresponding problem with a nonlinear solver like Ipopt. Do you know if there is a way to realize it?
Thanks very much. All your support is really appreciated!
tmigot
December 6, 2022, 3:02pm
2
Hi @Luca
You can use AmplNLReader.jl and NLPModelsIpopt.jl wrapper to Ipopt.
For instance:
using AmplNLReader, NLPModelsIpopt
hs33 = AmplModel("hs033.nl")
ipopt(hs33)
1 Like
Luca
December 6, 2022, 3:19pm
4
Thanks for the the quick answers! I would like to use also bonmin, couenne, and shot as solvers since there are integer variables in my model. Is it possible too? I check GitHub - jump-dev/AmplNLWriter.jl: Julia interface to AMPL-enabled solvers .
odow
December 6, 2022, 6:51pm
5
With JuMP, you’re after something like this:
using JuMP, AmplNLWriter, Bonmin_jll
model = read_from_file("file.nl")
set_optimizer(model, () -> AmplNLWriter.Optimizer(Bonmin_jll.amplexe))
optimize!(model)
2 Likes
Luca
December 8, 2022, 10:30am
6
Thanks for your answer. I tried the following code:
using JuMP, AmplNLWriter, SHOT_jll
model1 = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT_NL)
model = read_from_file(model1, "instance_15_3_1_0.nl")
set_optimizer(model, () -> AmplNLWriter.Optimizer(SHOT_jll.amplexe))
optimize!(model)
but I obtain the following error:
ERROR: LoadError: UndefVarError: FORMAT_NL not defined
odow
December 8, 2022, 6:16pm
7
Your code is not what I wrote?
FORMAT_NL not defined
This suggests you have an old version of MathOptInterface installed.
Try what I wrote, and if that doesn’t work, update your packages.
1 Like
Luca
December 13, 2022, 10:03am
8
I have update all Julia packages. I tried your code and it works! Thanks you so much!
1 Like