pynrp.simulation module

An interface to launch or control a simulation instance.

class Simulation(http_client, config, vc)[source]

Bases: object

Provides an interface to launch or control a simulation instance.

add_state_machine(state_machine_name, state_machine)[source]

Adds a new State Machine to the simulation.

Parameters
  • state_machine_name – A string containing the name of the state machine to be added.

  • state_machine – A string containing the new state machine code.

add_transfer_function(transfer_function)[source]

Adds a new transfer function to the simulation.

Parameters

transfer_function – A string containing the new transfer function code.

delete_state_machine(state_machine_name)[source]

Deletes a state machine.

Parameters

state_machine_name – A string containing the name of the state machine to be deleted.

delete_transfer_function(transfer_function_name)[source]

Deletes a transfer function.

Parameters

transfer_function_name – A string containing the name of the transfer function to be deleted.

edit_brain(brain_script)[source]

Edits the brain script defined in the simulation and keeps the defined populations. Calling this method will not change brain populations.

Parameters

brain_script – A string containing the new pyNN script.

edit_populations(populations)[source]

Modifies the neuron populations and replaces old population names with new ones in the transfer functions automatically.

Parameters

populations – A dictionary containing neuron indices and is indexed by population names. Neuron indices could be defined by individual integers, lists of integers or python slices. Python slices are defined by a dictionary containing the ‘from’, ‘to’ and ‘step’ values.

edit_state_machine(state_machine_name, state_machine)[source]

Modify an existing State Machine by updating the script.

Parameters
  • state_machine_name – A string containing the name of the state machine to be edited.

  • state_machine – A string containing the new state machine code.

edit_transfer_function(transfer_function_name, transfer_function)[source]

Modify an existing Transfer Function by updating the script.

Parameters
  • transfer_function_name – A string containing the name of the transfer function to be edited.

  • transfer_function – A string containing the new transfer function code.

get_brain()[source]

Gets the brain script.

get_csv_last_run_file(file_name)[source]

Retrieves a csv file content for the last simulation run.

Parameters

file_name – The name of csv file for which to retrieve the content.

get_populations()[source]

Gets the Neuron populations defined within the brain as a dictionary indexed by population names.

get_state()[source]

Returns the current simulation state.

get_state_machine(state_machine_name)[source]

Gets the State Machine body for a given state machine name.

Parameters

state_machine_name – A string containing the name of the state machine.

get_transfer_function(transfer_function_name)[source]

Gets the transfer function body for a given transfer function name.

Parameters

transfer_function_name – A string containing the name of the transfer function.

launch(experiment_id, experiment_conf, server, reservation, cloned=True, storage_token=None, brain_processes=1, profiler='disabled', recordingPath=None)[source]

Attempt to launch and initialize the given experiment on the given servers. This should not be directly invoked by users, use the VirtualCoach interface to validate and launch a simulation.

Parameters
  • experiment_id – A string representing the short name of the experiment to be launched (e.g. ExDTemplateHusky).

  • experiment_conf – A string representing the configuration file for the experiment.

  • server – A string representing the name of the server to try to launch on.

  • reservation – A string representing a cluster resource reservation (if any).

  • cloned – Boolean. True if the experiment is cloned.

  • storage_token – A string representing the token for storage authorization.

  • brain_processes – Number of mpi processes in the brain simulation.

  • profiler – profiler option. Possible values are: disabled, cle_step and cprofile.

  • recordingPath – (optional) the path to a the zip of a recording.

pause()[source]

Attempt to pause the simulation by transitioning to the “paused” state.

pause_recording()[source]

Pause recording.

print_state_machines()[source]

Prints a list of the state-machine names defined in the experiment.

print_transfer_functions()[source]

Prints a list of the transfer-function names defined in the experiment.

register_status_callback(callback)[source]

Register a status message callback to be called whenever a simulation status message is received. This functionality is only available on installations with native ROS support.

Parameters

callback – The callback function to be invoked.

reset(reset_type)[source]

Resets the simulation according to the type the user wants. Successful reset will pause the simulation.

Parameters

reset_type – The reset type the user wants to be performed. Possible values are full, robot_pose and world. The possible reset types are stored in the config file.

save_brain()[source]

Saves the current brain script and populations to the storage

save_state_machines()[source]

Saves the current state machines to the storage

save_transfer_functions()[source]

Saves the current transfer functions to the storage

save_world()[source]

Saves the current sdf world to the storage

start()[source]

Attempt to start the simulation by transitioning to the “started” state.

start_recording()[source]

Start recording.

stop()[source]

Attempt to stop the simulation by transitioning to the “stopped” state.

stop_recording(save, description=None)[source]

Stop recording and save the file if save is True. An optional description can be passed.

Parameters
  • save – True if the recording needs to be saves.

  • description – If provided a description of recording to be saved.

unpause_recording()[source]

Un-pause recording.