control.optimal.quadratic_cost

control.optimal.quadratic_cost(sys, Q, R, x0=0, u0=0)[source]

Create quadratic cost function.

Returns a quadratic cost function that can be used for an optimal control problem. The cost function is of the form

cost = (x - x0)^T Q (x - x0) + (u - u0)^T R (u - u0)

Parameters
sysInputOutputSystem

I/O system for which the cost function is being defined.

Q2D array_like

Weighting matrix for state cost. Dimensions must match system state.

R2D array_like

Weighting matrix for input cost. Dimensions must match system input.

x01D array

Nominal value of the system state (for which cost should be zero).

u01D array

Nominal value of the system input (for which cost should be zero).

Returns
cost_funcallable

Function that can be used to evaluate the cost at a given state and input. The call signature of the function is cost_fun(x, u).