automata4cps.automata

The module provides a class Automaton which inherits CPSComponent and implements the dynamics of different kinds of automata.

Authors: - Nemanja Hranisavljevic, hranisan@hsu-hh.de, nemanja@ai4cps.com - Tom Westermann, tom.westermann@hsu-hh.de, tom@ai4cps.com

class automata4cps.automata.Automaton(states: list = None, events: list = None, transitions: list = None, unknown_state: str = 'raise', id='', initial_q=(), super_states=(), decision_states=(), **kwargs)

Bases: CPSComponent

Automaton class is the main class for modeling various kinds of hybrid systems.

add_event(new_event)
Add multiple events to the automaton.
param new_event:

Events to be added.

add_initial_state(states)
Add initial state(s) of the automaton.
param states:

States to add.

add_single_transition(s, d, e, timing=None)
add_state(new_state, **kwargs)
Add state to the automaton.
param new_state:

State to be added.

add_state_data(s: str, d: object)
Add state data to a state s the automaton.
param s:

state

param d:

data to be added to s

return:

add_states_from(new_state, **kwargs)
Add multiple states to the automaton.
param new_state:

States to be added.

add_transition(s, d, e, **other)
Add multiple transition.
param list_of_tuples:

List of transitions in the form (source_state, destination_state, event, …<unused>…).

add_transitions_from(list_of_tuples, **other)
Add multiple transition.
param list_of_tuples:

List of transitions in the form (source_state, destination_state, event, …<unused>…).

discrete_event_dynamics(q, e, xt, xk, p) tuple

The function updates system state given the event e. :param event: :return:

property discrete_states
flow(q, p, x, u)
Flow equation gives derivative of the continuous variables.
param q:

Current discrete state of the model.

param p:

Stochastic parameters generated on entry to state current_q.

param x:

Current continuous state of the model.

param u:

Calculated internal i signals.

return:

Derivative of the continuous state x.

get_alternatives(state, system_state)
get_num_in(q)

Returns the number of in transitions of state q in the automaton. :return: number of transitions.

get_num_out(q)

Returns the number of out transitions of state q in the automaton. :return: number of transitions.

get_transition(s, d=None, e=None, if_more_than_one='raise')

Get all transitions with source state s, destination state __d. In case when e is provided, the returned list contains transitions where event is e.

param if_more_than_one:

param s:

Source state.

param d:

Destination state.

param e:

Event.

return:

get_transitions()
in_transitions(s)
Get all incoming transitions of state s.
param s:

return:

inv(t, q, x, y, z, p)
Invariants.
param t:

param q:

param x:

param y:

param z:

param p:

is_decision(state, overall_state)
is_deterministic()
is_state(q)
is_transition(s, d, e)
Check if a transition (s,d,e) exists in the automaton.
param s:

Source.

param d:

Destination.

param e:

Event.

return:

learn_transition_probabilities()
property num_modes

Returns the number of modes in the automaton. :return: number of states.

num_occur(q, e)
num_timings()
property num_transitions

Returns the number of transitions in the automaton. :return: number of transitions.

out_transitions(s, event=None)
Get all outgoing transitions of state s.
param event:

param s:

return:

predict_state(data_collection, time_col_name, discr_col_names)
print_state(v)

Prints outgoing transitions of a state v.

Parameters:

v (state)

Returns:

Description of the outgoing transitions of the state.

Return type:

String

remove_rare_transitions(min_p=0, min_num=0, keep_from_initial=False, keep_states=False, keep=None)
remove_state(s)
remove_transition(source, dest)

Remove the transition(s) from source to dest. :param source: :param dest: :return:

rename_events(prefix='e_')

Rename events to become e_0, e_1… The old id is stored in the field ‘old_symbol’ of the state data.

sim_continuous(q, x, y)
Simulates continuous behavior.
param q:

param x:

param y:

return:

simulate(finish_time=100, current_q=None)

Simulates behaviour of the system. :param finish_time: Time when simulation finishes. :return: generated data.

property state
state_is_deterministic(q)
step(x0, t, u)
Simulates one time step of continuous behavior from t to t+dt. Underlying function is solve_ivp with method is ‘RK23’.
param x0:

Initial state vector.

param t:

Time at start of the step simulation.

param u:

Arguments passed…..

return:

Time t+dt, value of state at t+dt

timed_transition(q, xc, xd, y, use_observed_timings=False)
property transitions
update_timing_boundaries(source, destination, event, newTiming)

Classes