Skip to content

default_copy_to accesses private methods #149

Description

@odow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions