question about the linear objective term in the MPC example #540
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think you are referring to the example here. The objective function in that example (both linear and quadratic parts) is # - quadratic objective
P = sparse.block_diag([sparse.kron(sparse.eye(N), Q), QN,
sparse.kron(sparse.eye(N), R)], format='csc')
# - linear objective
q = np.hstack([np.kron(np.ones(N), -Q@xr), -QN@xr, np.zeros(N*nu)]) The objective function is minimizing the (weighted) square of the difference between There will also be constant part |
Beta Was this translation helpful? Give feedback.
-
You can't include an objective term that maximizes the distance between vectors since that would be non-convex. The solver will throw an error saying that your objective function has a negative eigenvalue. The solver will also not support a log barrier function -- only (convex) quadratic objectives are supported. If you really want either of those things then you need a solver like IPOPT that supports non-convex problems. |
Beta Was this translation helpful? Give feedback.
I think you are referring to the example here.
The objective function in that example (both linear and quadratic parts) is
The objective function is minimizing the (weighted) square of the difference between$x$ and some reference state $x_r$ , the latter of which is not a decision variable. Terms like $\frac{1}{2}(x-x_r)^TQ(x-x_r)$ therefore have both a quadratic component $\frac{1}{2}x^TQx$ and a linear part $\frac{1}{2}(x_r^TQx + x^TQx_r) = (Qx_r)^Tx$ .…