|
4 | 4 | # Use of this source code is governed by an MIT-style license that can be found
|
5 | 5 | # in the LICENSE.md file or at https://opensource.org/licenses/MIT.
|
6 | 6 |
|
7 |
| -# There are five methods for which we implement `Utilities.promote_operation` |
8 |
| -# and `Utilities.operate`: |
9 |
| -# |
10 |
| -# 1. `+` |
11 |
| -# a. `promote_operation(::typeof(+), ::Type{T}, ::Type{F1}, ::Type{F2})` |
12 |
| -# 2. `-` |
13 |
| -# a. `promote_operation(::typeof(-), ::Type{T}, ::Type{F})` |
14 |
| -# b. `promote_operation(::typeof(-), ::Type{T}, ::Type{F1}, ::Type{F2})` |
15 |
| -# c. `promote_operation(::typeof(-), ::Type{T}, ::Type{F1}, ::Type{Vector{T}})` |
16 |
| -# 3. `*` |
17 |
| -# a. `promote_operation(::typeof(*), ::Type{T}, ::Type{T}, ::Type{F})` |
18 |
| -# b. `promote_operation(::typeof(*), ::Type{T}, ::Type{F1}, ::Type{F2})` |
19 |
| -# where `F1` and `F2` are `VariableIndex` or `ScalarAffineFunction` |
20 |
| -# c. `promote_operation(::typeof(*), ::Type{T}, ::Type{<:Diagonal{T}}, ::Type{F}` |
21 |
| -# 4. `/` |
22 |
| -# a. `promote_operation(::typeof(/), ::Type{T}, ::Type{F}, ::Type{T})` |
23 |
| -# 5. `vcat` |
24 |
| -# a. `promote_operation(::typeof(vcat), ::Type{T}, ::Type{F}...)` |
25 |
| -# 6. `imag` |
26 |
| -# a. `promote_operation(::typeof(imag), ::Type{T}, ::Type{F}` |
27 |
| -# where `F` is `VariableIndex` or `VectorOfVariables` |
28 |
| -# |
29 |
| -# There are eight types: |
30 |
| -# |
31 |
| -# 1. ::T |
32 |
| -# 2. ::VariableIndex |
33 |
| -# 3. ::ScalarAffineFunction{T} |
34 |
| -# 4. ::ScalarQuadraticFunction{T} |
35 |
| -# 5. ::AbstractVector{T} |
36 |
| -# 6. ::VectorOfVariables |
37 |
| -# 7. ::VectorAffineFunction{T} |
38 |
| -# 8. ::VectorQuadraticFunction{T} |
39 |
| - |
40 |
| -vector_type(::Type{T}) where {T} = Vector{T} |
41 |
| - |
42 |
| -vector_type(::Type{MOI.VariableIndex}) = MOI.VectorOfVariables |
43 |
| - |
44 |
| -function vector_type(::Type{MOI.ScalarAffineFunction{T}}) where {T} |
45 |
| - return MOI.VectorAffineFunction{T} |
46 |
| -end |
47 |
| - |
48 |
| -function vector_type(::Type{MOI.ScalarQuadraticFunction{T}}) where {T} |
49 |
| - return MOI.VectorQuadraticFunction{T} |
50 |
| -end |
| 7 | +""" |
| 8 | + promote_operation( |
| 9 | + op::Function, |
| 10 | + ::Type{T}, |
| 11 | + ArgsTypes::Type{<:Union{T,AbstractVector{T},MOI.AbstractFunction}}..., |
| 12 | + ) where {T} |
| 13 | +
|
| 14 | +Compute the return type of the call `operate(op, T, args...)`, where the types |
| 15 | +of the arguments `args` are `ArgsTypes`. |
| 16 | +
|
| 17 | +There are five methods for which we implement `Utilities.promote_operation`: |
| 18 | +
|
| 19 | + 1. `+` |
| 20 | + a. `promote_operation(::typeof(+), ::Type{T}, ::Type{F1}, ::Type{F2})` |
| 21 | + 2. `-` |
| 22 | + a. `promote_operation(::typeof(-), ::Type{T}, ::Type{F})` |
| 23 | + b. `promote_operation(::typeof(-), ::Type{T}, ::Type{F1}, ::Type{F2})` |
| 24 | + c. `promote_operation(::typeof(-), ::Type{T}, ::Type{F1}, ::Type{Vector{T}})` |
| 25 | + 3. `*` |
| 26 | + a. `promote_operation(::typeof(*), ::Type{T}, ::Type{T}, ::Type{F})` |
| 27 | + b. `promote_operation(::typeof(*), ::Type{T}, ::Type{F1}, ::Type{F2})` |
| 28 | + where `F1` and `F2` are `VariableIndex` or `ScalarAffineFunction` |
| 29 | + c. `promote_operation(::typeof(*), ::Type{T}, ::Type{<:Diagonal{T}}, ::Type{F}` |
| 30 | + 4. `/` |
| 31 | + a. `promote_operation(::typeof(/), ::Type{T}, ::Type{F}, ::Type{T})` |
| 32 | + 5. `vcat` |
| 33 | + a. `promote_operation(::typeof(vcat), ::Type{T}, ::Type{F}...)` |
| 34 | + 6. `imag` |
| 35 | + a. `promote_operation(::typeof(imag), ::Type{T}, ::Type{F}` |
| 36 | + where `F` is `VariableIndex` or `VectorOfVariables` |
| 37 | +
|
| 38 | +There are nine types: |
| 39 | +
|
| 40 | + 1. ::T |
| 41 | + 2. ::VariableIndex |
| 42 | + 3. ::ScalarAffineFunction{T} |
| 43 | + 4. ::ScalarQuadraticFunction{T} |
| 44 | + 5. ::ScalarNonlinearFunction |
| 45 | + 6. ::AbstractVector{T} |
| 46 | + 7. ::VectorOfVariables |
| 47 | + 8. ::VectorAffineFunction{T} |
| 48 | + 9. ::VectorQuadraticFunction{T} |
| 49 | +""" |
| 50 | +function promote_operation end |
51 | 51 |
|
52 | 52 | ### Method 1a and 2b
|
53 | 53 |
|
|
0 commit comments