rcognita.simulator.Simulator¶
- class rcognita.simulator.Simulator(sys_type, closed_loop_rhs, sys_out, state_init, disturb_init=[], action_init=[], t0=0, t1=1, dt=0.01, max_step=0.005, first_step=1e-06, atol=1e-05, rtol=0.001, is_disturb=0, is_dyn_ctrl=0)¶
Class for simulating closed loops (system-controllers).
- sys_type¶
Type of system by description:
diff_eqn
: differential equation \(\mathcal D state = f(state, u, q)\)discr_fnc
: difference equation \(state^+ = f(state, u, q)\)discr_prob
: by probability distribution \(X^+ \sim P_X(state^+| state, u, q)\)- Type
: string
- where¶
- \(state\) : state\(u\) : input\(q\) : disturbance
- closed_loop_rhs¶
Right-hand side description of the closed-loop system. Say, if you instantiated a concrete system (i.e., as an instance of a subclass of
system
class with concreteclosed_loop_rhs
method) asmy_sys
, this could be justmy_sys.closed_loop_rhs
.- Type
: function
- sys_out¶
System output function. Same as above, this could be, say,
my_sys.out
.- Type
: function
- is_dyn_ctrl¶
If 1, the controller (a.k.a. agent) is considered as a part of the full state vector.
- Type
: 0 or 1
- state_init, disturb_init, action_init
Initial values of the (open-loop) system state, disturbance and input.
- Type
: vectors
- t0, t1, dt
Initial, final times and time step size
- Type
: numbers
- max_step, first_step, atol, rtol
Parameters for an ODE solver (used if
sys_type
isdiff_eqn
).- Type
: numbers
See also
systems
module- __init__(sys_type, closed_loop_rhs, sys_out, state_init, disturb_init=[], action_init=[], t0=0, t1=1, dt=0.01, max_step=0.005, first_step=1e-06, atol=1e-05, rtol=0.001, is_disturb=0, is_dyn_ctrl=0)¶
- Parameters
sys_type (: string) –
Type of system by description:
diff_eqn
: differential equation \(\mathcal D state = f(state, u, q)\)discr_fnc
: difference equation \(state^+ = f(state, u, q)\)discr_prob
: by probability distribution \(X^+ \sim P_X(state^+| state, u, q)\)where –
\(state\) : state\(u\) : input\(q\) : disturbanceclosed_loop_rhs (: function) – Right-hand side description of the closed-loop system. Say, if you instantiated a concrete system (i.e., as an instance of a subclass of
System
class with concreteclosed_loop_rhs
method) asmy_sys
, this could be justmy_sys.closed_loop_rhs
.sys_out (: function) – System output function. Same as above, this could be, say,
my_sys.out
.is_dyn_ctrl (: 0 or 1) – If 1, the controller (a.k.a. agent) is considered as a part of the full state vector.
state_init (: vectors) – Initial values of the (open-loop) system state, disturbance and input.
disturb_init (: vectors) – Initial values of the (open-loop) system state, disturbance and input.
action_init (: vectors) – Initial values of the (open-loop) system state, disturbance and input.
t0 (: numbers) – Initial, final times and time step size
t1 (: numbers) – Initial, final times and time step size
dt (: numbers) – Initial, final times and time step size
max_step (: numbers) – Parameters for an ODE solver (used if
sys_type
isdiff_eqn
).first_step (: numbers) – Parameters for an ODE solver (used if
sys_type
isdiff_eqn
).atol (: numbers) – Parameters for an ODE solver (used if
sys_type
isdiff_eqn
).rtol (: numbers) – Parameters for an ODE solver (used if
sys_type
isdiff_eqn
).
Methods
__init__
(sys_type, closed_loop_rhs, sys_out, …)- param sys_type
Type of system by description:
get_sim_step_data
()Collect current simulation data: time, system state and output, and, for completeness, full closed-loop state.
reset
()sim_step
()Do one simulation step and update current simulation data (time, system state and output).