GalacticOptim with AmplNLWriter optimizer


I’m trying to use GalacticOptim.jl with AmplNLWriter.jl optimizer but it’s not working.

using GalacticOptim, AmplNLWriter, Ipopt_jll

rosenbrock(x,p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2

x0 = zeros(2)

p = [1.0,100.0]

prob = OptimizationProblem(rosenbrock,x0,p)

optimizer = GalacticOptim.MOI.OptimizerWithAttributes(AmplNLWriter.Optimizer(Ipopt_jll.amplexe))

sol = solve(prob, optimizer)


Here I use Ipopt_jll just for example, but it’s not working even with it. Could you please help me to find an error?

Thank you

Can you open this as an issue on the repo?

Yes, sure

AmplNLWriter requires the expression graph, which galacticoptim probably doesn’t provide.

Why not just use Ipopt directly via ipopt.jl?

I used Ipopt here only as an example, to check whether it will work. But I’d like to use AmplNLWriter later with another local solver on my laptop.

1 Like

Use JuMP instead of galacticoptim

Thank you for this recommendation. JuMP is very good but I thought that GalacticOptim and ModelingToolkit will be easier to use with nonlinearities.

JuMP supports nonlinear:

We can just do it through MTK though

I remember MTK can find minima and maxima, but how is this combination for non-linear optimisation in general? I’m going to be taking an econ class, with a lot of optimisation of Cartesian planes.

It might be best to start a new post for this. It’s unrelated to the ExprGraph problem.

1 Like