@@ -482,6 +482,26 @@ function scalar_type(::Type{MOI.VectorQuadraticFunction{T}}) where {T}
482
482
return MOI. ScalarQuadraticFunction{T}
483
483
end
484
484
485
+ """
486
+ vector_type(::Type{<:MOI.AbstractScalarFunction})
487
+
488
+ Return the [`MOI.AbstractVectorFunction`](@ref) associated with the scalar type
489
+ `F`.
490
+ """
491
+ function vector_type end
492
+
493
+ vector_type (:: Type{T} ) where {T} = Vector{T}
494
+
495
+ vector_type (:: Type{MOI.VariableIndex} ) = MOI. VectorOfVariables
496
+
497
+ function vector_type (:: Type{MOI.ScalarAffineFunction{T}} ) where {T}
498
+ return MOI. VectorAffineFunction{T}
499
+ end
500
+
501
+ function vector_type (:: Type{MOI.ScalarQuadraticFunction{T}} ) where {T}
502
+ return MOI. VectorQuadraticFunction{T}
503
+ end
504
+
485
505
"""
486
506
ScalarFunctionIterator{F<:MOI.AbstractVectorFunction}
487
507
@@ -1330,19 +1350,6 @@ function operate_output_index!(
1330
1350
return x[i] = operate! (op, T, x[i], args... )
1331
1351
end
1332
1352
1333
- """
1334
- promote_operation(
1335
- op::Function,
1336
- ::Type{T},
1337
- ArgsTypes::Type{<:Union{T, MOI.AbstractFunction}}...,
1338
- ) where {T}
1339
-
1340
- Returns the type of the `MOI.AbstractFunction` returned to the call
1341
- `operate(op, T, args...)` where the types of the arguments `args` are
1342
- `ArgsTypes`.
1343
- """
1344
- function promote_operation end
1345
-
1346
1353
# Helpers
1347
1354
1348
1355
function operate_term (
@@ -1597,44 +1604,6 @@ end
1597
1604
# ##################################### +/- #####################################
1598
1605
# # promote_operation
1599
1606
1600
- function promote_operation (:: typeof (- ), :: Type{T} , :: Type{T} ) where {T}
1601
- return T
1602
- end
1603
-
1604
- function promote_operation (
1605
- :: typeof (- ),
1606
- :: Type{T} ,
1607
- :: Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}} ,
1608
- ) where {T}
1609
- return MOI. ScalarAffineFunction{T}
1610
- end
1611
-
1612
- function promote_operation (
1613
- :: Union{typeof(+),typeof(-)} ,
1614
- :: Type{T} ,
1615
- :: Type{<:ScalarAffineLike{T}} ,
1616
- :: Type{<:ScalarAffineLike{T}} ,
1617
- ) where {T}
1618
- return MOI. ScalarAffineFunction{T}
1619
- end
1620
-
1621
- function promote_operation (
1622
- :: typeof (- ),
1623
- :: Type{T} ,
1624
- :: Type{<:ScalarQuadraticLike{T}} ,
1625
- ) where {T}
1626
- return MOI. ScalarQuadraticFunction{T}
1627
- end
1628
-
1629
- function promote_operation (
1630
- :: Union{typeof(+),typeof(-)} ,
1631
- :: Type{T} ,
1632
- :: Type{<:ScalarQuadraticLike{T}} ,
1633
- :: Type{<:ScalarQuadraticLike{T}} ,
1634
- ) where {T}
1635
- return MOI. ScalarQuadraticFunction{T}
1636
- end
1637
-
1638
1607
# # operate!
1639
1608
# + with at least 3 arguments
1640
1609
function operate! (op:: typeof (+ ), :: Type{T} , f, g, h, args... ) where {T}
@@ -1816,14 +1785,6 @@ end
1816
1785
1817
1786
# ## ScalarNonlinearFunction
1818
1787
1819
- function promote_operation (
1820
- :: Union{typeof(+),typeof(-)} ,
1821
- :: Type{<:Number} ,
1822
- :: Type{MOI.ScalarNonlinearFunction} ,
1823
- )
1824
- return MOI. ScalarNonlinearFunction
1825
- end
1826
-
1827
1788
function operate (
1828
1789
:: typeof (- ),
1829
1790
:: Type{T} ,
@@ -1838,24 +1799,6 @@ function operate(
1838
1799
return MOI. ScalarNonlinearFunction (:- , Any[f])
1839
1800
end
1840
1801
1841
- function promote_operation (
1842
- :: Union{typeof(+),typeof(-),typeof(*),typeof(/)} ,
1843
- :: Type{T} ,
1844
- :: Type{MOI.ScalarNonlinearFunction} ,
1845
- :: Type{S} ,
1846
- ) where {
1847
- T<: Number ,
1848
- S<: Union {
1849
- T,
1850
- MOI. VariableIndex,
1851
- MOI. ScalarAffineFunction{T},
1852
- MOI. ScalarQuadraticFunction{T},
1853
- MOI. ScalarNonlinearFunction,
1854
- },
1855
- }
1856
- return MOI. ScalarNonlinearFunction
1857
- end
1858
-
1859
1802
function operate (
1860
1803
op:: Union{typeof(+),typeof(-),typeof(*),typeof(/)} ,
1861
1804
:: Type{T} ,
@@ -1945,40 +1888,6 @@ end
1945
1888
# Vector +/-
1946
1889
# ##############################################################################
1947
1890
1948
- function promote_operation (
1949
- :: typeof (- ),
1950
- :: Type{T} ,
1951
- :: Type{<:VectorAffineLike{T}} ,
1952
- ) where {T}
1953
- return MOI. VectorAffineFunction{T}
1954
- end
1955
-
1956
- function promote_operation (
1957
- :: typeof (- ),
1958
- :: Type{T} ,
1959
- :: Type{<:VectorQuadraticLike{T}} ,
1960
- ) where {T}
1961
- return MOI. VectorQuadraticFunction{T}
1962
- end
1963
-
1964
- function promote_operation (
1965
- :: Union{typeof(+),typeof(-)} ,
1966
- :: Type{T} ,
1967
- :: Type{<:VectorAffineLike{T}} ,
1968
- :: Type{<:VectorAffineLike{T}} ,
1969
- ) where {T}
1970
- return MOI. VectorAffineFunction{T}
1971
- end
1972
-
1973
- function promote_operation (
1974
- :: Union{typeof(+),typeof(-)} ,
1975
- :: Type{T} ,
1976
- :: Type{<:VectorQuadraticLike{T}} ,
1977
- :: Type{<:VectorQuadraticLike{T}} ,
1978
- ) where {T}
1979
- return MOI. VectorQuadraticFunction{T}
1980
- end
1981
-
1982
1891
# Vector Variable +/- ...
1983
1892
function operate! (
1984
1893
op:: Union{typeof(+),typeof(-)} ,
@@ -2376,51 +2285,6 @@ end
2376
2285
2377
2286
# ###################################### * ######################################
2378
2287
2379
- function promote_operation (
2380
- :: typeof (* ),
2381
- :: Type{T} ,
2382
- :: Type{T} ,
2383
- :: Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}} ,
2384
- ) where {T}
2385
- return MOI. ScalarAffineFunction{T}
2386
- end
2387
-
2388
- function promote_operation (
2389
- :: typeof (* ),
2390
- :: Type{T} ,
2391
- :: Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}} ,
2392
- :: Type{T} ,
2393
- ) where {T}
2394
- return MOI. ScalarAffineFunction{T}
2395
- end
2396
-
2397
- function promote_operation (
2398
- :: typeof (* ),
2399
- :: Type{T} ,
2400
- :: Type{T} ,
2401
- :: Type{MOI.ScalarQuadraticFunction{T}} ,
2402
- ) where {T}
2403
- return MOI. ScalarQuadraticFunction{T}
2404
- end
2405
-
2406
- function promote_operation (
2407
- :: typeof (* ),
2408
- :: Type{T} ,
2409
- :: Type{MOI.ScalarQuadraticFunction{T}} ,
2410
- :: Type{T} ,
2411
- ) where {T}
2412
- return MOI. ScalarQuadraticFunction{T}
2413
- end
2414
-
2415
- function promote_operation (
2416
- :: typeof (* ),
2417
- :: Type{T} ,
2418
- :: Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}} ,
2419
- :: Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}} ,
2420
- ) where {T}
2421
- return MOI. ScalarQuadraticFunction{T}
2422
- end
2423
-
2424
2288
function operate! (:: typeof (* ), :: Type{T} , f:: MOI.VariableIndex , α:: T ) where {T}
2425
2289
return operate (* , T, α, f)
2426
2290
end
@@ -2639,24 +2503,6 @@ LinearAlgebra.symmetric(f::ScalarLike, ::Symbol) = f
2639
2503
2640
2504
# ###################################### / ######################################
2641
2505
2642
- function promote_operation (
2643
- :: typeof (/ ),
2644
- :: Type{T} ,
2645
- :: Type{<:Union{MOI.VariableIndex,MOI.ScalarAffineFunction{T}}} ,
2646
- :: Type{T} ,
2647
- ) where {T}
2648
- return MOI. ScalarAffineFunction{T}
2649
- end
2650
-
2651
- function promote_operation (
2652
- :: typeof (/ ),
2653
- :: Type{T} ,
2654
- :: Type{MOI.ScalarQuadraticFunction{T}} ,
2655
- :: Type{T} ,
2656
- ) where {T}
2657
- return MOI. ScalarQuadraticFunction{T}
2658
- end
2659
-
2660
2506
function operate! (:: typeof (/ ), :: Type{T} , f:: MOI.VariableIndex , α:: T ) where {T}
2661
2507
return operate (/ , T, f, α)
2662
2508
end
@@ -2826,14 +2672,6 @@ function fill_variables(
2826
2672
return
2827
2673
end
2828
2674
2829
- function promote_operation (
2830
- :: typeof (vcat),
2831
- :: Type{T} ,
2832
- :: Type{<:Union{MOI.VariableIndex,MOI.VectorOfVariables}} ...,
2833
- ) where {T}
2834
- return MOI. VectorOfVariables
2835
- end
2836
-
2837
2675
function operate (
2838
2676
:: typeof (vcat),
2839
2677
:: Type{T} ,
@@ -3094,19 +2932,6 @@ function vectorize(
3094
2932
return MOI. VectorQuadraticFunction (quadratic_terms, affine_terms, constant)
3095
2933
end
3096
2934
3097
- function promote_operation (:: typeof (vcat), :: Type{T} , :: Type{T} ...) where {T}
3098
- return Vector{T}
3099
- end
3100
-
3101
- # TODO Remove `<:Number` when we drop Julia v1.1.1, otherwise it gives a `StackOverflowError`
3102
- function promote_operation (
3103
- :: typeof (vcat),
3104
- :: Type{T} ,
3105
- :: Union{Type{T},Type{<:AbstractVector{T}}} ...,
3106
- ) where {T<: Number }
3107
- return Vector{T}
3108
- end
3109
-
3110
2935
# TODO Remove `<:Number` when we drop Julia v1.1.1, it's needed for disambiguation
3111
2936
function operate (
3112
2937
:: typeof (vcat),
@@ -3116,35 +2941,6 @@ function operate(
3116
2941
return vcat (funcs... )
3117
2942
end
3118
2943
3119
- function promote_operation (
3120
- :: typeof (vcat),
3121
- :: Type{T} ,
3122
- :: Type {
3123
- <: Union {
3124
- ScalarAffineLike{T},
3125
- MOI. VectorOfVariables,
3126
- MOI. VectorAffineFunction{T},
3127
- },
3128
- }. .. ,
3129
- ) where {T}
3130
- return MOI. VectorAffineFunction{T}
3131
- end
3132
-
3133
- function promote_operation (
3134
- :: typeof (vcat),
3135
- :: Type{T} ,
3136
- :: Type {
3137
- <: Union {
3138
- ScalarQuadraticLike{T},
3139
- MOI. VectorOfVariables,
3140
- MOI. VectorAffineFunction{T},
3141
- MOI. VectorQuadraticFunction{T},
3142
- },
3143
- }. .. ,
3144
- ) where {T}
3145
- return MOI. VectorQuadraticFunction{T}
3146
- end
3147
-
3148
2944
function operate (
3149
2945
:: typeof (vcat),
3150
2946
:: Type{T} ,
@@ -3495,22 +3291,6 @@ end
3495
3291
3496
3292
Base. real (f:: Union{MOI.VariableIndex,MOI.VectorOfVariables} ) = f
3497
3293
3498
- function promote_operation (
3499
- :: typeof (imag),
3500
- :: Type{T} ,
3501
- :: Type{MOI.VariableIndex} ,
3502
- ) where {T}
3503
- return MOI. ScalarAffineFunction{T}
3504
- end
3505
-
3506
- function promote_operation (
3507
- :: typeof (imag),
3508
- :: Type{T} ,
3509
- :: Type{MOI.VectorOfVariables} ,
3510
- ) where {T}
3511
- return MOI. VectorAffineFunction{T}
3512
- end
3513
-
3514
3294
function operate (:: typeof (imag), :: Type{T} , f:: MOI.VectorOfVariables ) where {T}
3515
3295
return zero_with_output_dimension (
3516
3296
MOI. VectorAffineFunction{T},
@@ -3539,17 +3319,6 @@ Base.conj(f::Union{MOI.VariableIndex,MOI.VectorOfVariables}) = f
3539
3319
3540
3320
# # Matrix operations
3541
3321
3542
- function promote_operation (
3543
- :: typeof (* ),
3544
- :: Type{T} ,
3545
- :: Type{<:Diagonal{T}} ,
3546
- :: Type{F} ,
3547
- ) where {T,F}
3548
- S = scalar_type (F)
3549
- U = promote_operation (* , T, T, S)
3550
- return promote_operation (vcat, T, U)
3551
- end
3552
-
3553
3322
function operate_term (:: typeof (* ), D:: Diagonal , term:: MOI.VectorAffineTerm )
3554
3323
return MOI. VectorAffineTerm (
3555
3324
term. output_index,
0 commit comments