Skip to content

Optimization

Interface to trigger optimization passes.

APIOptimization

Bases: APIBaseInternal

Exposes functions to run and schedule optimization runs on a set of flights and to fetch flights related to optimization targets.

Source code in src/rmlab/api/operations/optimization.py
  9
 10
 11
 12
 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class APIOptimization(APIBaseInternal):
    """Exposes functions to run and schedule optimization runs on a set of flights
    and to fetch flights related to optimization targets."""

    async def trigger_optimization_pass(
        self,
        scen_id: int,
        airline_id: str,
        *,
        citysector_id: Optional[str] = None,
        sector_id: Optional[str] = None,
    ):
        """Triggers an optimization pass on all flights of an airline belonging to a citysector or sector.

        Args:
            scen_id (int): Scenario ID
            airline_id (str): Airline ID
            citysector_id (Optional[str], optional): Citysector ID. Defaults to None.
            sector_id (Optional[str], optional): Sector ID. Defaults to None.

        Raises:
            ValueError: If none of `citysector_id`, `sector_id` is defined
        """

        if citysector_id is None and sector_id is None:
            raise ValueError(
                f"At least one of `citysector_id`, `sector_id` must be defined"
            )

        await self._submit_call(
            "api-operation-optimization-trigger",
            scen_id=scen_id,
            airline_id=airline_id,
            citysector_id=citysector_id,
            sector_id=sector_id,
        )

    async def schedule_optimization_pass(
        self,
        scen_id: int,
        airline_id: str,
        date_time: datetime,
        *,
        citysector_id: Optional[str] = None,
        sector_id: Optional[str] = None,
    ):
        """Schedules an optimization pass on all flights of an airline belonging to a citysector or sector to be run at specific date and time.

        Args:
            scen_id (int): Scenario ID
            airline_id (str): Airline ID
            date_time (datetime): Date and time at which the optimization pass is triggered.
            citysector_id (Optional[str], optional): Citysector ID. Defaults to None.
            sector_id (Optional[str], optional): Sector ID. Defaults to None.

        Raises:
            ValueError: If none of `citysector_id`, `sector_id` is defined
        """

        if citysector_id is None and sector_id is None:
            raise ValueError(
                f"At least one of `citysector_id`, `sector_id` must be defined"
            )

        await self._submit_call(
            "api-operation-optimization-schedule",
            scen_id=scen_id,
            date_time=datetime.strftime(date_time, DateTimeMinFormat),
            airline_id=airline_id,
            citysector_id=citysector_id,
            sector_id=sector_id,
        )

    async def fetch_optimization_input_flights(
            self,
            scen_id: int,
            flight_id: str,
            citysector_id: str) -> List[str]:
        """Returns all flights whose data is used as input for optimizing the input flight.

        Args:
            scen_id (int): Scenario ID.
            flight_id (str): Flight ID.
            citysector_id (str): Citysector ID of flight.
        """

        return await self._submit_call(
            "api-operation-optimization-input-ids",
            scen_id=scen_id,
            flight_id=flight_id,
            citysector_id=citysector_id)

    async def fetch_optimization_scheduled_flights(
            self,
            scen_id: int,
            airline_id: str,
            sector_id: str,
            date_start: datetime,
            date_end: datetime) -> List[str]:
        """Returns all flights of an airline in a sector scheduled for optimization passes in a date interval

        Args:
            scen_id (int): Scenario ID.
            airline_id (str): Airline ID.
            sector_id (str): Sector ID of flight.
            date_start (datetime): Start of date interval.
            date_end (datetime): End of date interval.
        """

        return await self._submit_call(
            "api-operation-optimization-scheduled-ids",
            scen_id=scen_id,
            airline_id=airline_id,
            sector_id=sector_id,
            ds_start=datetime.strftime(date_start, DateFormat),
            ds_end=datetime.strftime(date_end, DateFormat))

    async def set_current_date(
            self,
            scen_id: int,
            date_current: datetime):
        """Set current date.

        Args:
            scen_id (int): Scenario ID.
            date_current (datetime): Current date to set.
        """

        if not isinstance(date_current, datetime):
            raise TypeError(f"Expected `datetime` type, got `{type(date_current)}`")

        return await self._submit_call(
            "api-operation-set-date",
            scen_id=scen_id,
            ds_current=datetime.strftime(date_current, DateFormat))

fetch_optimization_input_flights(scen_id, flight_id, citysector_id) async

Returns all flights whose data is used as input for optimizing the input flight.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID.

required
flight_idstr

Flight ID.

required
citysector_idstr

Citysector ID of flight.

required
Source code in src/rmlab/api/operations/optimization.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
async def fetch_optimization_input_flights(
        self,
        scen_id: int,
        flight_id: str,
        citysector_id: str) -> List[str]:
    """Returns all flights whose data is used as input for optimizing the input flight.

    Args:
        scen_id (int): Scenario ID.
        flight_id (str): Flight ID.
        citysector_id (str): Citysector ID of flight.
    """

    return await self._submit_call(
        "api-operation-optimization-input-ids",
        scen_id=scen_id,
        flight_id=flight_id,
        citysector_id=citysector_id)

fetch_optimization_scheduled_flights(scen_id, airline_id, sector_id, date_start, date_end) async

Returns all flights of an airline in a sector scheduled for optimization passes in a date interval

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID.

required
airline_idstr

Airline ID.

required
sector_idstr

Sector ID of flight.

required
date_startdatetime

Start of date interval.

required
date_enddatetime

End of date interval.

required
Source code in src/rmlab/api/operations/optimization.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
async def fetch_optimization_scheduled_flights(
        self,
        scen_id: int,
        airline_id: str,
        sector_id: str,
        date_start: datetime,
        date_end: datetime) -> List[str]:
    """Returns all flights of an airline in a sector scheduled for optimization passes in a date interval

    Args:
        scen_id (int): Scenario ID.
        airline_id (str): Airline ID.
        sector_id (str): Sector ID of flight.
        date_start (datetime): Start of date interval.
        date_end (datetime): End of date interval.
    """

    return await self._submit_call(
        "api-operation-optimization-scheduled-ids",
        scen_id=scen_id,
        airline_id=airline_id,
        sector_id=sector_id,
        ds_start=datetime.strftime(date_start, DateFormat),
        ds_end=datetime.strftime(date_end, DateFormat))

schedule_optimization_pass(scen_id, airline_id, date_time, *, citysector_id=None, sector_id=None) async

Schedules an optimization pass on all flights of an airline belonging to a citysector or sector to be run at specific date and time.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID

required
airline_idstr

Airline ID

required
date_timedatetime

Date and time at which the optimization pass is triggered.

required
citysector_idOptional[str]

Citysector ID. Defaults to None.

None
sector_idOptional[str]

Sector ID. Defaults to None.

None

Raises:

TypeDescription
ValueError

If none of citysector_id, sector_id is defined

Source code in src/rmlab/api/operations/optimization.py
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
async def schedule_optimization_pass(
    self,
    scen_id: int,
    airline_id: str,
    date_time: datetime,
    *,
    citysector_id: Optional[str] = None,
    sector_id: Optional[str] = None,
):
    """Schedules an optimization pass on all flights of an airline belonging to a citysector or sector to be run at specific date and time.

    Args:
        scen_id (int): Scenario ID
        airline_id (str): Airline ID
        date_time (datetime): Date and time at which the optimization pass is triggered.
        citysector_id (Optional[str], optional): Citysector ID. Defaults to None.
        sector_id (Optional[str], optional): Sector ID. Defaults to None.

    Raises:
        ValueError: If none of `citysector_id`, `sector_id` is defined
    """

    if citysector_id is None and sector_id is None:
        raise ValueError(
            f"At least one of `citysector_id`, `sector_id` must be defined"
        )

    await self._submit_call(
        "api-operation-optimization-schedule",
        scen_id=scen_id,
        date_time=datetime.strftime(date_time, DateTimeMinFormat),
        airline_id=airline_id,
        citysector_id=citysector_id,
        sector_id=sector_id,
    )

set_current_date(scen_id, date_current) async

Set current date.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID.

required
date_currentdatetime

Current date to set.

required
Source code in src/rmlab/api/operations/optimization.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
async def set_current_date(
        self,
        scen_id: int,
        date_current: datetime):
    """Set current date.

    Args:
        scen_id (int): Scenario ID.
        date_current (datetime): Current date to set.
    """

    if not isinstance(date_current, datetime):
        raise TypeError(f"Expected `datetime` type, got `{type(date_current)}`")

    return await self._submit_call(
        "api-operation-set-date",
        scen_id=scen_id,
        ds_current=datetime.strftime(date_current, DateFormat))

trigger_optimization_pass(scen_id, airline_id, *, citysector_id=None, sector_id=None) async

Triggers an optimization pass on all flights of an airline belonging to a citysector or sector.

Parameters:

NameTypeDescriptionDefault
scen_idint

Scenario ID

required
airline_idstr

Airline ID

required
citysector_idOptional[str]

Citysector ID. Defaults to None.

None
sector_idOptional[str]

Sector ID. Defaults to None.

None

Raises:

TypeDescription
ValueError

If none of citysector_id, sector_id is defined

Source code in src/rmlab/api/operations/optimization.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
async def trigger_optimization_pass(
    self,
    scen_id: int,
    airline_id: str,
    *,
    citysector_id: Optional[str] = None,
    sector_id: Optional[str] = None,
):
    """Triggers an optimization pass on all flights of an airline belonging to a citysector or sector.

    Args:
        scen_id (int): Scenario ID
        airline_id (str): Airline ID
        citysector_id (Optional[str], optional): Citysector ID. Defaults to None.
        sector_id (Optional[str], optional): Sector ID. Defaults to None.

    Raises:
        ValueError: If none of `citysector_id`, `sector_id` is defined
    """

    if citysector_id is None and sector_id is None:
        raise ValueError(
            f"At least one of `citysector_id`, `sector_id` must be defined"
        )

    await self._submit_call(
        "api-operation-optimization-trigger",
        scen_id=scen_id,
        airline_id=airline_id,
        citysector_id=citysector_id,
        sector_id=sector_id,
    )