@@ -49,6 +49,18 @@ function _is_psd(
49
49
end
50
50
end
51
51
52
+ """
53
+ quadform(x::AbstractExpr, A::AbstractExpr; assume_psd=false)
54
+
55
+ Represents `x' * A * x` where either:
56
+
57
+ * `x` is a vector-valued variable and `A` is a positive semidefinite or
58
+ negative semidefinite matrix (and in particular Hermitian or real symmetric).
59
+ If `assume_psd=true`, then `A` will be assumed to be positive semidefinite.
60
+ Otherwise, `Convex._is_psd` will be used to check if `A` is positive
61
+ semidefinite or negative semidefinite.
62
+ * or `A` is a matrix-valued variable and `x` is a vector.
63
+ """
52
64
quadform (x:: Value , A:: AbstractExpr ; assume_psd = false ) = x' * A * x
53
65
54
66
function quadform (x:: AbstractExpr , A:: Value ; assume_psd = false )
@@ -68,24 +80,22 @@ function quadform(x::AbstractExpr, A::Value; assume_psd = false)
68
80
return factor * square (norm2 (P * x))
69
81
end
70
82
71
- """
72
- quadform(x::AbstractExpr, A::AbstractExpr; assume_psd=false)
83
+ function quadform (x:: Constant , A:: AbstractExpr ; assume_psd = false )
84
+ return quadform (evaluate (x), A; assume_psd)
85
+ end
73
86
74
- Represents `x' * A * x` where either:
87
+ function quadform (x:: AbstractExpr , A:: Constant ; assume_psd = false )
88
+ return quadform (x, evaluate (A); assume_psd)
89
+ end
75
90
76
- * `x` is a vector-valued variable and `A` is a positive semidefinite or
77
- negative semidefinite matrix (and in particular Hermitian or real symmetric).
78
- If `assume_psd=true`, then `A` will be assumed to be positive semidefinite.
79
- Otherwise, `Convex._is_psd` will be used to check if `A` is positive
80
- semidefinite or negative semidefinite.
81
- * or `A` is a matrix-valued variable and `x` is a vector.
82
- """
83
91
function quadform (x:: AbstractExpr , A:: AbstractExpr ; assume_psd = false )
84
- if vexity (x) == ConstVexity ()
85
- return quadform (evaluate (x), A; assume_psd = assume_psd)
86
- elseif vexity (A) == ConstVexity ()
87
- return quadform (x, evaluate (A); assume_psd = assume_psd)
88
- else
89
- error (" either `x` or `A` must be constant in `quadform(x, A)`" )
90
- end
92
+ return error (
93
+ " Convex.jl v0.13.5 introduced the ability to use `fix!`ed variables " *
94
+ " in `quadform`. However, this did not consider the case that the " *
95
+ " value of `fix!`ed variables is changed between solves. Due to the " *
96
+ " risk that this may silently produce incorrect solutions, this " *
97
+ " behavior has been removed. Use `evaluate(H)` to obtain the value of " *
98
+ " a fixed variable. If the value changes between solves, rebuild the " *
99
+ " problem for the change to take effect." ,
100
+ )
91
101
end
0 commit comments