1-
2- # destructive_add!
3- # ------------------------------------------------------------------------------
4-
5- # destructive_add!{C}(ex::Number, c::Number, x::Number) = ex + c*x
6-
7- #=
8- Number
9- =#
10-
11- JuMP. destructive_add! (ex:: Number , c:: C , x:: ParameterRef ) where C<: Number = PAE {C} (GAEv {C} (ex),GAEp {C} (zero (C), x => c))
12- JuMP. destructive_add! (ex:: Number , x:: ParameterRef , c:: C ) where C<: Number = JuMP. destructive_add! (ex, c, x)
13- JuMP. destructive_add! (ex:: Number , c:: C , x:: PAE ) where C<: Number = PAE {C} (JuMP. destructive_add! (ex, c, x. v), JuMP. destructive_add! (0.0 , c, x. p))
14-
15- #=
16- VariableRef
17- =#
18-
19- JuMP. destructive_add! (ex:: JuMP.VariableRef , c:: C , x:: ParameterRef ) where C<: Number = PAE {C} (GAEv {C} (zero (C), ex => one (C)), GAEp {C} (zero (C), x => c))
20- JuMP. destructive_add! (ex:: JuMP.VariableRef , x:: ParameterRef , c:: C ) where C<: Number = JuMP. destructive_add! (ex, c, x)
21-
22- #=
23- Parameter
24- =#
25-
26- JuMP. destructive_add! (ex:: ParameterRef , c:: Number , x:: Number ) = c * x + ex
27-
28- JuMP. destructive_add! (ex:: ParameterRef , c:: C , x:: JuMP.VariableRef ) where C<: Number = PAE {C} (GAEv {C} (zero (C), x => c), GAEp {C} (zero (C), ex => one (C)))
29- JuMP. destructive_add! (ex:: ParameterRef , x:: JuMP.VariableRef , c:: Number ) = JuMP. destructive_add! (ex, c, x)
30-
31- JuMP. destructive_add! (ex:: ParameterRef , c:: C , x:: ParameterRef ) where {C<: Number } = PAE {C} (zero (GAEv{C}), GAEp {C} (zero (C), ex => one (C), x => c))
32- JuMP. destructive_add! (ex:: ParameterRef , x:: ParameterRef , c:: C ) where {C<: Number } = JuMP. destructive_add! (ex, x, c)
33-
34- #=
35- GAEp
36- =#
37-
38- JuMP. destructive_add! (aff:: GAEp{C} , c:: Number , x:: Number ) where {C} = PAE {C} (GAEv {C} (c* x), aff)
39-
40- JuMP. destructive_add! (aff:: GAEp{C} , x:: Union{JuMP.VariableRef, GAEv{C}} , c:: Number ) where C = JuMP. destructive_add! (aff, c, x)
41- JuMP. destructive_add! (aff:: GAEp{C} , c:: Number , x:: Union{JuMP.VariableRef, GAEv{C}} ) where C = PAE {C} (GAEv {C} (zero (C), x => convert (C, c)), aff)
42-
43- #=
44- GAEv
45- =#
46-
47- JuMP. destructive_add! (aff:: GAEv{C} , x:: Union{ParameterRef, GAEp{C}} , c:: Number ) where C = JuMP. destructive_add! (aff, c, x)
48- JuMP. destructive_add! (aff:: GAEv{C} , c:: Number , x:: Union{ParameterRef, GAEp{C}} ) where C = PAE {C} (aff, GAEp {C} (zero (C), x => convert (C, c)))
49-
50- #=
51- PAE
52- =#
53-
54- JuMP. destructive_add! (aff:: PAE , x:: Union{JuMP.VariableRef, GAEv, ParameterRef, GAEp} , c:: Number ) = JuMP. destructive_add! (aff, c, x)
55- function JuMP. destructive_add! (aff:: PAE , c:: Number , x:: Union{JuMP.VariableRef, GAEv} )
1+ function MA. mutable_operate! (op:: MA.AddSubMul , aff:: PAE , x:: Union{JuMP.VariableRef, GAEv, ParameterRef, GAEp} , c:: Number )
2+ return MA. mutable_operate! (op, aff, c, x)
3+ end
4+ function MA. mutable_operate! (op:: MA.AddSubMul , aff:: PAE , c:: Number , x:: Union{JuMP.VariableRef, GAEv} )
565 if ! iszero (c)
57- aff . v = JuMP . destructive_add! ( aff. v, c, x)
6+ MA . mutable_operate! (op, aff. v, c, x)
587 end
59- aff
8+ return aff
609end
61- function JuMP . destructive_add! ( aff:: PAE , c:: Number , x:: Union{ParameterRef, GAEp} )
10+ function MA . mutable_operate! (op :: MA.AddSubMul , aff:: PAE , c:: Number , x:: Union{ParameterRef, GAEp} )
6211 if ! iszero (c)
63- aff . p = JuMP . destructive_add! ( aff. p, c, x)
12+ MA . mutable_operate! (op, aff. p, c, x)
6413 end
65- aff
14+ return aff
6615end
67- function JuMP . destructive_add! ( aff:: PAE , c:: Number , x:: Number )
68- if ! iszero (c)
69- aff. v = JuMP . destructive_add! ( aff. v, c, x)
16+ function MA . mutable_operate! (op :: MA.AddSubMul , aff:: PAE , c:: Number , x:: Number )
17+ if ! iszero (c) && ! iszero (x)
18+ aff. v = MA . mutable_operate! (op, aff. v, c, x)
7019 end
71- aff
20+ return aff
7221end
7322
7423function JuMP. add_to_expression! (aff:: PAE , other:: Number )
9544function JuMP. add_to_expression! (lhs_aff:: PAE , rhs_aff:: PAE )
9645 JuMP. add_to_expression! (lhs_aff. p, rhs_aff. p)
9746 JuMP. add_to_expression! (lhs_aff. v, rhs_aff. v)
98- end
47+ end
0 commit comments