starling_sim.basemodel.output.kpis

Module Contents

Classes

KPI

Generic structure of a KPI class

MoveKPI

This KPI evaluates the distance and spent time for each one of the simulation modes

WaitKPI

This KPI evaluates the time spent waiting

GetVehicleKPI

This KPI evaluates the number of vehicle uses

SuccessKPI

This KPI evaluates the number of failed/successful requests

StaffOperationKPI

This KPI evaluates the number of staff operations

OccupationKPI

This KPI evaluates the empty and full time and distance

StationOccupationKPI

This KPI evaluates the time spent in the empty and full states (of a station),

VehicleOccupationKPI

This KPI evaluates the time and distance in the empty and full states (of vehicle),

ChargeKPI

This KPI evaluates the trips's boards and un-boards

PublicTransportChargeKPI

This KPI evaluates the public transport trips's boards and un-boards

ServiceKPI

This KPI describes the service time of a vehicle.

TransferKPI

This KPI lists the transfers realised by a user,

DestinationReachedKPI

This KPI evaluates the destination reach time

LeaveSimulationKPI

This KPI evaluates the cause of the simulation leave.

Functions

get_route_id_of_trip(trips, trip_id, event)

get_direction_of_trip(trips, trip_id)

get_route_short_name_of_trip(trips, routes, trip_id)

get_stop_id_of_event(event)

class starling_sim.basemodel.output.kpis.KPI(export_keys: list = None)

Bases: abc.ABC

Generic structure of a KPI class

Its sub-classes compute and update specific indicator from given events

property export_keys
PROFILE_COMPATIBILITY = True
KEY_ID = 'agentId'
_init_keys()
new_indicator_dict()

Evaluate indicators starting values

Returns:

dict with keys in self.keys

setup(kpi_output, simulation_model)

Setup method called during simulation setup.

After calling this method, the keys attribute should be set.

Parameters:
  • kpi_output – parent KpiOutput

  • simulation_model

_indicators_setup(simulation_model)

Setup attributes that need the simulation model to be initialised.

evaluate_for_agent(agent)

Evaluate KPI indicators for the given agent.

Indicators are evaluated by browsing the agent’s events in chronological and updating values according to the KPI description.

Parameters:

agent – Traced agent

reset_for_agent(agent)

Reset indicators of the KPI in preparation of a new evaluation.

Parameters:

agent

end_of_events()

Execute certain actions when the event list evaluation has ended.

end_of_profile_range()

Add a new row with indicators of current interval and jump to the next one.

new_kpi_row()

Add a new row to the output table.

Indicators are reset after their data has been added to a row.

is_in_later_profile(timestamp)

Test if time profiling is enabled and if the given timestamp is in a later profile interval.

Parameters:

timestamp

Returns:

boolean indicating if timestamp in a later profile interval

update_from_event(event: starling_sim.basemodel.trace.events.Event)

Update indicators based on the event contents.

If event is in a later profile interval, jump to the right interval before processing the event.

Parameters:

event – Event instance

add_proportioned_indicators(event)
abstract evaluate_indicators_on_profile_range(event, current_timestamp, duration_on_range)

Evaluate and update KPI indicators for the given event on the specified time interval.

Parameters:
  • event

  • current_timestamp

  • duration_on_range

Returns:

abstract _update(event)

Update the kpi values according to the event content and the agent.

Parameters:

event – processed event

Returns:

class starling_sim.basemodel.output.kpis.MoveKPI(**kwargs)

Bases: KPI

This KPI evaluates the distance and spent time for each one of the simulation modes

SUFFIX_KEY_DISTANCE = '{mode}Distance'
SUFFIX_KEY_TIME = '{mode}Time'
_indicators_setup(simulation_model)

Setup attributes that need the simulation model to be initialised.

_init_keys()
_update(event)

Update the kpi values according to the event content and the agent.

Parameters:

event – processed event

Returns:

evaluate_indicators_on_profile_range(event, current_timestamp, duration_on_range)

Evaluate and update KPI indicators for the given event on the specified time interval.

Parameters:
  • event

  • current_timestamp

  • duration_on_range

Returns:

class starling_sim.basemodel.output.kpis.WaitKPI(export_keys: list = None)

Bases: KPI

This KPI evaluates the time spent waiting

KEY_WAIT = 'waitTime'
_update(event)

Update the kpi values according to the event content and the agent.

Parameters:

event – processed event

Returns:

evaluate_indicators_on_profile_range(event, current_timestamp, duration_on_range)

Evaluate and update KPI indicators for the given event on the specified time interval.

Parameters:
  • event

  • current_timestamp

  • duration_on_range

Returns:

class starling_sim.basemodel.output.kpis.GetVehicleKPI(export_keys: list = None)

Bases: KPI

This KPI evaluates the number of vehicle uses

KEY_GET_VEHICLE = 'nbGetVehicle'
_update(event)

Add a new use for each GetVehicleEvent

Parameters:

event

class starling_sim.basemodel.output.kpis.SuccessKPI(export_keys: list = None)

Bases: KPI

This KPI evaluates the number of failed/successful requests

KEY_FAILED_GET = 'nbFailedGet'
KEY_SUCCESS_GET = 'nbSuccessGet'
KEY_FAILED_PUT = 'nbFailedPut'
KEY_SUCCESS_PUT = 'nbSuccessPut'
KEY_FAILED_REQUEST = 'nbFailedRequest'
KEY_SUCCESS_REQUEST = 'nbSuccessRequest'
_init_keys()
_update(event)

Add request events according to their success

Parameters:

event

class starling_sim.basemodel.output.kpis.StaffOperationKPI(export_keys: list = None)

Bases: KPI

This KPI evaluates the number of staff operations

KEY_FAILED_GET_STAFF = 'nbFailedGetStaff'
KEY_SUCCESS_GET_STAFF = 'nbSuccessGetStaff'
KEY_FAILED_PUT_STAFF = 'nbFailedPutStaff'
KEY_SUCCESS_PUT_STAFF = 'nbSuccessPutStaff'
_init_keys()
_update(event)

Add operations to the total

Parameters:

event

class starling_sim.basemodel.output.kpis.OccupationKPI(**kwargs)

Bases: KPI

This KPI evaluates the empty and full time and distance and the stock relative time/distance

KEY_EMPTY_TIME = 'emptyTime'
KEY_EMPTY_DISTANCE = 'emptyDistance'
KEY_FULL_TIME = 'fullTime'
KEY_FULL_DISTANCE = 'fullDistance'
KEY_STOCK_TIME = 'stockTime'
KEY_STOCK_DISTANCE = 'stockDistance'
KEY_MAX_STOCK = 'maxStock'
_init_keys()
reset_for_agent(agent)

Reset indicators of the KPI in preparation of a new evaluation.

Parameters:

agent

get_capacity(element)

Get the capacity of the agent, according to its type.

Parameters:

element

Returns:

agent’s capacity

get_initial_stock(element)

Get the initial stock of the agent, according to its type.

Parameters:

element

Returns:

agent’s initial stock

end_of_profile_range()

Add a new row with indicators of current interval and jump to the next one.

update_timestamp(timestamp)
add_to_stock(value, timestamp)

Update the full and empty time and distance counts, according to the previous stock value, then updates the stock and time.

Parameters:
  • value – stock change (negative for stock loss)

  • timestamp – timestamp of the stock change event

_update(event)

Update the stock and time counts from traced events

Parameters:

event

class starling_sim.basemodel.output.kpis.StationOccupationKPI(**kwargs)

Bases: OccupationKPI

This KPI evaluates the time spent in the empty and full states (of a station), and the stock relative time spent in the station

_init_keys()
new_indicator_dict()

Evaluate indicators starting values

Returns:

dict with keys in self.keys

get_capacity(element)

Get the capacity of the agent, according to its type.

Parameters:

element

Returns:

agent’s capacity

get_initial_stock(element)

Get the initial stock of the agent, according to its type.

Parameters:

element

Returns:

agent’s initial stock

_update(event)

Update the stock and time counts from request events

Parameters:

event

class starling_sim.basemodel.output.kpis.VehicleOccupationKPI(**kwargs)

Bases: OccupationKPI

This KPI evaluates the time and distance in the empty and full states (of vehicle), and a passenger relative distance and time.

reset_for_agent(agent)

Reset indicators of the KPI in preparation of a new evaluation.

Parameters:

agent

end_of_profile_range()

Add a new row with indicators of current interval and jump to the next one.

get_capacity(element)

Get the capacity of the agent, according to its type.

Parameters:

element

Returns:

agent’s capacity

get_initial_stock(element)

Get the initial stock of the agent, according to its type.

Parameters:

element

Returns:

agent’s initial stock

_update(event)

Update the stock and time/distance counts from get/leave vehicle and move events

Parameters:

event

evaluate_indicators_on_profile_range(event, current_timestamp, duration_on_range)

Evaluate and update KPI indicators for the given event on the specified time interval.

Parameters:
  • event

  • current_timestamp

  • duration_on_range

Returns:

class starling_sim.basemodel.output.kpis.ChargeKPI(non_empty_only=True, **kwargs)

Bases: KPI

This KPI evaluates the trips’s boards and un-boards

PROFILE_COMPATIBILITY = False
KEY_TRIP_ID = 'tripId'
KEY_TIME = 'time'
KEY_STOP_ID = 'stopId'
KEY_BOARD_TYPE = 'boardType'
KEY_VALUE = 'value'
new_indicator_dict()

Evaluate indicators starting values

Returns:

dict with keys in self.keys

_init_keys()
end_of_events()

Execute certain actions when the event list evaluation has ended.

_update(event)

Add stop information to the list

Parameters:

event

update_stop_information(event)

Update the indicator with the information common to dropoffs and pickups.

Parameters:

event

class starling_sim.basemodel.output.kpis.PublicTransportChargeKPI(**kwargs)

Bases: ChargeKPI

This KPI evaluates the public transport trips’s boards and un-boards

KEY_ROUTE_ID = 'routeId'
KEY_TRIP_DIRECTION = 'tripDirection'
_init_keys()
_indicators_setup(simulation_model)

Setup attributes that need the simulation model to be initialised.

update_stop_information(event)

Update the indicator with the information common to dropoffs and pickups.

Parameters:

event

class starling_sim.basemodel.output.kpis.ServiceKPI(**kwargs)

Bases: KPI

This KPI describes the service time of a vehicle.

KEY_SERVICE_DURATION = 'serviceDuration'
reset_for_agent(agent)

Reset indicators of the KPI in preparation of a new evaluation.

Parameters:

agent

end_of_profile_range()

Add a new row with indicators of current interval and jump to the next one.

update_indicator(timestamp)
_update(event)

Update the kpi values according to the event content and the agent.

Parameters:

event – processed event

Returns:

start_service(timestamp)
close_service(timestamp)
class starling_sim.basemodel.output.kpis.TransferKPI(**kwargs)

Bases: KPI

This KPI lists the transfers realised by a user, with additional information such as walk distance and duration, wait duration, from/to trip/stop

PROFILE_COMPATIBILITY = False
KEY_WALK_DIST = 'walkDistance'
KEY_WALK_DURATION = 'walkDuration'
KEY_WAIT_TIME = 'waitTime'
KEY_FROM_ROUTE = 'fromRoute'
KEY_FROM_TRIP = 'fromTrip'
KEY_FROM_STOP = 'fromStop'
KEY_TO_ROUTE = 'toRoute'
KEY_TO_TRIP = 'toTrip'
KEY_TO_STOP = 'toStop'
_indicators_setup(simulation_model)

Setup attributes that need the simulation model to be initialised.

_init_keys()
end_of_events()

Execute certain actions when the event list evaluation has ended.

new_indicator_dict()

Evaluate indicators starting values

Returns:

dict with keys in self.keys

_update(event)

Update the kpi values according to the event content and the agent.

Parameters:

event – processed event

Returns:

reset_variables()
write_variables()
class starling_sim.basemodel.output.kpis.DestinationReachedKPI(export_keys: list = None)

Bases: KPI

This KPI evaluates the destination reach time

KEY_DESTINATION_REACHED = 'destinationReachedTime'
new_indicator_dict()

Evaluate indicators starting values

Returns:

dict with keys in self.keys

_update(event)

Add total wait duration of the request

Parameters:

event

class starling_sim.basemodel.output.kpis.LeaveSimulationKPI(export_keys: list = None)

Bases: KPI

This KPI evaluates the cause of the simulation leave.

KEY_LEAVE_SIMULATION = 'leaveSimulation'
new_indicator_dict()

Evaluate indicators starting values

Returns:

dict with keys in self.keys

_update(event)

Add the cause of the LeaveSimulationEvent.

Parameters:

event

starling_sim.basemodel.output.kpis.get_route_id_of_trip(trips, trip_id, event)
starling_sim.basemodel.output.kpis.get_direction_of_trip(trips, trip_id)
starling_sim.basemodel.output.kpis.get_route_short_name_of_trip(trips, routes, trip_id)
starling_sim.basemodel.output.kpis.get_stop_id_of_event(event)