@@ -20,6 +20,7 @@ struct IndexMap <: AbstractDict{MOI.Index,MOI.Index}
2020 typeof (CleverDicts. index_to_key),
2121 }
2222 con_map:: DoubleDicts.IndexDoubleDict
23+ nl_cache:: Dict{MOI.ScalarNonlinearFunction,MOI.ScalarNonlinearFunction}
2324end
2425
2526"""
@@ -30,7 +31,8 @@ The dictionary-like object returned by [`MOI.copy_to`](@ref).
3031function IndexMap ()
3132 var_map = CleverDicts. CleverDict {MOI.VariableIndex,MOI.VariableIndex} ()
3233 con_map = DoubleDicts. IndexDoubleDict ()
33- return IndexMap (var_map, con_map)
34+ nl_cache = Dict {MOI.ScalarNonlinearFunction,MOI.ScalarNonlinearFunction} ()
35+ return IndexMap (var_map, con_map, nl_cache)
3436end
3537
3638function _identity_constraints_map (
@@ -104,3 +106,10 @@ Base.length(map::IndexMap) = length(map.var_map) + length(map.con_map)
104106function Base. iterate (map:: IndexMap , args... )
105107 return iterate (Base. Iterators. flatten ((map. var_map, map. con_map)), args... )
106108end
109+
110+ function map_indices (
111+ index_map:: IndexMap ,
112+ f:: MOI.ScalarNonlinearFunction ,
113+ )
114+ return map_indices (Base. Fix1 (getindex, index_map), f, index_map. nl_cache)
115+ end
0 commit comments