model.schedule

Classes

StopTime

This represents a stop time of a Trip at a Station.

TripType

The type of a trip. Used in analysis to determine schedule efficiency.

Trip

A trip is a single run of a bus on a Route. It is part of a Rotation.

Rotation

A rotation is a sequence of trips that are performed by a bus in a single day.

Functions

check_trip_before_commit(_, __, target)

check_rotation_before_commit(_, __, target)

A Rotation needs to be contiguous in time and space

Module Contents

class model.schedule.StopTime

Bases: eflips.model.Base

This represents a stop time of a Trip at a Station.

A trip is not guaranteed to have any stop times, but it either has none (with only the arrival and departure times set) or every stop (including the first and last) has a stop time.

__tablename__ = 'StopTime'
id: sqlalchemy.orm.Mapped[int]

The unique identifier of the battery type. Auto-incremented.

scenario_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the scenario. Foreign key to Scenario.id.

scenario: sqlalchemy.orm.Mapped[eflips.model.Scenario]

The scenario.

station_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the station. Foreign key to Station.id.

station: sqlalchemy.orm.Mapped[eflips.model.Station]

The station.

trip_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the trip. Foreign key to Trip.id.

trip: sqlalchemy.orm.Mapped[Trip]

The trip.

arrival_time: sqlalchemy.orm.Mapped[datetime.datetime]

The arrival time at the station.

dwell_duration: sqlalchemy.orm.Mapped[datetime.timedelta]

The dwell time at the station. Defaults to 0 if unspecified.

__table_args__
__repr__()
Return type:

str

class model.schedule.TripType(*args, **kwds)

Bases: enum.Enum

The type of a trip. Used in analysis to determine schedule efficiency.

EMPTY

= deadheading, vehicle if repositioning itself for passenger trip

PASSENGER

Passengers may board

class model.schedule.Trip

Bases: eflips.model.Base

A trip is a single run of a bus on a Route. It is part of a Rotation.

__tablename__ = 'Trip'
id: sqlalchemy.orm.Mapped[int]

The unique identifier of the battery type. Auto-incremented.

scenario_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the scenario. Foreign key to Scenario.id.

scenario: sqlalchemy.orm.Mapped[eflips.model.Scenario]

The scenario.

route_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the route. Foreign key to Route.id.

route: sqlalchemy.orm.Mapped[eflips.model.Route]

The route.

rotation_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the rotation. Foreign key to Rotation.id.

rotation: sqlalchemy.orm.Mapped[Rotation]

The rotation.

departure_time: sqlalchemy.orm.Mapped[datetime.datetime]

The departure time at the first station.

This must be specified as full seconds, e.g. the “microseconds” part of the datetime must be 0. This is done because lots of later parts of the code assume that the departure time is a full second.

arrival_time: sqlalchemy.orm.Mapped[datetime.datetime]

The arrival time at the last station.

This must be specified as full seconds, e.g. the “microseconds” part of the datetime must be 0. This is done because lots of later parts of the code assume that the departure time is a full second

trip_type

The type of the trip. Either EMPTY or PASSENGER.

loaded_mass

The level of load on the bus in kg.

stop_times: sqlalchemy.orm.Mapped[List[StopTime]]
stations

The stations of the trip.

events: sqlalchemy.orm.Mapped[List[eflips.model.Event]]
__table_args__
__repr__()
Return type:

str

model.schedule.check_trip_before_commit(_, __, target)
  1. Check if the arrival or departure time is not a full second, warn the user if it is not.

2) Before a trip is flushed to the database, if it has stop times: - Ensure that the arrival time of the first stop time is the departure time of the trip - Ensure that the arrival time of the last stop time is the arrival time of the trip - Ensure that the first stop time is the first stop of the route - Ensure that the last stop time is the last stop of the route

Parameters:
  • target (Trip) – a trip

  • _ (Any)

  • __ (Any)

Returns:

Nothing. Raises an exception if something is wrong.

Return type:

None

class model.schedule.Rotation

Bases: eflips.model.Base

A rotation is a sequence of trips that are performed by a bus in a single day.

__tablename__ = 'Rotation'
id: sqlalchemy.orm.Mapped[int]

The unique identifier of the battery type. Auto-incremented.

scenario_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the scenario. Foreign key to Scenario.id.

scenario: sqlalchemy.orm.Mapped[eflips.model.Scenario]

The scenario.

vehicle_type_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the vehicle type. Foreign key to VehicleType.id.

vehicle_type: sqlalchemy.orm.Mapped[eflips.model.VehicleType]

The vehicle type.

vehicle_id: sqlalchemy.orm.Mapped[int]

The unique identifier of the vehicle. Foreign key to Vehicle.id.

vehicle: sqlalchemy.orm.Mapped[eflips.model.Vehicle]
allow_opportunity_charging: sqlalchemy.orm.Mapped[bool]

Whether opportunity charging is permitted. To actually charge, the vehicle type must support opportunity charging.

name: sqlalchemy.orm.Mapped[str]

The name of the rotation.

trips: sqlalchemy.orm.Mapped[List[Trip]]

A list of trips.

__repr__()
Return type:

str

model.schedule.check_rotation_before_commit(_, __, target)

A Rotation needs to be contiguous in time and space - the end station of a trip must be the start station of the next trip - the departure time of a trip must be after the arrival time of the previous trip

Parameters:
  • target (Rotation) – A Rotation object

  • _ (Any)

  • __ (Any)

Returns:

Nothing. Raises an exception if something is wrong.

Return type:

None