if self.cutoff is not None and max_budget is not None:
warnings.warn("Successive Halving with runtime-cutoff as budget: "
"Both max budget (%d) and runtime-cutoff (%d) were provided. Max budget will be used." %
(self.max_budget, len(self.instances)))
self.min_budget = min_budget
self.max_budget = max_budget if max_budget else self.cutoff
After Change
// BUDGETS
if max_budget is not None and min_budget is not None \
and max_budget < min_budget:
raise ValueError("Max budget has to be larger than min budget")
// - if only 1 instance was provided & quality objective, then use cutoff as budget
// - else, use instances as budget
if not self.run_obj_time and len(self.instances) <= 1:
// budget with cutoff
if min_budget is None or \
(max_budget is None and self.cutoff is None):
raise ValueError("Successive Halving with runtime-cutoff as budget (i.e., only 1 instance) "
"requires parameters min_budget and max_budget/cutoff for intensification!")
if self.cutoff is not None and max_budget is not None:
self.logger.warn("Successive Halving with runtime-cutoff as budget: "
"Both max budget (%d) and runtime-cutoff (%d) were provided. Max budget will be used." %
(max_budget, self.cutoff))
self.min_budget = min_budget
self.max_budget = max_budget if max_budget else self.cutoff
self.cutoff_as_budget = True
else:
// budget with instances
if self.run_obj_time and len(self.instances) <= 1:
self.logger.warn("Successive Halving has objective "runtime" but only 1 instance-seed pair.")
self.min_budget = 1 if min_budget is None else int(min_budget)
self.max_budget = len(self.instances) if max_budget is None else int(max_budget)
self.cutoff_as_budget = False
if self.max_budget > len(self.instances):
raise ValueError("Max budget cannot be greater than the number of instance-seed pairs")
if self.max_budget < len(self.instances):
self.logger.warn("Max budget (%d) does not include all instance-seed pairs (%d)" %
(self.max_budget, len(self.instances)))
self.logger.debug("Running Successive Halving with "%s" as budget" % self.cutoff_as_budget)
// precomputing stuff for SH
self.max_sh_iter = np.floor(np.log(self.max_budget / self.min_budget) / np.log(eta))
self.init_chal = int(np.round(self.eta**self.max_sh_iter)) if init_chal is None else init_chal
self.budgets = self.max_budget * np.power(self.eta, -np.linspace(self.max_sh_iter, 0, self.max_sh_iter + 1))
def intensify(self, challengers: typing.List[Configuration],
incumbent: typing.Optional[Configuration],
run_history: RunHistory,