Intensifier
smac.intensifier.intensifier
#
Intensifier
#
Intensifier(
scenario: Scenario,
max_config_calls: int = 3,
max_incumbents: int = 10,
retries: int = 16,
seed: int | None = None,
)
Bases: AbstractIntensifier
Implementation of an intensifier supporting multi-fidelity, multi-objective, and multi-processing. Races challengers against current incumbents.
The behaviour of this intensifier is as follows:
- First, adds configs from the runhistory to the queue with N=1 (they will be ignored if they are already evaluated).
-
While loop:
-
If queue is empty: Intensifies exactly one more instance of one incumbent and samples a new configuration afterwards.
- If queue is not empty: Configs in the queue are evaluated on N=(N*2) instances if they might be better than the incumbents. If not, they are removed from the queue and rejected forever.
| PARAMETER | DESCRIPTION |
|---|---|
scenario
|
The scenario defining the optimization problem.
TYPE:
|
max_config_calls
|
Maximum number of configuration evaluations. Basically, how many instance-seed keys should be maxed evaluated for a configuration.
TYPE:
|
max_incumbents
|
How many incumbents to keep track of in the case of multi-objective.
TYPE:
|
retries
|
How many more iterations should be done in case no new trial is found.
TYPE:
|
seed
|
Internal seed used for random events, like shuffle seeds.
TYPE:
|
Source code in smac/intensifier/intensifier.py
config_generator
property
#
config_generator: Iterator[Configuration]
Based on the configuration selector, an iterator is returned that generates configurations.
config_selector
property
writable
#
config_selector: ConfigSelector
The configuration selector for the intensifier.
trajectory
property
#
trajectory: list[TrajectoryItem]
Returns the trajectory (changes of incumbents) of the optimization run.
__iter__
#
This iter method holds the logic for the intensification loop. Some facts about the loop:
- Adds existing configurations from the runhistory to the queue (that means it supports user-inputs).
- Everytime an incumbent (with the lowest amount of trials) is intensified, a new challenger is added to the queue.
- If all incumbents are evaluated on the same trials, a new trial is added to one of the incumbents.
- Only challengers which are not rejected/running/incumbent are intensified by N*2.
| RETURNS | DESCRIPTION |
|---|---|
trials
|
Iterator over the trials. |
Source code in smac/intensifier/intensifier.py
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 144 145 146 147 148 149 150 151 152 153 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 231 232 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 263 264 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 | |
__post_init__
#
Fills self._tf_seeds and self._tf_instances. Moreover, the incumbents are updated.
Source code in smac/intensifier/abstract_intensifier.py
get_callback
#
get_callback() -> Callback
The intensifier makes use of a callback to efficiently update the incumbent based on the runhistory (every time new information is available). Moreover, incorporating the callback here allows developers more options in the future.
Source code in smac/intensifier/abstract_intensifier.py
get_incumbent
#
Returns the current incumbent in a single-objective setting.
Source code in smac/intensifier/abstract_intensifier.py
get_incumbent_instance_seed_budget_key_differences
#
get_incumbent_instance_seed_budget_key_differences(
compare: bool = False,
) -> list[InstanceSeedBudgetKey]
There are situations in which incumbents are evaluated on more trials than others. This method returns the instances that are not part of the lowest intersection of instances for all incumbents.
Source code in smac/intensifier/abstract_intensifier.py
get_incumbent_instance_seed_budget_keys
#
get_incumbent_instance_seed_budget_keys(
compare: bool = False,
) -> list[InstanceSeedBudgetKey]
Find the lowest intersection of instance-seed-budget keys for all incumbents.
Source code in smac/intensifier/abstract_intensifier.py
get_incumbents
#
Returns the incumbents (points on the pareto front) of the runhistory as copy. In case of a single-objective optimization, only one incumbent (if is) is returned.
| RETURNS | DESCRIPTION |
|---|---|
configs
|
The configs of the Pareto front.
TYPE:
|
sort_by
|
Sort the trials by
TYPE:
|
Source code in smac/intensifier/abstract_intensifier.py
get_instance_seed_budget_keys
#
get_instance_seed_budget_keys(
config: Configuration, compare: bool = False
) -> list[InstanceSeedBudgetKey]
Returns the instance-seed-budget keys for a given configuration. This method is used for updating the incumbents and might differ for different intensifiers. For example, if incumbents should only be compared on the highest observed budgets.
Source code in smac/intensifier/abstract_intensifier.py
get_instance_seed_keys_of_interest
#
get_instance_seed_keys_of_interest(
*, validate: bool = False, seed: int | None = None
) -> list[InstanceSeedKey]
Returns a list of instance-seed keys. Considers seeds and instances from the
runhistory (self._tf_seeds and self._tf_instances). If no seeds or instances were found, new
seeds and instances are generated based on the global intensifier seed.
Warning
The passed seed is only used for validation. For training, the global intensifier seed is used.
| PARAMETER | DESCRIPTION |
|---|---|
validate
|
Whether to get validation trials or training trials. The only difference lies in different seeds.
TYPE:
|
seed
|
The seed used for the validation trials.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
instance_seed_keys
|
Instance-seed keys of interest.
TYPE:
|
Source code in smac/intensifier/abstract_intensifier.py
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 263 264 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 | |
get_rejected_configs
#
get_rejected_configs() -> list[Configuration]
Returns rejected configurations when racing against the incumbent failed.
Source code in smac/intensifier/abstract_intensifier.py
get_trials_of_interest
#
get_trials_of_interest(
config: Configuration,
*,
validate: bool = False,
seed: int | None = None
) -> list[TrialInfo]
Returns the trials of interest for a given configuration.
Expands the keys from get_instance_seed_keys_of_interest with the config.
Source code in smac/intensifier/abstract_intensifier.py
load
#
Loads the latest state of the intensifier including the incumbents and trajectory.
Source code in smac/intensifier/abstract_intensifier.py
reset
#
Resets the internal variables of the intensifier including the queue.
Source code in smac/intensifier/intensifier.py
save
#
Saves the current state of the intensifier. In addition to the state (retrieved by get_state), this
method also saves the incumbents and trajectory.
Source code in smac/intensifier/abstract_intensifier.py
update_incumbents
#
Updates the incumbents. This method is called everytime a trial is added to the runhistory. Since only the affected config and the current incumbents are used, this method is very efficient. Furthermore, a configuration is only considered incumbent if it has a better performance on all incumbent instances.
Crucially, if there is no incumbent (at the start) then, the first configuration assumes incumbent status. For the next configuration, we need to check if the configuration is better on all instances that have been evaluated for the incumbent. If this is the case, then we can replace the incumbent. Otherwise, a) we need to requeue the config to obtain the missing instance-seed-budget combination or b) mark this configuration as inferior ("rejected") to not consider it again. The comparison behaviour is controlled by self.get_instance_seed_budget_keys() and self.get_incumbent_instance_seed_budget_keys().
Notably, this method is written to support both multi-fidelity and multi-objective optimization. While the get_instance_seed_budget_keys() method and self.get_incumbent_instance_seed_budget_keys() are used for the multi-fidelity behaviour, calculate_pareto_front() is used as a hard coded way to support multi-objective optimization, including the single objective as special case. calculate_pareto_front() is called on the set of all (in case of MO) incumbents amended with the challenger configuration, provided it has a sufficient overlap in seed-instance-budget combinations.
Lastly, if we have a self._max_incumbents and the pareto front provides more than this specified amount, we cut the incumbents using crowding distance.
Source code in smac/intensifier/abstract_intensifier.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |