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
  • sys (InputOutputSystem) – I/O system for which the cost function is being defined.

  • Q (2D array_like) – Weighting matrix for state cost. Dimensions must match system state.

  • R (2D array_like) – Weighting matrix for input cost. Dimensions must match system input.

  • x0 (1D array) – Nominal value of the system state (for which cost should be zero).

  • u0 (1D array) – Nominal value of the system input (for which cost should be zero).

Returns

cost_fun – 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).

Return type

callable