Skip to content

RM Action Base Classes

RmAction

RmAction(
    *,
    carrier: str = "",
    minimum_sample: int = 10,
    dcps: Collection[int] = (),
)

Bases: ABC

A revenue management action.

Each RmAction is configured to run on a specific carrier, and on a set of days prior to departure. Actions can be scheduled to run on specific days prior to departure (DCPs), or daily, or on other frequencies.

requires class-attribute instance-attribute

requires: set[str] = set()

produces class-attribute instance-attribute

produces: set[str] = set()

frequency class-attribute instance-attribute

frequency: Literal[
    "dcp",
    "daily",
    "daily_pre_dep",
    "non_dcp",
    "begin_sample",
    "end_sample",
    "weekly",
] = None

The frequency with which to run this action.

This can be one of the following values: - "dcp": run only on the specified DCPs. - "daily": run every day. - "daily_pre_dep": run every day prior to departure (i.e., days_prior > 0)." - "non_dcp": run on days that are not in the specified DCPs. - "begin_sample": run only on the first DCP (i.e., the maximum days_prior). - "end_sample": run only on the day of departure (i.e., days_prior == 0). - "weekly": run every 7 days (i.e. when days_prior is a multiple of 7).

The run method of RM actions is actually called every day (as it is implemented as a daily callback), but the first thing the run method should do is check whether it should actually execute on that day, using the should_run method, which uses this frequency setting to determine whether to proceed.

carrier instance-attribute

carrier = carrier

The carrier upon which to apply this action.

minimum_sample instance-attribute

minimum_sample = minimum_sample

The minimum sample number before this action will run.

dcps instance-attribute

dcps = set(dcps)

Set of days prior to departure on which to run this action.

run abstractmethod

run(sim: Simulation, days_prior: int)

Execute the action for the given simulation.

Subclasses must implement this method.

configure classmethod

configure(
    fixed: dict[str, Any] | None = None, **kwargs
) -> RmActionFactory

Create an RmActionFactory for this action with the given configuration.

Each keyword argument name should correspond to a parameter in the RmAction subclass's init method. The value of each keyword argument will be the keyword argument used in the RmSys that uses this factory.

Fixed values can be provided via the fixed parameter, which is a dictionary of parameter names to fixed values. These values will always be passed to the RmAction constructor, and cannot be overridden via the RmSys.

get_dcp_index

get_dcp_index(
    days_prior: int, allow_between: bool = False
) -> int

should_run

should_run(sim: Simulation, days_prior: int) -> bool

Determine if the action should run on the given days_prior.

RmSys

RmSys(carrier: str, dcps: Collection[int] = (), **kwargs)

A revenue management (RM) system that executes a sequence of RM actions.

Initialize the RM system.

Parameters:

  • carrier (str) –

    The carrier code for which this RM system is configured.

  • dcps (Collection[int], default: () ) –

    A collection of data collection points (DCPs) given as days prior to departure, on which to run the EMSR optimization and other actions.

  • **kwargs

    Additional keyword arguments to configure the RM actions in this system.

Raises:

  • ValueError

    If availability_control is not defined, or if no actions are defined, or if any provided keyword argument does not match any action's configuration options.

priority class-attribute instance-attribute

priority: int = -1

Priority of this RM system when scheduled as an event callback.

The default setting is -1, which means it will run just before other daily callbacks with the default priority of 0.

availability_control class-attribute instance-attribute

availability_control: Literal[
    "leg", "cabin", "bp", "bp_loose", "classless", None
] = None

The type of availability control used in this RM system.

The selected availability control is injected into the Carrier object at the time it is created in the simulation, as this setting is used during the passenger arrival simulation loop, and instead of during the RM system steps run from the action queue each day.

Subclasses of RmSys must set this class variable to one of the allowed values (other than None) to indicate the type of availability control used by that RM system.

actions class-attribute instance-attribute

actions: list[RmActionFactory | type[RmAction]] = []

List of RM actions (or action factories) to execute in this RM system.

Each item in this list should be either an RmActionFactory instance, or an RmAction subclass. If an RmAction subclass is provided, its configure() class method will be called to create an RmActionFactory with no configurable parameters.

Subclasses of RmSys must set this class variable to a non-empty list of actions to be executed in order when this RM system runs.

action_queue instance-attribute

action_queue: list[RmAction] = [
    (make_action(carrier=carrier, dcps=dcps, **kwargs))
    for f in factory_queue
]

List of RM actions to be executed in order.

run

run(sim: Simulation, days_prior: int) -> None

Run all actions in the RM system's action queue.

This will call all the actions in the action queue in order, passing the simulation and days prior to each action's run method. Each action should handle its own logic for whether it should execute based on the current simulation state and days prior.

get_name classmethod

get_name() -> str

Get the name of this RM system class.