palaestrai.simulation package#

Submodules#

palaestrai.simulation.vanilla_sim_controller module#

class palaestrai.simulation.vanilla_sim_controller.VanillaSimController(rungov_connection, sim_connection, agent_conductor_ids, environment_conductor_ids, agents, termination_conditions, mode)[source]#

Bases: SimulationController

This is our vanilla controller. With this simulation, environment and agent(s) work alternately and not in parallel. It is not a continuous simulation. After each simulation step (independent if done by environment or agent) the Termination Condition is called.

access_list(sensor_list, actuator_list)[source]#

access_list takes a list of sensors and actuators and checks if they are part of the available sensors/actuators. If that is the case they will be returned.

Parameters:
  • sensor_list (list) – a list with sensor IDs.

  • actuator_list (list) – a list with actuator IDs.

Returns:

  • sensor_list (list)

  • actuator_list (list)

static agent_update(responses: list) list[source]#

This method combines all actuator_information of all Agents and creates on list.

Parameters:

AgentUpdateResponses (responses = List of) –

Return type:

actuators which is a list of actuator_information

collect_actuators(agent_responses: list)[source]#

collect_actuators takes a list of agent_responses and combines all available actuators to one list.

Parameters:

agent_responses (list[agent_responses]) –

Returns:

actuators

Return type:

list[actuator]

async continue_simulation(termination, rewards, additional_results)[source]#
async get_agent_updates(rewards, env_termination, simtimes)[source]#

Fetches actions from agents.

This method sends an AgentUpdateRequest to each agent and collects the responses, which will be returned.

Parameters:
  • rewards (List[RewardInformation]) – List of environment rewards

  • env_termination (bool) – True if environment has terminated, False if not

  • simtimes (Dict[str, palaestrai.types.SimTime]) – Contains time values from the environment. It maps environment UIDs to SimTime.

Returns:

List of response messages containing information about the agent’s actions

Return type:

List[AgentUpdateResponse]

async get_env_update(env, actuators)[source]#

Sends an EnvironmentUpdateRequest to one env and collects the Response. The vanilla simController sends all actuators to all envs and the env has to select the own actuators. A access list could be needed if two envs of the same type are used. :param env: :type env: id of the environment :param actuators: :type actuators: list of actuatorinformation

Returns:

response

Return type:

EnvironmentUpdateResponse

static handle_env_reset(responses: list)[source]#

This method will process a list of environment reset responses and will combine the information to combined lists.

Parameters:

EnvironmentResetResponse (responses = list of) –

Return type:

sensors = list of all sensor_information of all available environments

static handle_env_update(responses: List[EnvironmentUpdateResponse])[source]#

This method will process a list of environment update responses and will combine the information to combined lists. Currently the termination variable is global because we assume, that the run terminates if at least one environment is env terminates.

Parameters:

EnvironmentUpdateResponse (responses = list of) –

Returns:

  • sensors = list of all sensor_information of all available environments

  • rewards = list of all environment rewards

  • termination = boolean which is true if one environment has terminated

async perform_restart()[source]#
async send_termination_request(rewards: list, additional_results)[source]#
async simulation()[source]#

This is the abstract method implementation of the simulation task. The vanilla sim controller simulation start by asking all environments for sensor information. These information will be sent to the agent(s) which will respond which their actuator-values. From there on it will be a ping pong between environment(s) and agent(s). All available information will be exchanged. Both, environment as well as agent information, can be used for the termination.

async simulation_shutdown(env_termination: bool, rewards: list, additional_results)[source]#

This method will be called when the simulation has terminated it will send a SimControllerTerminationRequest to the runGov. The RunGov will respond and will tell if it will be a complete or partial shutdown. The complete shutdown includes the conductors while a partial shutdown is a reset which just deletes the muscle(s) and env(s) :param env_termination: :type env_termination: bool if the environment has terminated :param rewards: :type rewards: list of rewards to show the current performance :param additional_results: :type additional_results: for any additional information

palaestrai.simulation.vanilla_simcontroller_termination_condition module#

class palaestrai.simulation.vanilla_simcontroller_termination_condition.VanillaSimControllerTerminationCondition(*args, **kwargs)[source]#

Bases: EnvironmentTerminationCondition

Module contents#