LegValue

class passengersim.rm.leg_value.LegValue(*, carrier: str = '', minimum_sample: int = 3, cfg: Config | None = None, algorithm: 'bottom_up' | 'top_down' = 'bottom_up', minimum_pct_separation: float = 0.05, frequency: 'dcp' | 'daily' | 'begin_sample' = 'dcp')[source]

Bases: RmAction

Methods

__init__(*[, carrier, minimum_sample, cfg, ...])

apply_snapshot_filters(sim, days_prior, ...)

Apply this action's snapshot filters, if any, and return the resulting instruction.

configure([fixed])

Create an RmActionFactory for this action with the given configuration.

get_dcp_index(days_prior[, allow_between])

init(sim)

Initialize the action for the given simulation.

run(sim, days_prior)

Execute the action for the given simulation.

should_run(sim, days_prior)

Determine if the action should run on the given days_prior.

Attributes

frequency

How often to run this step.

produces

requires

snapshot_filter_type

algorithm

Algorithm to use for leg value correction.

minimum_pct_separation

Minimum percentage separation between bucket values.

dcps

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

carrier

The carrier upon which to apply this action.

minimum_sample

The minimum sample number before this action will run.

produces : set[str] = {'leg_value'}
algorithm : Literal['bottom_up', 'top_down']

Algorithm to use for leg value correction.

Corrections may be needed to address fare inversions. The bottom_up algorithm will start with the lowest bucket and work up, pushing fares upwards if needed to maintain ordering and ensure the indicated minimum percentage separation. The top_down algorithm will start with the highest bucket and work down, pushing fares downwards if needed.

apply_snapshot_filters(sim: Simulation, days_prior: int, *args, **kwargs) SnapshotInstruction | None

Apply this action’s snapshot filters, if any, and return the resulting instruction.

If there are no snapshot filters, or if none of the filters trigger, then this returns None.

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(days_prior: int, allow_between: bool = False) int
init(sim: Simulation)

Initialize the action for the given simulation.

This is a hook called once at the beginning of the simulation, after the entire network and all core data structures have been set up but before any simulation samples have been run. It can be used to perform any necessary setup before the first call to run. By default, this does nothing, but subclasses can override it if needed.

requires : set[str] = {}
should_run(sim: Simulation, days_prior: int) bool

Determine if the action should run on the given days_prior.

snapshot_filter_type : type[GenericSnapshotFilter] = None
minimum_pct_separation : float

Minimum percentage separation between bucket values.

If the computed values are inverted or too close to each other, many optimization algorithms will fail. This parameter ensures that the values are separated by at least this percentage at each step.

dcps : set[int]

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

carrier

The carrier upon which to apply this action.

minimum_sample

The minimum sample number before this action will run.

frequency : Literal['dcp', 'daily', 'begin_sample'] = 'begin_sample'

How often to run this step.

run(sim: Simulation, days_prior: int)[source]

Execute the action for the given simulation.

Subclasses must implement this method.