Skip to content

Commit 6c05925

Browse files
committed
abstract intensifier has a FIXME check. Maybe this is cause the problem but a config should be added to rejected configs if the incumbent set stays the same.
1 parent 5afa7cb commit 6c05925

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

smac/intensifier/abstract_intensifier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ def update_incumbents(self, config: Configuration) -> None:
627627

628628
# Update trajectory
629629
if previous_incumbents == new_incumbents: # Only happens with incumbent config
630-
self._remove_rejected_config(config) # Remove the incumbent from the rejected config list
631-
630+
# self._remove_rejected_config(config) # Remove the incumbent from the rejected config list
631+
self._add_rejected_config(config) # FIXME check whether this is really what we want
632632
return
633633
elif len(previous_incumbents) == len(new_incumbents):
634634
# In this case, we have to determine which config replaced which incumbent and reject it

smac/intensifier/intensifier.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def __iter__(self) -> Iterator[TrialInfo]:
340340

341341
def _check_for_intermediate_comparison(self, config: Configuration) -> bool:
342342
"""Checks if the configuration should be evaluated against the incumbent while it
343-
did not run on all the trails the incumbents did.By default this triggers when all N trails have completed.
343+
did not run on all the trails the incumbents did. By default this triggers when all N trails have completed.
344344
345345
346346
Parameters
@@ -354,6 +354,11 @@ def _check_for_intermediate_comparison(self, config: Configuration) -> bool:
354354
config_isb_keys = self.get_instance_seed_budget_keys(config)
355355
config_hash = get_config_hash(config)
356356

357+
if (
358+
self.uses_cutoffs and len(config_isb_keys) > 0
359+
): # if we are in a runtime setting we definitely want to do intermediate comparisons
360+
return True
361+
357362
# Do not compare very early in the process
358363
if len(config_isb_keys) < 4:
359364
return False

smac/main/config_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def __iter__(self) -> Iterator[Configuration]:
252252
if self._retrain_wallclock_ratio is not None:
253253
# TODO: CB: What does this actually do? Delete/clear the iterator?
254254
# --> JG: To easily measure the time needed to perform maximise, difficult otherwise due to yield
255-
len(challengers) # Forces actual computation of the acquisition function maximizer
255+
len(list(challengers)) # Forces actual computation of the acquisition function maximizer
256256

257257
self._acquisition_training_times.append(time.time() - train_start_time)
258258

tests/test_intensifier/test_adaptive_capping_intensifier.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ConfigSpace import ConfigurationSpace, Configuration
66

77
from smac import Scenario, AlgorithmConfigurationFacade
8+
from smac.runhistory import TrialInfo, TrialValue
89
import numpy as np
910

1011
from smac.main.exceptions import ConfigurationSpaceExhaustedException
@@ -74,12 +75,11 @@ def train(self, config:Configuration, instance: str, cutoff: int, seed: int = 0)
7475
if log[1] == "reject" and log[2] == config_hash:
7576
reject_log = log
7677
break
77-
7878
self.expected_behavior_violations += [f"{self.log_counter}: Configuration {config_hash} was already "
7979
f"rejected here {reject_log}"]
8080

8181
# specify log entry (id, config hash, instance, performance)
82-
log = (self.log_counter, config_hash, instance, rand_perf)
82+
log = (self.log_counter, config_hash, instance, int(rand_perf))
8383

8484
# ensure config has an entry in the log map and store observed performance, add log entry to list
8585
if config_hash not in self.log_map:
@@ -139,12 +139,15 @@ def test_incumbent_switch() -> None:
139139

140140
# setup test environment
141141
tm = TrainMockup()
142-
smac = get_basic_setup(tm.train)
142+
smac = get_basic_setup(tm.train, num_configs=100)
143143

144144
# start smac run
145145
try:
146-
smac.optimize()
146+
for i in range(20):
147+
trial_info:TrialInfo = smac.ask()
148+
val = tm.train(config=trial_info.config, instance=trial_info.instance, cutoff=trial_info.additional_info["cutoff"])
149+
smac.tell(trial_info, TrialValue(cost=val))
147150
except ConfigurationSpaceExhaustedException:
148151
pass
149152

150-
assert tm.expected_behavior_violated is False, tm.get_violation_report()
153+
assert tm.expected_behavior_violated is False, tm.get_violation_report()

0 commit comments

Comments
 (0)