|
197 | 197 | # The `eval_variables(::F, ::MOI.ModelLike, ::MOI.ScalarNonlinearFunction)` |
198 | 198 | # method is defined in the MOI.Nonlinear submodule. |
199 | 199 |
|
| 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 | + |
200 | 210 | """ |
201 | 211 | map_indices(index_map::Function, attr::MOI.AnyAttribute, x::X)::X where {X} |
202 | 212 |
|
@@ -339,7 +349,7 @@ function map_indices( |
339 | 349 | f::MOI.GenericVectorFunction{T}, |
340 | 350 | ) where {F<:Function,T} |
341 | 351 | return MOI.GenericVectorFunction{T}( |
342 | | - convert(Vector{T}, map_indices(index_map, f.rows)) |
| 352 | + convert(Vector{T}, map_indices(index_map, f.rows)), |
343 | 353 | ) |
344 | 354 | end |
345 | 355 |
|
@@ -524,6 +534,14 @@ function substitute_variables( |
524 | 534 | return g |
525 | 535 | end |
526 | 536 |
|
| 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 | + |
527 | 545 | """ |
528 | 546 | scalar_type(F::Type{<:MOI.AbstractVectorFunction}) |
529 | 547 |
|
@@ -923,6 +941,8 @@ function is_canonical( |
923 | 941 | _is_strictly_sorted(f.quadratic_terms) |
924 | 942 | end |
925 | 943 |
|
| 944 | +is_canonical(f::MOI.GenericVectorFunction) = all(is_canonical, f.rows) |
| 945 | + |
926 | 946 | function _is_strictly_sorted(x::Vector) |
927 | 947 | if isempty(x) |
928 | 948 | return true |
|
0 commit comments