rlevator package

Submodules

rlevator.actions module

class rlevator.actions.Action(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

There are 6 actions that an elevator can take:

  1. Do nothing and remain at the current floor.

  2. Attempt to move up a floor. This does nothing if at the elevator’s maximum floor.

  3. Attempt to move down a floor. This does nothing if at the elevator’s minimum floor.

  4. Load as many passengers will fit in the remaining elevator capacity from the current floor that are in the up queue starting from the first arrived passengers onward.

  5. Load as many passengers will fit in the remaining elevator capacity from the current floor that are in the down queue starting from the first arrived passengers onward.

  6. Unload any passengers that have their destination floor as the elevator’s current floor.

LOAD_DOWN = 4
LOAD_UP = 3
MOVE_DOWN = 2
MOVE_UP = 1
UNLOAD = 5
WAIT = 0

rlevator.arrivals module

rlevator.building module

rlevator.elevator module

class rlevator.elevator.Elevator(start_floor, capacity, min_floor, max_floor)[source]

Bases: object

Elevator representation. Holds passengers and is aware of its own capacity and general passenger destinations. The destinations are stored as a list of booleans, with true meaning that the button has been clicked and the corresponding passengers have not yet been unloaded onto that destination floor.

Floor zero is the bottom floor and it goes up from there.

Parameters:
  • start_floor – int Floor number in the building that the elevator starts off at.

  • min_floor – int Bottom floor that the elevator can access

  • max_floor – int Top floor that the elevator can access

  • capacity – int Total number of passengers that the elevator can hold at any one time.

available_capacity()[source]

Return the number of available spots for passengers on the elevator.

count_correct_move_passengers(start_floor)[source]

After an elevator has moved, count the number of passengers for which the move was in the correct direction for their destination.

Parameters:

start_floor – int The previous floor that the elevator was on before moving. The end floor is the current floor the elevator is on since it has already moved.

Returns:

int

Number of passengers with the desired move direction.

count_incorrect_move_passengers(start_floor)[source]

After an elevator has moved, count the number of passengers for which the move was in the incorrect direction for their destination.

Parameters:

start_floor – int The previous floor that the elevator was on before moving. The end floor is the current floor the elevator is on since it has already moved.

Returns:

int

Number of passengers with the incorrect move direction.

destination_floors()[source]

Returns a list of the floors that are destinations for at least one passenger.

get_capacity()[source]
get_count_passengers()[source]
get_current_floor()[source]
get_destination_bool_list()[source]

Returns the boolean list of destination identifiers for each floor starting at the min_floor and working upwards

get_floor_bounds()[source]
get_max_floor()[source]
get_min_floor()[source]
increment_passenger_steps()[source]

Calls the step increment function for every passenger in the elevator with the argument that they are in the elevator so the wait age is not increased.

load_passengers(passengers)[source]

Load new passengers onto the elevator and update destinations.

Parameters:

passengers – List[Passenger]

move(floor_diff)[source]

Move the elevator based on the floor difference provided. Clamp the floor number to be between the minimum and maximum floors. This means that if the move function is called and it would be out of bounds, it only goes to the limit and will not exceed.

TODO: decide if we want to raise and exception for out of bounds errors

Parameters:

floor_diff – int Integer number of floors to move based on floor number.

unload_passengers()[source]

Identify all passengers with the current floor as the destination and return them in a list. Set the passengers list to be the remaining passengers that were not returned. There is no limit to the number of passengers that can be unloaded at one time.

Returns:

List[Passenger]

rlevator.environment module

rlevator.passenger module

class rlevator.passenger.Passenger(start_step, start_floor, destination_floor, max_wait_steps=50)[source]

Bases: object

Passenger representation.

Parameters:
  • start_step – int Step number in the environment in which the passenger was created

  • start_floor – int Initial floor number for which they arrived at the elevator

  • destination_floor – int Floor number they are trying to reach through the elevator

  • max_wait_steps – int Maximum number of steps they are willing to wait before they use the stairs

get_age()[source]
get_destination_floor()[source]
get_start_floor()[source]
get_wait()[source]
increment_step(in_elevator=False)[source]

Increases the passenger step tracking upon environment step completion. Age increases every step, but wait only increases if they aren’t on an elevator.

Parameters:

in_elevator – bool Flag as to whether or not the passenger is currently inside an elevator or waiting on a floor queue.

moved_correct_direction(elevator_start_floor, elevator_end_floor)[source]

Determines if the elevator moved in direction of the passenger’s destination floor or at least remained on the same floor. Main use is in the reward function to penalize elevators that move in the opposite direction of any passenger’s destinations.

Ideally, it should not be called is the start and end floors are equal, and the elevator did not move. However, in the case it does, not moving is counted as an incorrect direction since it made no progress.

Parameters:
  • elevator_start_floor – int Original floor that the elevator was located on before the step

  • elevator_end_floor – int Original floor that the elevator was located on before the step

Returns:

bool

Returns true if the end floor is closer to the destination floor than the original start floor of the elevator

reached_destination(elevator_floor)[source]
reached_max_wait()[source]

Determines if the passenger has reached their max number of wait steps. TODO: determine if the passenger leaves or increases reward penalty when this condition is met. Could be an environment configuration

Module contents