-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error updating NLparameter
#204
Comments
Thanks for reporting this issue with the complete MWE. I confirm I can reproduce it locally. A direct workaroundIf this is blocking for your work, I would suggest to define using JuMP
using KNITRO
# small test problem
model = JuMP.Model(
optimizer_with_attributes(
KNITRO.Optimizer,
"honorbnds" => 1,
),
)
@variable(model, 0 <= x[1:5] <= 10)
@variable(model, epsilon==1)
@constraint(model, sum(x) == 10)
@NLconstraint(model, x[1] + exp(x[2]*epsilon) <= 10)
@NLconstraint(model, x[2] + exp(x[3]*epsilon) <= 5)
@objective(model, Max, x[2])
# solve with first parameter
JuMP.fix(epsilon, 1e-1) # okay
optimize!(model)
# solve with second parameter
JuMP.fix(epsilon, 1e-2) # it works locally for me!
optimize!(model)
Addressing your issueHowever, the previous MWE does not solve your issue. I think it's a bug inside Knitro's MOI wrapper. The issue arises inside the x0 = rand(5)
jump_evaluator = model.moi_backend.optimizer.model.nlp_data.evaluator
MOI.eval_objective(jump_evaluator, x0)
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] getproperty
@ ./Base.jl:33 [inlined]
[2] macro expansion
@ ~/.julia/packages/JuMP/klrjG/src/nlp.jl:735 [inlined]
[3] macro expansion
@ ./timing.jl:287 [inlined]
[4] eval_objective(d::NLPEvaluator, x::Vector{Float64})
@ JuMP ~/.julia/packages/JuMP/klrjG/src/nlp.jl:734 Your MWE is working fine with Ipopt, so I don't think the issue is inside JuMP. I suspect a nasty side-effect within Knitro's MOI wrapper. |
I have a guess at what is wrong: You initialize things only if Lines 348 to 369 in f61bed3
But setting the KNITRO.jl/src/MOI_wrapper/nlp.jl Lines 5 to 7 in f61bed3
So the first solve works okay, then JuMP updates the This can probably be fixed by setting Related issues: jump-dev/JuMP.jl#1185, jump-dev/JuMP.jl#3018 |
Thank you very much! |
Hi, I seem to be unable to update parameters for resolves using the JuMP interface. Below is a MWE:
The error message is:
I am using Julia v1.6.3, JuMP v0.21.10 and KNITRO v0.10.
Any ideas on how to do this?
The text was updated successfully, but these errors were encountered: