Pricing optimizer
A pricing optimizer completely defines the revenue optimization strategy to apply to flights. In particular, it is needed to define:
A schedule, to define when to trigger optimization passes.
A selector, to specify the inputs of the optimization passes for each flight.
An operator, to specify the set of actions and algorithms that will run on the input data.
DPQSDMaximizer
dataclass
Bases: OptimizerMaximizer
Parameters of the DPQSD Maximizer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_requests_per_day | int | Upper bound in maximum requests per day | 50 |
price_points | int | Number of price points | 30 |
ebc_samples | int | Number of samples to take from the optimal solution | 5 |
Source code in src/rmlab/data/parametric/pricing_optimizer.py
139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
OptimizerMaximizer
Base class for maximizers.
Source code in src/rmlab/data/parametric/pricing_optimizer.py
133 134 135 136 |
|
OptimizerModel
dataclass
Bases: PricingModel
Dataclass assembling all optimization parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schedule | List[OptimizerSchedule] | Schedule instance | required |
selector | OptimizerSelector | Selector instance | required |
operator | OptimizerOperator | Operator instance | required |
other | Optional[Mapping[str, Any]] | Other fields (for backwards compatibility) | None |
Source code in src/rmlab/data/parametric/pricing_optimizer.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
OptimizerOperator
dataclass
Optimizer operator parameters specify the forecasting, aggregation and maximization algorithms and which actions are performed after an optimization pass finishes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
forecaster_type | OptimizationForecasterKind | Forecaster type | required |
maximizer | OptimizationMaximizerKind | Revenue maximizer type | required |
aggregate_type | OptimizationAggregatorKind | Type of aggregation of historic input data | required |
aggregate_value | Optional[float] | Numeric parameter of aggregation type | None |
effects | str | Actions to perform after maximization | required |
Example 1
To create an operator that:
- Runs q-forecast forecaster on all input data
- Aggregates forecast data of all flights as a *0.5 exponential" weighting
- Modify the thresholds of the flight after maximization pass
we create an operator instance as:
op = OptimizerOperator(
forecaster_type="q-forecast",
maximizer=OptimizerMaximizer(...),
aggregate_type="exponential",
aggregate_value=0.5
effects="promote-dynamic-bc-thresholds"
)
Example 2
To create an operator that:
- Runs Q-Forecast forecaster on all input data
- Aggregates forecast data of all flights uniformly
- Do not apply the results to the thresholds
we create an operator instance as:
op = OptimizerOperator(
forecaster_type="q-forecast",
maximizer=OptimizerMaximizer(...),
aggregate_type="uniform",
effects="none"
)
Source code in src/rmlab/data/parametric/pricing_optimizer.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
OptimizerSchedule
dataclass
Optimizer schedule parameters specify when and how often optimization passes are triggered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_dbd | int | Positive day before departure from which this schedule is applied. | required |
day_frequency | int | Number of days between consecutive optimization passes | required |
Examples:
Run every 30 days since it is put on sale:
sch = OptimizerSchedule(from_dbd=float('inf'), day_frequency=30)
Run every 15 days when it reaches dbd 180:
sch = OptimizerSchedule(from_dbd=180, day_frequency=15)
Run every 7 days when it reaches dbd 60:
sch = OptimizerSchedule(from_dbd=60, day_frequency=7)
Run every 3 days when it reaches dbd 30:
sch = OptimizerSchedule(from_dbd=30, day_frequency=3)
Run every day when it reaches dbd 15:
sch = OptimizerSchedule(from_dbd=15, day_frequency=1)
Source code in src/rmlab/data/parametric/pricing_optimizer.py
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 |
|
OptimizerSelector
dataclass
Optimizer selector parameters specify which historic data is fed to the forecaster.
From a functional perspective, a OptimizerSelector instance stores a set of parameters that define a function:
(flightInput) → [flight1, flight2, …, flightN]
Ie: from the OptimizerSelector parameters we know, given a flightInput, the set of neighboring flights [flight1, flight2, …, flightN] on which optimization passes are run upon.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
since_qty | int | Time qty | required |
since_unit | TimeUnit | Time unit | required |
filters | List[OptimizationSelectorFilterKind] | Filters to apply to input flights | required |
Examples:
To create a selector that picks the neighboring flights that:
- Cover the same citysector and same airline (implicitly assumed, no need to specify it)
- Depart any time within the last 2 years with respect the flight departure date
- Departing in the same day of week as flightInput
- Departing in the same hour slot as flightInput
- Covering the same sector
then we create the selector instance as:
sel = OptimizerSelector(
since_qty=2,
since_unit="year",
filters=["day-of-week", "hour-slot", "sector"]
)
See OptimizationSelectorFilterKind
reference of allowed filters.
Source code in src/rmlab/data/parametric/pricing_optimizer.py
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 |
|
make_pricing_optimizer_from_json(filename_or_dict)
Make a pricing optimizer instance from a json representation (from file or dict).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename_or_dict | Union[str, dict] | JSON filename or dictionary in json format | required |
Examples from file: my_pricing_optimizer.json
{
"schedule": {
"INF": 7,
"7": 2
},
"selector": {
"since": "2 years",
"filters": []
},
"operator": {
"forecaster": "q-forecast",
"aggregate": "exponential 1.5",
"optimizer": {
"type": "qsd",
"max_requests_per_day": 50,
"price_points": 30,
"ebc_samples": 5
},
"effects": "none"
}
}
my_pricing_optimizer = make_pricing_optimizer_from_json("my_pricing_optimizer.json")
Source code in src/rmlab/data/parametric/pricing_optimizer.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|