Skip to content

Upload API Pricing models

Interface for uploading customers models data.

APIUploadPricingModels

Bases: APIUploadInternal

Exposes functions for uploading pricing models data to the server.

Source code in src/rmlab/api/upload/parametric/pricing.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
class APIUploadPricingModels(APIUploadInternal):
    """Exposes functions for uploading pricing models data to the server."""

    async def upload_pricing_range_model(
        self,
        scen_id: int,
        content: Union[str, dict],
    ) -> None:
        """Upload to server a parametric model defined in file, specifying a pricing range to be applied by flights.

        Args:
            scen_id (int): Scenario ID
            content: Model content as file or json dict (require `id` identifier field if the latter)
        """

        await self._upload_parametric_model(
            scen_id,
            parametric_kind=ParametricModelKind.PRICING,
            kind=PricingModelKind.RANGE,
            content=content,
        )

    async def upload_pricing_behavior_model(
        self,
        scen_id: int,
        content: Union[str, dict],
    ) -> None:
        """Upload to server a parametric model defined in file, specifying the pricing behavior/strategy
        under which flights assign prices to seats.

        Args:
            scen_id (int): Scenario ID
            content: Model content as file or json dict (require `id` identifier field if the latter)
        """

        await self._upload_parametric_model(
            scen_id,
            parametric_kind=ParametricModelKind.PRICING,
            kind=PricingModelKind.BEHAVIOR,
            content=content,
        )

    async def upload_pricing_optimizer_model(
        self,
        scen_id: int,
        content: Union[str, dict],
    ) -> None:
        """Upload to server a parametric model defined in file, specifying the pricing optimization methods
        under which flights operate, to adapt the prices given current and past demand.

        Args:
            scen_id (int): Scenario ID
            content: Model content as file or json dict (require `id` identifier field if the latter)
        """

        await self._upload_parametric_model(
            scen_id,
            parametric_kind=ParametricModelKind.PRICING,
            kind=PricingModelKind.OPTIMIZER,
            content=content,
        )

    async def upload_batch_pricing_models(
        self,
        scen_id: int,
        *,
        range_models: Optional[List[Union[str, dict]]] = None,
        behavior_models: Optional[List[Union[str, dict]]] = None,
        optimizer_models: Optional[List[Union[str, dict]]] = None,
    ):
        if range_models is None:
            range_models = list()
        if behavior_models is None:
            behavior_models = list()
        if optimizer_models is None:
            optimizer_models = list()

        not_existing_filenames = \
            [FileNotFoundError(fn) for fn in range_models if isinstance(fn, str) and not os.path.exists(fn)] + \
            [FileNotFoundError(fn) for fn in behavior_models if isinstance(fn, str) and not os.path.exists(fn)] + \
            [FileNotFoundError(fn) for fn in optimizer_models if isinstance(fn, str) and not os.path.exists(fn)]

        wrong_types = \
            [TypeError("Range model expects dict or file name") for cnt in range_models if (not isinstance(cnt, dict)) and (not isinstance(cnt, str))] + \
            [TypeError("Behavior model expects dict or file name") for cnt in behavior_models if (not isinstance(cnt, dict)) and (not isinstance(cnt, str))] + \
            [TypeError("Optimizer model expects dict or file name") for cnt in optimizer_models if (not isinstance(cnt, dict)) and (not isinstance(cnt, str))]

        raise_from_list(not_existing_filenames + wrong_types)

        for prm in range_models:
            await self._upload_parametric_model(
                scen_id, ParametricModelKind.PRICING, PricingModelKind.RANGE, prm
            )

        for pbm in behavior_models:
            await self._upload_parametric_model(
                scen_id, ParametricModelKind.PRICING, PricingModelKind.BEHAVIOR, pbm
            )

        for pom in optimizer_models:
            await self._upload_parametric_model(
                scen_id, ParametricModelKind.PRICING, PricingModelKind.OPTIMIZER, pom
            )

upload_pricing_behavior_model(scen_id, content) async

Upload to server a parametric model defined in file, specifying the pricing behavior/strategy under which flights assign prices to seats.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID

required
contentUnion[str, dict]

Model content as file or json dict (require id identifier field if the latter)

required
Source code in src/rmlab/api/upload/parametric/pricing.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
async def upload_pricing_behavior_model(
    self,
    scen_id: int,
    content: Union[str, dict],
) -> None:
    """Upload to server a parametric model defined in file, specifying the pricing behavior/strategy
    under which flights assign prices to seats.

    Args:
        scen_id (int): Scenario ID
        content: Model content as file or json dict (require `id` identifier field if the latter)
    """

    await self._upload_parametric_model(
        scen_id,
        parametric_kind=ParametricModelKind.PRICING,
        kind=PricingModelKind.BEHAVIOR,
        content=content,
    )

upload_pricing_optimizer_model(scen_id, content) async

Upload to server a parametric model defined in file, specifying the pricing optimization methods under which flights operate, to adapt the prices given current and past demand.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID

required
contentUnion[str, dict]

Model content as file or json dict (require id identifier field if the latter)

required
Source code in src/rmlab/api/upload/parametric/pricing.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
async def upload_pricing_optimizer_model(
    self,
    scen_id: int,
    content: Union[str, dict],
) -> None:
    """Upload to server a parametric model defined in file, specifying the pricing optimization methods
    under which flights operate, to adapt the prices given current and past demand.

    Args:
        scen_id (int): Scenario ID
        content: Model content as file or json dict (require `id` identifier field if the latter)
    """

    await self._upload_parametric_model(
        scen_id,
        parametric_kind=ParametricModelKind.PRICING,
        kind=PricingModelKind.OPTIMIZER,
        content=content,
    )

upload_pricing_range_model(scen_id, content) async

Upload to server a parametric model defined in file, specifying a pricing range to be applied by flights.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID

required
contentUnion[str, dict]

Model content as file or json dict (require id identifier field if the latter)

required
Source code in src/rmlab/api/upload/parametric/pricing.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
async def upload_pricing_range_model(
    self,
    scen_id: int,
    content: Union[str, dict],
) -> None:
    """Upload to server a parametric model defined in file, specifying a pricing range to be applied by flights.

    Args:
        scen_id (int): Scenario ID
        content: Model content as file or json dict (require `id` identifier field if the latter)
    """

    await self._upload_parametric_model(
        scen_id,
        parametric_kind=ParametricModelKind.PRICING,
        kind=PricingModelKind.RANGE,
        content=content,
    )