Learn R Programming

netcontrol (version 0.1)

LQR: Linear Quadratic Regulator

Description

Creates a function that can be used to calculate the cumulative value of the LQR for any set of states and control inputs. By setting eval to True, the LQR is immediately calculated. See lewisOptimalControl2012netcontrol

NOTE: LQR functions, as they are calculated forward in time, go to 0 by the maximum time regardless of input. This is expected behavior, but that does make using the LQR value to evaluate control efficacy somewhat difficult.

Usage

LQR(X, U, S, Q_seq, R_seq, eval = TRUE)

Arguments

X

A \(t x p\) matrix of state values

U

A \(t-1 x q\) matrix of control inputs`

S

A \(p x p\) final state weighting matrix

Q_seq

A list of \(t\) \(p x p\) intermediate state weighting matrices or a single \(p x p\) intermediate state weighting matrix

R_seq

A list of \(t\) \(q x q\) intermediate cost matrices or a single \(q x q\) cost matrix

eval

Boolean, if FALSE returns a function, if TRUE calculates the LQR series

Value

A function or a \(t\) length numeric vector

References

lewisOptimalControl2012netcontrol

Examples

Run this code
# NOT RUN {
X = matrix(1, 100, 3)
U = matrix(-1, 99, 3)
S = Q_seq = R_seq = diag(3)

print(LQR(X,U, S, Q_seq, R_seq)[1:5])

# }

Run the code above in your browser using DataLab