hive.agents.agent module

class hive.agents.agent.Agent(observation_space, action_space, id=0)[source]

Bases: ABC, Registrable

Base class for agents. Every implemented agent should be a subclass of this class.

Parameters
  • observation_space (gym.Space) – Observation space for agent.

  • action_space (gym.Space) – Action space for agent.

  • id – Identifier for the agent.

property id
abstract act(observation, agent_traj_state)[source]

Returns an action for the agent to perform based on the observation.

Parameters
  • observation – Current observation that agent should act on.

  • agent_traj_state – Contains necessary state information for the agent to process current trajectory. This should be updated and returned.

Returns

  • Action for the current timestep.

  • Agent trajectory state.

abstract update(update_info, agent_traj_state)[source]

Updates the agent.

Parameters
  • update_info (dict) – Contains information from the environment agent needs to update itself.

  • agent_traj_state – Contains necessary state information for the agent to process current trajectory. This should be updated and returned.

Returns

Agent trajectory state.

train()[source]

Changes the agent to training mode.

eval()[source]

Changes the agent to evaluation mode

abstract save(dname)[source]

Saves agent checkpointing information to file for future loading.

Parameters

dname (str) – directory where agent should save all relevant info.

abstract load(dname)[source]

Loads agent information from file.

Parameters

dname (str) – directory where agent checkpoint info is stored.

classmethod type_name()[source]
Returns

“agent”