-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
See
ParametricOptInterface.jl/src/MOI_wrapper.jl
Lines 1390 to 1428 in 4ec565a
| 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) |
Metadata
Metadata
Assignees
Labels
No labels