Skip to content

Demands

Demand

Bases: BaseModel

Source code in passengersim/config/demands.py
class Demand(BaseModel, extra="forbid"):
    orig: str
    dest: str
    segment: str
    base_demand: float
    reference_fare: float
    distance: float | None = 0.0
    choice_model: str | None = None
    """The name of the choice model that is applied for this demand."""

    curve: str | None = None
    """The name of the booking curve that is applied for this demand.

    Each demand is attached to a booking curve that describes the temporal
    distribution of customer arrivals."""

    @property
    def choice_model_(self):
        """Choice model, falling back to segment name if not set explicitly."""
        return self.choice_model or self.segment

    @field_validator("curve", mode="before")
    def curve_integer_name(cls, v):
        """Booking curves can have integer names, treat as string."""
        if isinstance(v, int):
            v = str(v)
        return v

base_demand instance-attribute

base_demand: float

choice_model class-attribute instance-attribute

choice_model: str | None = None

The name of the choice model that is applied for this demand.

choice_model_ property

choice_model_

Choice model, falling back to segment name if not set explicitly.

curve class-attribute instance-attribute

curve: str | None = None

The name of the booking curve that is applied for this demand.

Each demand is attached to a booking curve that describes the temporal distribution of customer arrivals.

dest instance-attribute

dest: str

distance class-attribute instance-attribute

distance: float | None = 0.0

orig instance-attribute

orig: str

reference_fare instance-attribute

reference_fare: float

segment instance-attribute

segment: str

curve_integer_name

curve_integer_name(v)

Booking curves can have integer names, treat as string.

Source code in passengersim/config/demands.py
@field_validator("curve", mode="before")
def curve_integer_name(cls, v):
    """Booking curves can have integer names, treat as string."""
    if isinstance(v, int):
        v = str(v)
    return v