55from ConfigSpace import ConfigurationSpace , Configuration
66
77from smac import Scenario , AlgorithmConfigurationFacade
8+ from smac .runhistory import TrialInfo , TrialValue
89import numpy as np
910
1011from 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