Skip to content

Commit

Permalink
Fix problem with Hyperopt out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvelich committed Aug 26, 2020
1 parent 2ceed7d commit ecf435b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/suggestion/v1beta1/hyperopt/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ def getSuggestions(self, trials, request_number):
# Produce new request_number ids to make new Suggestion
hyperopt_trial_new_ids = self.fmin.trials.new_trial_ids(request_number)
random_state = self.fmin.rstate.randint(2**31 - 1)

# Trial list that must be deployed
new_trials = []
if self.algorithm_name == RANDOM_ALGORITHM_NAME:
new_trials = self.hyperopt_algorithm(
new_ids=hyperopt_trial_new_ids,
Expand All @@ -203,7 +206,6 @@ def getSuggestions(self, trials, request_number):
**self.algorithm_conf)
self.is_first_run = False
else:
new_trials = []
for i in range(request_number):
# hyperopt_algorithm always returns one new Trial
new_trials.append(self.hyperopt_algorithm(
Expand All @@ -216,9 +218,13 @@ def getSuggestions(self, trials, request_number):

# Construct return advisor Trials from new hyperopt Trials
list_of_assignments = []
for i in range(request_number):
vals = new_trials[i]['misc']['vals']
for trial in new_trials:
vals = trial['misc']['vals']
list_of_assignments.append(BaseHyperoptService.convert(self.search_space, vals))

if len(list_of_assignments) > 0:
logger.info("GetSuggestions returns {} new Trial\n".format(len(new_trials)))

return list_of_assignments

@staticmethod
Expand Down

0 comments on commit ecf435b

Please sign in to comment.