Simulation#
Simulation involves evaluating a trajectory of the system starting from an initial state \(x_0\).
See also
Simulation Documentation for more details about all objects and routines.
Simulation Examples for demonstrations.
Execution#
Simulation of an inclusion problem \(0 \in \sum_{i=1}^s F_i(\beta^*)\) with \(\beta^* \in \R^d\) is conducted by the alg_sim object.
The arguments to alg_sim are the system (sys), and the dimensionality of \(\beta\) in simulation (d). The output of an algorithm execution for \(T\) time steps is obtained through the sim() command,
1simulator = alg_sim(sys, d);
2sim_result = simulator.sim(T);
By default, algorithm execution will occur with \(x_0=0\), and \(w_p = 0\). The sampler field of alg_sim allows for random generation and external signals. The attributes of sampler are:
Field |
Description |
|---|---|
|
Initial Condition |
|
Performance Input |
|
Initial value of problem-dependent parameters |
|
Subsequent value of problem-dependent parameters |
The output of alg_sim.sim(T) is an alg_sim_out object. The fields of alg_sim_out include
|
state of network |
|
input to operators |
|
output from operators |
|
state of controller |
|
performance output |
|
performance input |
|
time index |
|
output to controller |
|
input from controller |
|
function value |
|
optimality error \(\norm{\sum_{i=1}^s w^i_k}_2\) |
|
consensus error \(\norm{z^i_k - z^i_{\text{average}, k}}_2\) |
|
subsystem for switched systems |
|
problem-dependent parameters |
Each field of alg_sim_out is a numeric or cell array with last dimension indexed by \(k \in \{1, \ldots, T\}\).
Plotting#
The alg_plotter class accepts a result from simulation, and can then plot any signal stored in alg_sim_out.
A plot of the signals (\(w\), \(z\), \(u\), \(y\)) is accomplished by performing
1plt = alg_plotter(sim_result);
2fig = plt.plot({"w", "z", "u", "y"});
The figure number can be set by an optional second argument to plot()
1plt = alg_plotter(sim_result);
2fig1 = plt.plot({"w", "z", "res_w", "res_z"}, 100); %figure number 100
3fig2 = plt.plot({"xi", "u", "y"}, 101); %figure number 101
Helper functions of alg_plotter include
Method |
Description |
Plotted Signals |
|---|---|---|
|
States, oracles, and convergence |
( |
|
States, oracles, convergence, function values |
( |
|
oracles, convergence |
( |
See also
Plotting contains a full list of helper functions and more details.
Details of Execution#
The System sys executed by first interconnecting the Network and Controller, and then interconnecting the possibly nonlinear operator \(F\). This is mathematically described by
Well-posedness requires that the map \(H: = (F^{-1} - \Dcl{zw})^{-1}\) is globally defined and continuous.
The closed loop state \(x\) is the concatenation \(x = [x^N, x^c]\).
alg_sim execution using sim() requires well-posedness and a block-triangular information structure (closed loop \(\Dcl\) matrix).
Under these conditions, the System can be partitioned as
The iterative loop for algorithm simulation is to evaluate the equations for each \(k \in \N\)
The operator \(H_i: = (F_i^{-1} - \Dcl_{zw, ii})^{-1}\) can be evaluated using the op_sim methods
Evaluation |
Used Method |
Condition |
Operation \(z_i \mapsto H_i z_i\) |
|---|---|---|---|
Explicit |
|
\(\Dcl_{zw, ii} = 0\) |
\(z \mapsto F_i(z_i)\), |
Implicit |
|
\(\Dcl_{zw,ii}\) is invertible |
\(z_i \mapsto \Dcl_{zw, ii}^{-1} [z - (I - \Dcl_{zw, ii} F_i)^{-1}(z_i)]\) |