I was using AmplNLWriter with Ipopt_jll, but it stopped working when I installed MadNLP. I have removed all my packages and reinstalled (excluding MaNLP), but I have not been able to make AmplNLWriter to work. The error message suggests that the solver has not found a solution, but that is incorrect as I cannot see it showing any iterations or progress from the solver’s log. It seems like it is not passing the problem to the solver.
The same code works fine when I use Ipopt with JuMP directly (i.e., without AmplNLWriter) but it is incredibly slow. For a moderate size problem, JuMP is not able to generate the model even when left for few hours, i.e., it does not progresses to the stage of solving. When using the solver via the AmplNLWriter, it was at least able to solve the problem. The issue seems to be with AmplNLWriter rather than the solver (as I have tried quite a few of them).
Could anyone please help with this? I have given a MWE and error message below.
Result index of attribute MathOptInterface.VariablePrimal(1) out of bounds. There are currently 0 solution(s) in the model.
in eval at base\boot.jl:360
in top-level scope at untitled:30
in nlp_model at untitled:19
in value at JuMP\klrjG\src\variables.jl:943
in var"#value#30" at JuMP\klrjG\src\variables.jl:943
in get at JuMP\klrjG\src\JuMP.jl:1232
in _moi_get_result at JuMP\klrjG\src\JuMP.jl:1199
in get at MathOptInterface\YDdD3\src\Utilities\cachingoptimizer.jl:757
in get at MathOptInterface\YDdD3\src\Bridges\bridge_optimizer.jl:1039
in get at MathOptInterface\YDdD3\src\Utilities\cachingoptimizer.jl:757
in get at AmplNLWriter\7riG9\src\AmplNLWriter.jl:1176
in check_result_index_bounds at MathOptInterface\YDdD3\src\attributes.jl:139
using Ipopt, JuMP, AmplNLWriter, Ipopt_jll
function nlp_model(p, c1, c2,b, k, n)
#model = Model(Ipopt.Optimizer)
model = Model(() -> AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
@variable(model, 0 <= x[i = 1:n] <= 1)
@variable(model, 0<=var1<=1)
@variable(model, 0<=var2<=1)
@variable(model, 0<=var3<=1)
@objective(model,Max,var1-var2+var3)
@NLconstraint(model,con3,sum(x[i]*p[i] for i in 1:n)-sum(b[j]/(1+var1)^j for j in 1:k) == 0)
@NLconstraint(model,con5,sum(x[i]*p[i] for i in 1:n)-sum(c1[j,i] *x[i] / (1+var2)^j for i in 1:n, j in 1:k) == 0)
@NLconstraint(model,con6,sum(x[i]*p[i] for i in 1:n)-sum(c2[j,i] *x[i] / (1+var3)^j for i in 1:n, j in 1:k) == 0)
@constraint(model, con1, c1*x .>= b)
JuMP.optimize!(model)
println("")
println("variable l = $(value(var1)) , variable 2 = $(value(var2)) , variable 3 = $(value(var3))")
end
function data()
p = rand(400:700,5,1); c1= (rand(100:200,4,5))'; c2 = 0.9 .* c1
b =rand(150:250,5,1); n= size(c1,2); k = size(c1,1)
return p, c1, c2, b, n, k
end
p, c1, c2, b, n, k = data()
nlp_model(p, c1, c2,b, k, n)
Package versions
[7c4d4715] AmplNLWriter v0.7.2
[c52e3926] Atom v0.12.35
[336ed68f] CSV v0.9.10
[9961bab8] Cbc v0.8.1
[e2554f3b] Clp v0.8.4
[a93c6f00] DataFrames v1.2.2
[b6b21f68] Ipopt v0.7.0
[4076af6c] JuMP v0.21.10
[e5e0dc1b] Juno v0.8.4
[29cba6d7] Bonmin_jll v100.800.800+0
[9cc047cb] Ipopt_jll v3.13.4+2
[ade2ca70] Dates
[37e2e46d] LinearAlgebra
Checking raw_status(model)
suggests that AmplNLWriter is unable to call the Ipopt_jll solver.
Error calling the solver. Failed with: MethodError(AmplNLWriter.call_solver, (AmplNLWriter._DefaultSolverCommand{typeof(Ipopt_jll.amplexe)}(Ipopt_jll.amplexe), "C:\\Users\\AppData\\Local\\Temp\\jl_ReON4y\\model.nl", Any[], Base.TTY(Base.Libc.WindowsRawSocket(0x0000000000000240) open, 0 bytes waiting), Base.TTY(Base.Libc.WindowsRawSocket(0x0000000000000248) open, 0 bytes waiting)), 0x0000000000007484)