@@ -49,6 +49,18 @@ function _is_psd(
4949 end
5050end
5151
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+ """
5264quadform (x:: Value , A:: AbstractExpr ; assume_psd = false ) = x' * A * x
5365
5466function quadform (x:: AbstractExpr , A:: Value ; assume_psd = false )
@@ -68,24 +80,22 @@ function quadform(x::AbstractExpr, A::Value; assume_psd = false)
6880 return factor * square (norm2 (P * x))
6981end
7082
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
7386
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
7590
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- """
8391function 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+ )
91101end
0 commit comments