Title: | Control Theory Methods for Networks |
---|---|
Description: | Implementations of various control theory methods for use in brain and psychological networks. Contains controllability statistics from Pasqualetti, Zampieri & Bullo (2014) <doi:10.1109/TCNS.2014.2310254>, optimal control algorithms from Lewis, Vrabie & Syrmos (2012, ISBN:978-0-470-63349-6), and various utilities. |
Authors: | Teague R. Henry |
Maintainer: | Teague R. Henry <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1 |
Built: | 2024-11-22 06:53:13 UTC |
Source: | CRAN |
Calculates the average control centrality of a system defined by .
ave_control_centrality(A)
ave_control_centrality(A)
A |
An n by n matrix. |
A length n vector of average control centrality measures (Pasqualetti et al. 2014), representing the overall average control of each node in the system.
Pasqualetti F, Zampieri S, Bullo F (2014). “Controllability Metrics, Limitations and Algorithms for Complex Networks.” In 2014 American Control Conference, 3287–3292. ISBN 978-1-4799-3274-0 978-1-4799-3272-6 978-1-4799-3271-9, doi:10/ggkhs9.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) ave_control_centrality(A)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) ave_control_centrality(A)
average_control
- Average controllability as defined by the trace of the GramianA commonly used measure (Pasqualetti et al. 2014) of the overall controllability of a system defined by .
average_control(A, B)
average_control(A, B)
A |
A |
B |
A |
Trace of the infinite time Gramian.
Pasqualetti F, Zampieri S, Bullo F (2014). “Controllability Metrics, Limitations and Algorithms for Complex Networks.” In 2014 American Control Conference, 3287–3292. ISBN 978-1-4799-3274-0 978-1-4799-3272-6 978-1-4799-3271-9, doi:10/ggkhs9.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) average_control(A, B)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) average_control(A, B)
Compute the (infinite time) controllability Gramian for the discrete linear time invariant system described by .
The infinite time controllability Gramian is the solution to the discrete Lyapunov equation
, while the finite time Gramian for time
is
control_gramian(A, B, t = NA)
control_gramian(A, B, t = NA)
A |
|
B |
|
t |
Either NA for infinite time Gramian, or a positive non-zero integer. Defaults to NA. |
The infinite time or finite time controllability Gramian
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) #Infinite time Gramian W_inf = control_gramian(A, B) #4 time Gramian W_4 = control_gramian(A,B,4)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) #Infinite time Gramian W_inf = control_gramian(A, B) #4 time Gramian W_4 = control_gramian(A,B,4)
Given a system dynamics , control input matrix
, final state weighting matrix
,
intermediate state weighting matrix sequence
, and cost matrix sequence
,
calculates the Kalman gain sequence to minimize the LQR by time
.
See section 2.2 of (Lewis et al. 2012) for details.
control_scheme_DLI_freestate(t_max, A, B, S, Q_seq, R_seq)
control_scheme_DLI_freestate(t_max, A, B, S, Q_seq, R_seq)
t_max |
Required. An integer total number of time points to determine the trajectory over |
A |
Required. A |
B |
Required. A |
S |
A |
Q_seq |
A list of |
R_seq |
A list of |
A list containing an entry labeled gain_seq
containing either 1 or t_max - 1
Kalman gain matrices and an entry labeled cost_func
which contains a LQR function.
Lewis FL, Vrabie DL, Syrmos VL (2012). Optimal Control, 3rd ed edition. Wiley, Hoboken. ISBN 978-0-470-63349-6.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) #Normalize rows to sum to 1 A = solve(diag(rowSums(A))) %*% A B = S = Q_seq = R_seq = diag(3) CS = control_scheme_DLI_freestate(100, A, B, S, Q_seq, R_seq)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) #Normalize rows to sum to 1 A = solve(diag(rowSums(A))) %*% A B = S = Q_seq = R_seq = diag(3) CS = control_scheme_DLI_freestate(100, A, B, S, Q_seq, R_seq)
This function is designed to work with control_scheme objects generated by control_scheme_DLI_freestate
In future versions of netcontrol
this function will be used to simulate any control trajectory.
For general details on control theory trajectories, see (Lewis et al. 2012).
control_traj(t_max, x_0, A, B, theta = NA, gamma = NA, control_scheme, delta = NA, d_nosign = F, d_toggle = F, upper_bounds = NA, lower_bounds = NA, u_pos = F)
control_traj(t_max, x_0, A, B, theta = NA, gamma = NA, control_scheme, delta = NA, d_nosign = F, d_toggle = F, upper_bounds = NA, lower_bounds = NA, u_pos = F)
t_max |
Required. An integer total number of time points to determine the trajectory over |
x_0 |
Required. A |
A |
Required. A |
B |
Required. A |
theta |
Optional. A |
gamma |
Optional. A |
control_scheme |
Required. A list containing an entry labeled |
delta |
Optional. A vector of length 2, where the first entry contains the point of saturation for control inputs, and the second entry contains the saturation value for control inputs. |
d_nosign |
Optional. Boolean. If |
d_toggle |
Optional. Boolean. If |
upper_bounds |
Optional. A |
lower_bounds |
Optional. A |
u_pos |
Optional. Boolean. If |
CAUTION: Use of saturation parameters and/or bound parameters delta, d_nosign, d_toggle, upper.bound, lower.bound, u.pos
leads to estimates of the optimal trajectory to be sub-optimal, as the Kalman gain calculations do not take any of those restrictions into account.
This functionality will be added later, and this caution statement removed at that time.
A list containing 4 entries: a 't_max x p' state value matrix, a 't_max x p' observation matrix, a 't_max-1 x q' matrix of control inputs and a 't_max' length vector of cost function values.
Lewis FL, Vrabie DL, Syrmos VL (2012). Optimal Control, 3rd ed edition. Wiley, Hoboken. ISBN 978-0-470-63349-6..
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) #Normalize rows to sum to 1 A = solve(diag(rowSums(A))) %*% A B = S = Q_seq = R_seq = diag(3) CS = control_scheme_DLI_freestate(100, A, B, S, Q_seq, R_seq) traj = control_traj(100, rep(100,3), A, B, control_scheme = CS) #First 5 control inputs print(head(traj[[3]]))
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) #Normalize rows to sum to 1 A = solve(diag(rowSums(A))) %*% A B = S = Q_seq = R_seq = diag(3) CS = control_scheme_DLI_freestate(100, A, B, S, Q_seq, R_seq) traj = control_traj(100, rep(100,3), A, B, control_scheme = CS) #First 5 control inputs print(head(traj[[3]]))
Computes the solution of using the Barraud 1977 approach, adapted from Datta 2004.
This implementation is equivalent to the Matlab implementation of dylap.
dlyap(A, W)
dlyap(A, W)
A |
|
W |
|
The solution to the above Lyapunov equation.
Barraud A (1977). “A numerical algorithm to solve $ A^TXA - X = Q$.” IEEE Transactions on Automatic Control, 22(5), 883–885. ISSN 0018-9286, doi:10/fr9gs7, http://ieeexplore.ieee.org/document/1101604/.
Datta BN (2004). Numerical methods for linear control systems: design and analysis. Elsevier Academic Press, Amsterdam ; Boston. ISBN 978-0-12-203590-6.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) C = matrix(c(-2,-8,11,2,-6,13,-3,-5,-2), 3,3) X = dlyap(t(A), C) print(sum(abs(A %*% X %*% t(A) - X + C)))
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) C = matrix(c(-2,-8,11,2,-6,13,-3,-5,-2), 3,3) X = dlyap(t(A), C) print(sum(abs(A %*% X %*% t(A) - X + C)))
A commonly used measure of the overall controllability of a system defined by .
inv_average_control(A, B)
inv_average_control(A, B)
A |
A |
B |
A |
Trace of the inverse infinite time Gramian.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) inv_average_control(A, B)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) inv_average_control(A, B)
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 (Lewis et al. 2012)
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.
LQR(X, U, S, Q_seq, R_seq, eval = TRUE)
LQR(X, U, S, Q_seq, R_seq, eval = TRUE)
X |
A |
U |
A |
S |
A |
Q_seq |
A list of |
R_seq |
A list of |
eval |
Boolean, if |
A function or a length numeric vector
Lewis FL, Vrabie DL, Syrmos VL (2012). Optimal Control, 3rd ed edition. Wiley, Hoboken. ISBN 978-0-470-63349-6.
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])
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])
Calculates the modal control (Hamdan and Nayfeh 1989) of a system defined by .
modal_control(A, B)
modal_control(A, B)
A |
A |
B |
A |
A matrix representing the control of the
th mode by the mth control input.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) modal_control(A, B)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) B = diag(3) modal_control(A, B)
Calculates the modal control centrality of a system defined by .
modal_control_centrality(A)
modal_control_centrality(A)
A |
An n by n matrix. |
A length n vector of modal control centrality measures(Pasqualetti et al. 2014), representing the overall modal control of each node in the system.
Pasqualetti F, Zampieri S, Bullo F (2014). “Controllability Metrics, Limitations and Algorithms for Complex Networks.” In 2014 American Control Conference, 3287–3292. ISBN 978-1-4799-3274-0 978-1-4799-3272-6 978-1-4799-3271-9, doi:10/ggkhs9.
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) modal_control_centrality(A)
A = matrix(c(0,-3,-2,2,-2,1,-1,2,-1), 3,3) modal_control_centrality(A)