Skip to content

Commit c451032

Browse files
committed
Updates
1 parent 3352f8c commit c451032

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Utilities/functions.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ end
197197
# The `eval_variables(::F, ::MOI.ModelLike, ::MOI.ScalarNonlinearFunction)`
198198
# method is defined in the MOI.Nonlinear submodule.
199199

200+
function eval_variables(
201+
value_fn::F,
202+
model::MOI.ModelLike,
203+
f::MOI.GenericVectorFunction,
204+
) where {F}
205+
return map(f.rows) do row
206+
return eval_variables(value_fn, model, row)
207+
end
208+
end
209+
200210
"""
201211
map_indices(index_map::Function, attr::MOI.AnyAttribute, x::X)::X where {X}
202212
@@ -339,7 +349,7 @@ function map_indices(
339349
f::MOI.GenericVectorFunction{T},
340350
) where {F<:Function,T}
341351
return MOI.GenericVectorFunction{T}(
342-
convert(Vector{T}, map_indices(index_map, f.rows))
352+
convert(Vector{T}, map_indices(index_map, f.rows)),
343353
)
344354
end
345355

@@ -524,6 +534,14 @@ function substitute_variables(
524534
return g
525535
end
526536

537+
function substitute_variables(
538+
variable_map::F,
539+
f::MOI.GenericVectorFunction{T},
540+
) where {T,F<:Function}
541+
new_rows = map(Base.Fix1(substitute_variables, variable_map), f.rows)
542+
return MOI.GenericVectorFunction{T}(convert(Vector{T}, new_rows))
543+
end
544+
527545
"""
528546
scalar_type(F::Type{<:MOI.AbstractVectorFunction})
529547
@@ -923,6 +941,8 @@ function is_canonical(
923941
_is_strictly_sorted(f.quadratic_terms)
924942
end
925943

944+
is_canonical(f::MOI.GenericVectorFunction) = all(is_canonical, f.rows)
945+
926946
function _is_strictly_sorted(x::Vector)
927947
if isempty(x)
928948
return true

0 commit comments

Comments
 (0)