Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jun 23, 2023
1 parent 3352f8c commit c451032
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Utilities/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ end
# The `eval_variables(::F, ::MOI.ModelLike, ::MOI.ScalarNonlinearFunction)`
# method is defined in the MOI.Nonlinear submodule.

function eval_variables(
value_fn::F,
model::MOI.ModelLike,
f::MOI.GenericVectorFunction,
) where {F}
return map(f.rows) do row
return eval_variables(value_fn, model, row)
end
end

"""
map_indices(index_map::Function, attr::MOI.AnyAttribute, x::X)::X where {X}
Expand Down Expand Up @@ -339,7 +349,7 @@ function map_indices(
f::MOI.GenericVectorFunction{T},
) where {F<:Function,T}
return MOI.GenericVectorFunction{T}(
convert(Vector{T}, map_indices(index_map, f.rows))
convert(Vector{T}, map_indices(index_map, f.rows)),
)
end

Expand Down Expand Up @@ -524,6 +534,14 @@ function substitute_variables(
return g
end

function substitute_variables(
variable_map::F,
f::MOI.GenericVectorFunction{T},
) where {T,F<:Function}
new_rows = map(Base.Fix1(substitute_variables, variable_map), f.rows)
return MOI.GenericVectorFunction{T}(convert(Vector{T}, new_rows))
end

"""
scalar_type(F::Type{<:MOI.AbstractVectorFunction})
Expand Down Expand Up @@ -923,6 +941,8 @@ function is_canonical(
_is_strictly_sorted(f.quadratic_terms)
end

is_canonical(f::MOI.GenericVectorFunction) = all(is_canonical, f.rows)

function _is_strictly_sorted(x::Vector)
if isempty(x)
return true
Expand Down

0 comments on commit c451032

Please sign in to comment.