Skip to content

Add attributes jump_variables and jump_constraints in the model#228

Open
amontoison wants to merge 3 commits intoJuliaSmoothOptimizers:mainfrom
amontoison:am/mapping
Open

Add attributes jump_variables and jump_constraints in the model#228
amontoison wants to merge 3 commits intoJuliaSmoothOptimizers:mainfrom
amontoison:am/mapping

Conversation

@amontoison
Copy link
Copy Markdown
Member

cc @michel2323

using NLPModels, NLPModelsJuMP, JuMP

x0 = [-1.2; 1.0]
model = Model() # No solver is required
@variable(model, x[i=1:2], start=x0[i])
@objective(model, Min, (x[1] - 1)^2 + 100 * (x[2] - x[1]^2)^2)

nlp = MathOptNLPModel(model)
nlp.jump_variables
julia> nlp.jump_variables
Dict{String, Int64} with 2 entries:
  "x[2]" => 2
  "x[1]" => 1

@amontoison
Copy link
Copy Markdown
Member Author

@blegat Do you have an idea why the tests are failing?

@amontoison amontoison changed the title Add an attribute jump_variables in the model Add attribute jump_variables and jump_constraints in the model Jan 22, 2026
@amontoison amontoison changed the title Add attribute jump_variables and jump_constraints in the model Add attributes jump_variables and jump_constraints in the model Jan 22, 2026
Comment thread src/MOI_wrapper.jl Outdated
dest.nlp = nlp_model(src)
dest.solver = dest.options["solver"](dest.nlp)
return index_map
return dest
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MOI.copy_to should return the index_map

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what is making the tests fail

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index_map was just a dummy dict VariableRef(
i) => VariableRef(i).
Why do you need it?
Is it because of bridges?

Comment thread src/MOI_wrapper.jl Outdated
Co-authored-by: Benoît Legat <benoit.legat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants