Simulation

Simulation Module

grsim.grsim(aut_list, aut_trans_dict={}, env_states=[{}], num_it=20, deterministic_env=True, graph_vis=False, destfile='sim_graph.gexf', label_vars=None, delay=2, vis_depth=3)[source]

Simulate an execution of the given list of automata and return a sequence of automaton states. If graph_vis is True, simulate the automata live in Gephi.

For the simplest use case, try something like:
aut_states_list = grsim([aut], env_states=[{state: var...}])

Note that ‘aut_states_list’ is composed of (autID, autState) tuples, ‘aut’ is enclosed in a list, and ‘env_states’ is a list of state dictionaries.

Arguments:

  • aut_list – a list of Automaton objects containing the automata

    generated from jtlvint.synthesize or jtlv.computeStrategy function.

  • aut_trans_dict – a dictionary in which the keys correspond to exit states

    of automata and the values are the entry states of the next automata. Both keys and values are tuples in the following format:

    (AutomatonID, AutomatonState)

    where ‘AutomatonID’ is an integer corresponding to the index of the current automaton and ‘AutomatonState’ is the current automaton state.

  • env_states – a list of dictionaries of environment state, specifying

    the sequence of environment states. If the length of this sequence is less than num_it, then this function will automatically pick the environment states for the rest of the execution.

  • num_it – the number of iterations.

  • deterministic_env – specify whether this function will choose

    the environment state deterministically.

  • graph_vis – specify whether to visualize the simulation in Gephi.

  • destfile – for graph visualization, the string name of the desired

    destination ‘.gexf’ file.

  • label_vars – for graph visualization, a list of the names of the system

    or environment variables to be encoded as labels.

  • delay – for graph visualization, the time between simulation steps.

  • vis_depth – for graph visualization, set the number of previous states to

    continue displaying.

Return: List of automaton states, corresponding to a sequence of simulated transitions. Each entry will be formatted as follows:

(AutomatonID, AutomatonState)

as described above under ‘aut_trans_dict’.

class grsim.visualizeGraph(aut_list, destfile, label_vars=None)[source]

Open Gephi (a graph visualization application) and stream a live automaton simulation to it.

Arguments:

  • aut_list – a list of Automaton objects.

  • destfile – the string name of a ‘.gexf’ graph file to be opened

    in Gephi.

  • label_vars – a list of the names of the system or environment

    variables to be encoded as labels.

Fields:

  • gs – a Gephi streaming server.
  • gephi – an asynchronous process running Gephi.
update(active_nodes)[source]

Update the graph by streaming the changed active nodes.

Arguments:

  • active_nodes – an ordered list of nodes that should be active.

Return: (nothing)

grsim.writeSimStatesToFile(states, file, verbose=0)[source]

Write a simulation trace (sequence of states) to a text file.

Arguments:

  • states – a list of tuples of automaton states, formatted as:

    (AutomatonID, AutomatonState)

    where ‘AutomatonID’ is an integer corresponding to the index of the current automaton and ‘AutomatonState’ is the current automaton state.

  • file – the string name of the desired destination file.

Return: (nothing)

grsim.writeStatesToFile(aut_list, destfile, aut_states_list=[], label_vars=None)[source]

Write the states and transitions from a list of automata to a ‘.gexf’ graph file. If a list of simulated states is given, record the sequence of traversed states.

Arguments:

  • aut_list – a list of Automaton objects.

  • destfile – the string name of the desired destination file.

  • aut_states_list – a list of tuples of automaton states, formatted as:

    (AutomatonID, AutomatonState)

    where ‘AutomatonID’ is an integer corresponding to the index of the current automaton and ‘AutomatonState’ is the current automaton state.

  • label_vars – a list of the names of the system or environment

    variables to be encoded as labels.

Return: (nothing)

Table Of Contents

Previous topic

Planner Synthesis

This Page