|
35 | 35 |
|
36 | 36 | Base.size(array::ArrayOfVariables) = array.size |
37 | 37 | function Base.getindex(A::ArrayOfVariables{T}, I...) where {T} |
38 | | - index = A.offset + Base._to_linear_index(Base.CartesianIndices(A.size), I...) |
| 38 | + index = |
| 39 | + A.offset + Base._to_linear_index(Base.CartesianIndices(A.size), I...) |
39 | 40 | return JuMP.GenericVariableRef{T}(A.model, MOI.VariableIndex(index)) |
40 | 41 | end |
41 | 42 |
|
42 | 43 | JuMP._is_real(::ArrayOfVariables) = true |
43 | | -JuMP.moi_function(array::ArrayOfVariables) = ContiguousArrayOfVariables(array.offset, array.size) |
44 | | -function JuMP.jump_function(model::JuMP.GenericModel{T}, array::ContiguousArrayOfVariables{N}) where {T,N} |
| 44 | +function JuMP.moi_function(array::ArrayOfVariables) |
| 45 | + return ContiguousArrayOfVariables(array.offset, array.size) |
| 46 | +end |
| 47 | +function JuMP.jump_function( |
| 48 | + model::JuMP.GenericModel{T}, |
| 49 | + array::ContiguousArrayOfVariables{N}, |
| 50 | +) where {T,N} |
45 | 51 | return ArrayOfVariables{T,N}(model, array.offset, array.size) |
46 | 52 | end |
47 | 53 |
|
48 | | -function Base.convert(::Type{ArrayOfVariables{T,N}}, array::Array{JuMP.GenericVariableRef{T},N}) where {T,N} |
| 54 | +function Base.convert( |
| 55 | + ::Type{ArrayOfVariables{T,N}}, |
| 56 | + array::Array{JuMP.GenericVariableRef{T},N}, |
| 57 | +) where {T,N} |
49 | 58 | model = JuMP.owner_model(array[1]) |
50 | 59 | offset = JuMP.index(array[1]).value - 1 |
51 | 60 | for i in eachindex(array) |
|
106 | 115 |
|
107 | 116 | function Base.getindex(expr::ExprGenerator, i::Integer) |
108 | 117 | idx = CartesianIndices(Base.OneTo.(_size(expr)))[i] |
109 | | - values = [expr.iterators[i].values[idx[i]] for i in eachindex(expr.iterators)] |
| 118 | + values = |
| 119 | + [expr.iterators[i].values[idx[i]] for i in eachindex(expr.iterators)] |
110 | 120 | return index_iterators(expr.expr.expr, values) |
111 | 121 | end |
112 | 122 |
|
|
0 commit comments