Skip to content

question about the linear objective term in the MPC example #540

Discussion options

You must be logged in to vote

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 $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$.…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Jushan-Randy-Chen
Comment options

Answer selected by Jushan-Randy-Chen
Comment options

You must be logged in to vote
1 reply
@Jushan-Randy-Chen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants