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

default_copy_to accesses private methods #149

Closed
odow opened this issue Jun 24, 2024 · 1 comment · Fixed by #147
Closed

default_copy_to accesses private methods #149

odow opened this issue Jun 24, 2024 · 1 comment · Fixed by #147

Comments

@odow
Copy link
Member

odow commented Jun 24, 2024

See

function _poi_default_copy_to(dest::T, src::MOI.ModelLike) where {T}
if !MOI.supports_incremental_interface(dest)
error("Model $(typeof(dest)) does not support copy_to.")
end
MOI.empty!(dest)
vis_src = MOI.get(src, MOI.ListOfVariableIndices())
index_map = MOI.IndexMap()
# The `NLPBlock` assumes that the order of variables does not change (#849)
# Therefore, all VariableIndex and VectorOfVariable constraints are added
# seprately, and no variables constrained-on-creation are added.
# This is not valid for NLPs with Parameters, they should enter
has_nlp = MOI.NLPBlock() in MOI.get(src, MOI.ListOfModelAttributesSet())
constraints_not_added = if has_nlp
vcat(
Any[
MOI.get(src, MOI.ListOfConstraintIndices{F,S}()) for
(F, S) in MOI.get(src, MOI.ListOfConstraintTypesPresent()) if
MOI.Utilities._is_variable_function(F) &&
S != MOI.Parameter{Float64}
],
Any[MOI.Utilities._try_constrain_variables_on_creation(
dest,
src,
index_map,
MOI.Parameter{Float64},
)],
)
else
Any[
MOI.Utilities._try_constrain_variables_on_creation(
dest,
src,
index_map,
S,
) for S in MOI.Utilities.sorted_variable_sets_by_cost(dest, src)
]
end
MOI.Utilities._copy_free_variables(dest, index_map, vis_src)

x-ref jump-dev/MathOptInterface.jl#2520

@odow
Copy link
Member Author

odow commented Jun 24, 2024

This is effectively a duplicate of #146.

The default_copy_to method hacks around the fact that the NLPBlock models do not support re-ordering parameters by permuting the variable order. So if we remove NLPBlock support (#147), then this method isn't needed.

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.

1 participant