Skip to content
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

set_dual_start_value function #423

Closed
mcosovic opened this issue Jul 26, 2024 · 2 comments · Fixed by #424
Closed

set_dual_start_value function #423

mcosovic opened this issue Jul 26, 2024 · 2 comments · Fixed by #424

Comments

@mcosovic
Copy link

Hello,

Something strange happens when I try to set the value of the dual variable for the nonlinear constraint. I'm not sure if it is related to the nonlinear constraint itself; perhaps the example is not ideal, but it represents what is happening:

model = Model(Ipopt.Optimizer)

x = @variable(model, 0 <= x[i = 1:2] <= 0.8)
c = @constraint(model, sin(x[1] - x[2]) == 0.5)
set_dual_start_value(c, 0.1)

@objective(model, Min, sum(x))
optimize!(model)
ERROR: BoundsError: attempt to access 0-element Vector{Union{Nothing, Float64}} at index [1]
Stacktrace:
  [1] setindex!
    @ .\array.jl:1021 [inlined]
  [2] set
    @ C:\Users\User\.julia\packages\Ipopt\YDBAD\src\utils.jl:465 [inlined]
  [3] set
    @ C:\Users\User\.julia\packages\Ipopt\YDBAD\src\MOI_wrapper.jl:430 [inlined]
  [4] _set_substituted
    @ C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Bridges\bridge_optimizer.jl:1375 [inlined]
  [5] set(b::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, attr::MathOptInterface.ConstraintDualStart, ci::MathOptInterface.ConstraintIndex{…}, value::Float64)
    @ MathOptInterface.Bridges C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Bridges\bridge_optimizer.jl:1603
  [6] _pass_attribute(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…}, index_map::MathOptInterface.Utilities.IndexMap, cis_src::Vector{…}, attr::MathOptInterface.ConstraintDualStart)
    @ MathOptInterface.Utilities C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Utilities\copy.jl:146
  [7] pass_attributes(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…}, index_map::MathOptInterface.Utilities.IndexMap, cis_src::Vector{…})
    @ MathOptInterface.Utilities C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Utilities\copy.jl:131
  [8] _pass_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…}, index_map::MathOptInterface.Utilities.IndexMap, variable_constraints_not_added::Vector{…})
    @ MathOptInterface.Utilities C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Utilities\copy.jl:337
  [9] default_copy_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{…}, src::MathOptInterface.Utilities.UniversalFallback{…})
    @ MathOptInterface.Utilities C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Utilities\copy.jl:505
 [10] copy_to
    @ C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Bridges\bridge_optimizer.jl:455 [inlined]
 [11] optimize!
    @ C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\MathOptInterface.jl:84 [inlined]
 [12] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{…})
    @ MathOptInterface.Utilities C:\Users\User\.julia\packages\MathOptInterface\2rAFb\src\Utilities\cachingoptimizer.jl:316
 [13] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})
    @ JuMP C:\Users\User\.julia\packages\JuMP\Gwn88\src\optimizer_interface.jl:457
 [14] optimize!(model::Model)
    @ JuMP C:\Users\User\.julia\packages\JuMP\Gwn88\src\optimizer_interface.jl:409
 [15] top-level scope
    @ c:\Users\User\Desktop\aaa.jl:13
Some type information was truncated. Use `show(err)` to see complete types.

It's even stranger because if I remove the sine function, it works well. Additionally, if I add a new constraint, it also works well. For example:

model = Model(Ipopt.Optimizer)

x = @variable(model, 0 <= x[i = 1:2] <= 0.8)

c = @constraint(model, sin(x[1] - x[2]) == 0.5)
n = @constraint(model, 0 <= x[1] - x[2] <= 1)
set_dual_start_value(c, 0.1)

@objective(model, Min, sum(x))
optimize!(model)
@odow odow transferred this issue from jump-dev/JuMP.jl Jul 26, 2024
@odow
Copy link
Member

odow commented Jul 26, 2024

I transferred this to Ipopt. It looks like a bug. I mustn't have tested ConstraintDualStart with the new nonlinear API.

@odow
Copy link
Member

odow commented Jul 27, 2024

Thanks for reporting! I'll get a new release tagged in the next couple of hours: #425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants