Agents#

class airlift.envs.agents.EnvAgent(start_airport, routemap=None, plane_type=None, max_loaded_weight=None, malfunction_generator=None, priority=1)

Represents an individual agent (airplane) in an environment.

property current_cargo_weight: float

Gets the total current cargo weight on an airplane

Returns:

current cargo weight on an airplane

load_cargo(cargo_to_load: Collection[Cargo], elapsed_steps, warnings: List[str])

Checks to make sure airplane can load cargo and loads the cargo. Also checks to ensure that cargo is assigned to that airplane

Parameters:
  • cargo_to_load – A list that contains the Cargo to load

  • warnings – List of warnings issued by the environment. Ex: If an action is given to an unavailable route

step(action, cargo_by_id: Dict[int, Cargo], elapsed_time) Tuple[dict, List[str]]

Updates the agent’s state.

Parameters:
  • action – A dictionary of actions that contains ‘process’, ‘cargo_to_load’, ‘cargo_to_unload’ and ‘destination’

  • cargo_by_id – Dictionary containing the Cargo and CargoID

Returns:

Tuple containing updated_action and warnings. The updated action contains any updated events to the action dict that occurred during the time step. The warnings list contains any issues with the current actions given.

try_to_process(cargo_to_load: Collection[Cargo], cargo_to_unload: Collection[Cargo], elapsed_time, warnings: List[str]) bool

Checks to see if the current airport has capacity. If there is capacity the agent will go into the PROCESSING state and the processing timer will be updated. The agent is added to the airports capacity.

Parameters:
  • cargo_to_load – A set that contains cargo to load

  • cargo_to_unload – A set that contains cargo to unload

Returns:

Boolean, if successfully load or unloaded cargo

unload_cargo(cargo_to_unload: Collection[Cargo], warnings: List[str])

Does a check to ensure the correct cargo is being unloaded and removes the cargo from the airplane.

Parameters:
  • cargo_to_unload – A list that contains the Cargo to unload

  • warnings – List of warnings issued by the environment. Ex: If an action is given to an unavailable route

class airlift.envs.agents.PlaneState(value)

Enumeration that defines the states an agent can be in

  • 0:

    Waiting - airplane is waiting to process at an airport

  • 1:

    Processing - airplane is refueling and loading/unloading cargo

  • 2:

    Moving - Airplane is in flight to its destination

  • 3:

    Ready for takeoff - airplane is ready for takeoff once it is given a destination