91 |
96 |
|
end |
92 |
97 |
|
|
93 |
98 |
|
# scalar |
94 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
95 |
|
- |
::Type{<:Union{MOI.VariableIndex, MOI.ScalarAffineFunction{T}}}, |
96 |
|
- |
::Type{T} |
97 |
|
- |
) where T |
98 |
|
- |
MOI.ScalarAffineFunction{T} |
|
99 |
+ |
function MOIU.promote_operation( |
|
100 |
+ |
::typeof(LinearAlgebra.dot), |
|
101 |
+ |
::Type{T}, |
|
102 |
+ |
::Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}}, |
|
103 |
+ |
::Type{T}, |
|
104 |
+ |
) where {T} |
|
105 |
+ |
return MOI.ScalarAffineFunction{T} |
99 |
106 |
|
end |
100 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
107 |
+ |
function MOIU.promote_operation( |
|
108 |
+ |
::typeof(LinearAlgebra.dot), |
101 |
109 |
|
::Type{T}, |
102 |
|
- |
::Type{<:Union{MOI.VariableIndex, MOI.ScalarAffineFunction{T}}} |
103 |
|
- |
) where T |
104 |
|
- |
MOI.ScalarAffineFunction{T} |
|
110 |
+ |
::Type{T}, |
|
111 |
+ |
::Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}}, |
|
112 |
+ |
) where {T} |
|
113 |
+ |
return MOI.ScalarAffineFunction{T} |
105 |
114 |
|
end |
106 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
107 |
|
- |
::Type{<:Union{MOI.VariableIndex, MOI.ScalarAffineFunction{T}}}, |
108 |
|
- |
::Type{<:Union{MOI.VariableIndex, MOI.ScalarAffineFunction{T}}} |
109 |
|
- |
) where T |
110 |
|
- |
MOI.ScalarQuadraticFunction{T} |
|
115 |
+ |
function MOIU.promote_operation( |
|
116 |
+ |
::typeof(LinearAlgebra.dot), |
|
117 |
+ |
::Type{T}, |
|
118 |
+ |
::Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}}, |
|
119 |
+ |
::Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}}, |
|
120 |
+ |
) where {T} |
|
121 |
+ |
return MOI.ScalarQuadraticFunction{T} |
111 |
122 |
|
end |
112 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
123 |
+ |
function MOIU.promote_operation( |
|
124 |
+ |
::typeof(LinearAlgebra.dot), |
|
125 |
+ |
::Type{T}, |
113 |
126 |
|
::Type{MOI.ScalarQuadraticFunction{T}}, |
114 |
|
- |
::Type{T} |
115 |
|
- |
) where T |
116 |
|
- |
MOI.ScalarQuadraticFunction{T} |
|
127 |
+ |
::Type{T}, |
|
128 |
+ |
) where {T} |
|
129 |
+ |
return MOI.ScalarQuadraticFunction{T} |
117 |
130 |
|
end |
118 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
131 |
+ |
function MOIU.promote_operation( |
|
132 |
+ |
::typeof(LinearAlgebra.dot), |
119 |
133 |
|
::Type{T}, |
120 |
|
- |
::Type{MOI.ScalarQuadraticFunction{T}} |
121 |
|
- |
) where T |
122 |
|
- |
MOI.ScalarQuadraticFunction{T} |
|
134 |
+ |
::Type{T}, |
|
135 |
+ |
::Type{MOI.ScalarQuadraticFunction{T}}, |
|
136 |
+ |
) where {T} |
|
137 |
+ |
return MOI.ScalarQuadraticFunction{T} |
123 |
138 |
|
end |
124 |
139 |
|
# flip |
125 |
|
- |
function MOIU.operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
140 |
+ |
function MOIU.operate( |
|
141 |
+ |
::typeof(LinearAlgebra.dot), |
|
142 |
+ |
::Type{T}, |
126 |
143 |
|
f::Union{ |
127 |
144 |
|
MOI.VariableIndex, |
128 |
145 |
|
MOI.ScalarAffineFunction{T}, |
129 |
|
- |
MOI.ScalarQuadraticFunction{T} |
130 |
|
- |
}, |
131 |
|
- |
α::T) where T |
|
146 |
+ |
MOI.ScalarQuadraticFunction{T}, |
|
147 |
+ |
}, |
|
148 |
+ |
α::T, |
|
149 |
+ |
) where {T} |
132 |
150 |
|
return MOIU.operate(LinearAlgebra.dot, T, α, f) |
133 |
151 |
|
end |
134 |
152 |
|
# pass to * |
135 |
|
- |
function MOIU.operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
136 |
|
- |
f::Union{ |
137 |
|
- |
T, |
138 |
|
- |
MOI.VariableIndex, |
139 |
|
- |
MOI.ScalarAffineFunction{T} |
140 |
|
- |
}, |
141 |
|
- |
g::Union{ |
142 |
|
- |
MOI.VariableIndex, |
143 |
|
- |
MOI.ScalarAffineFunction{T} |
144 |
|
- |
} |
145 |
|
- |
) where T |
|
153 |
+ |
function MOIU.operate( |
|
154 |
+ |
::typeof(LinearAlgebra.dot), |
|
155 |
+ |
::Type{T}, |
|
156 |
+ |
f::Union{T,MOI.VariableIndex,MOI.ScalarAffineFunction{T}}, |
|
157 |
+ |
g::Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}, |
|
158 |
+ |
) where {T} |
146 |
159 |
|
return MOIU.operate(*, T, f, g) |
147 |
160 |
|
end |
148 |
|
- |
function MOIU.operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
161 |
+ |
function MOIU.operate( |
|
162 |
+ |
::typeof(LinearAlgebra.dot), |
|
163 |
+ |
::Type{T}, |
149 |
164 |
|
α::T, |
150 |
|
- |
f::MOI.ScalarQuadraticFunction{T} |
151 |
|
- |
) where T |
|
165 |
+ |
f::MOI.ScalarQuadraticFunction{T}, |
|
166 |
+ |
) where {T} |
152 |
167 |
|
return MOIU.operate(*, T, f, α) |
153 |
168 |
|
end |
154 |
169 |
|
|
155 |
170 |
|
# vector |
156 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
157 |
|
- |
::Type{<:Union{MOI.VectorOfVariables, MOI.VectorAffineFunction{T}}}, |
158 |
|
- |
::Type{Vector{T}} |
159 |
|
- |
) where T |
160 |
|
- |
MOI.VectorAffineFunction{T} |
|
171 |
+ |
function MOIU.promote_operation( |
|
172 |
+ |
::typeof(LinearAlgebra.dot), |
|
173 |
+ |
::Type{T}, |
|
174 |
+ |
::Type{<:Union{MOI.VectorOfVariables,MOI.VectorAffineFunction{T}}}, |
|
175 |
+ |
::Type{Vector{T}}, |
|
176 |
+ |
) where {T} |
|
177 |
+ |
return MOI.VectorAffineFunction{T} |
161 |
178 |
|
end |
162 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
179 |
+ |
function MOIU.promote_operation( |
|
180 |
+ |
::typeof(LinearAlgebra.dot), |
|
181 |
+ |
::Type{T}, |
163 |
182 |
|
::Type{Vector{T}}, |
164 |
|
- |
::Type{<:Union{MOI.VectorOfVariables, MOI.VectorAffineFunction{T}}} |
165 |
|
- |
) where T |
166 |
|
- |
MOI.VectorAffineFunction{T} |
|
183 |
+ |
::Type{<:Union{MOI.VectorOfVariables,MOI.VectorAffineFunction{T}}}, |
|
184 |
+ |
) where {T} |
|
185 |
+ |
return MOI.VectorAffineFunction{T} |
167 |
186 |
|
end |
168 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
169 |
|
- |
::Type{<:Union{MOI.VectorOfVariables, MOI.VectorAffineFunction{T}}}, |
170 |
|
- |
::Type{<:Union{MOI.VectorOfVariables, MOI.VectorAffineFunction{T}}} |
171 |
|
- |
) where T |
172 |
|
- |
MOI.VectorQuadraticFunction{T} |
|
187 |
+ |
function MOIU.promote_operation( |
|
188 |
+ |
::typeof(LinearAlgebra.dot), |
|
189 |
+ |
::Type{T}, |
|
190 |
+ |
::Type{<:Union{MOI.VectorOfVariables,MOI.VectorAffineFunction{T}}}, |
|
191 |
+ |
::Type{<:Union{MOI.VectorOfVariables,MOI.VectorAffineFunction{T}}}, |
|
192 |
+ |
) where {T} |
|
193 |
+ |
return MOI.VectorQuadraticFunction{T} |
173 |
194 |
|
end |
174 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
195 |
+ |
function MOIU.promote_operation( |
|
196 |
+ |
::typeof(LinearAlgebra.dot), |
|
197 |
+ |
::Type{T}, |
175 |
198 |
|
::Type{MOI.VectorQuadraticFunction{T}}, |
176 |
|
- |
::Type{Vector{T}} |
177 |
|
- |
) where T |
178 |
|
- |
MOI.VectorQuadraticFunction{T} |
|
199 |
+ |
::Type{Vector{T}}, |
|
200 |
+ |
) where {T} |
|
201 |
+ |
return MOI.VectorQuadraticFunction{T} |
179 |
202 |
|
end |
180 |
|
- |
function MOIU.promote_operation(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
203 |
+ |
function MOIU.promote_operation( |
|
204 |
+ |
::typeof(LinearAlgebra.dot), |
|
205 |
+ |
::Type{T}, |
181 |
206 |
|
::Type{Vector{T}}, |
182 |
|
- |
::Type{MOI.VectorQuadraticFunction{T}} |
183 |
|
- |
) where T |
184 |
|
- |
MOI.VectorQuadraticFunction{T} |
|
207 |
+ |
::Type{MOI.VectorQuadraticFunction{T}}, |
|
208 |
+ |
) where {T} |
|
209 |
+ |
return MOI.VectorQuadraticFunction{T} |
185 |
210 |
|
end |
186 |
211 |
|
# flip |
187 |
|
- |
function MOIU.operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
212 |
+ |
function MOIU.operate( |
|
213 |
+ |
::typeof(LinearAlgebra.dot), |
|
214 |
+ |
::Type{T}, |
188 |
215 |
|
f::Union{ |
189 |
216 |
|
MOI.VectorOfVariables, |
190 |
217 |
|
MOI.VectorAffineFunction{T}, |
191 |
|
- |
MOI.VectorQuadraticFunction{T} |
192 |
|
- |
}, |
193 |
|
- |
α::Vector{T}) where T |
|
218 |
+ |
MOI.VectorQuadraticFunction{T}, |
|
219 |
+ |
}, |
|
220 |
+ |
α::Vector{T}, |
|
221 |
+ |
) where {T} |
194 |
222 |
|
return MOIU.operate(LinearAlgebra.dot, T, α, f) |
195 |
223 |
|
end |
196 |
224 |
|
# pass to _operate(LinearAlgebra.dot, ...) |
197 |
|
- |
function MOIU.operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
198 |
|
- |
f::Union{ |
199 |
|
- |
Vector{T}, |
200 |
|
- |
MOI.VectorOfVariables, |
201 |
|
- |
MOI.VectorAffineFunction{T} |
202 |
|
- |
}, |
203 |
|
- |
g::Union{ |
204 |
|
- |
MOI.VectorOfVariables, |
205 |
|
- |
MOI.VectorAffineFunction{T} |
206 |
|
- |
} |
207 |
|
- |
) where T |
|
225 |
+ |
function MOIU.operate( |
|
226 |
+ |
::typeof(LinearAlgebra.dot), |
|
227 |
+ |
::Type{T}, |
|
228 |
+ |
f::Union{Vector{T},MOI.VectorOfVariables,MOI.VectorAffineFunction{T}}, |
|
229 |
+ |
g::Union{MOI.VectorOfVariables,MOI.VectorAffineFunction{T}}, |
|
230 |
+ |
) where {T} |
208 |
231 |
|
return _operate(LinearAlgebra.dot, T, f, g) |
209 |
232 |
|
end |
210 |
|
- |
function MOIU.operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
233 |
+ |
function MOIU.operate( |
|
234 |
+ |
::typeof(LinearAlgebra.dot), |
|
235 |
+ |
::Type{T}, |
211 |
236 |
|
α::T, |
212 |
|
- |
f::MOI.VectorQuadraticFunction{T} |
213 |
|
- |
) where T |
|
237 |
+ |
f::MOI.VectorQuadraticFunction{T}, |
|
238 |
+ |
) where {T} |
214 |
239 |
|
return _operate(LinearAlgebra.dot, T, f, α) |
215 |
240 |
|
end |
216 |
|
- |
function _operate(::typeof(LinearAlgebra.dot), ::Type{T}, |
|
241 |
+ |
function _operate( |
|
242 |
+ |
::typeof(LinearAlgebra.dot), |
|
243 |
+ |
::Type{T}, |
217 |
244 |
|
f::Union{ |
218 |
245 |
|
Vector{T}, |
219 |
246 |
|
MOI.VectorOfVariables, |
220 |
247 |
|
MOI.VectorAffineFunction{T}, |
221 |
|
- |
MOI.VectorQuadraticFunction{T} |
222 |
|
- |
}, |
|
248 |
+ |
MOI.VectorQuadraticFunction{T}, |
|
249 |
+ |
}, |
223 |
250 |
|
g::Union{ |
224 |
251 |
|
MOI.VectorOfVariables, |
225 |
252 |
|
MOI.VectorAffineFunction{T}, |
226 |
|
- |
MOI.VectorQuadraticFunction{T} |
227 |
|
- |
}) where T |
228 |
|
- |
|
|
253 |
+ |
MOI.VectorQuadraticFunction{T}, |
|
254 |
+ |
}, |
|
255 |
+ |
) where {T} |
229 |
256 |
|
dim = MOI.output_dimension(g) |
230 |
257 |
|
if MOI.output_dimension(f) != dim |
231 |
|
- |
throw(DimensionMismatch("f and g are of different MOI.output_dimension's!")) |
|
258 |
+ |
throw( |
|
259 |
+ |
DimensionMismatch( |
|
260 |
+ |
"f and g are of different MOI.output_dimension's!", |
|
261 |
+ |
), |
|
262 |
+ |
) |
232 |
263 |
|
end |
233 |
264 |
|
|
234 |
265 |
|
fs = MOIU.scalarize(f) |