Skip to content

Commit

Permalink
moved getting first item from ind for ga
Browse files Browse the repository at this point in the history
  • Loading branch information
jsadler2 committed Mar 18, 2019
1 parent 4ddeeb3 commit 3983694
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion swmm_mpc/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def list_to_policy(policy, control_str_ids, n_control_steps):

def format_policies(policy, control_str_ids, n_control_steps, opt_method):
if opt_method == 'genetic_algorithm':
return gene_to_policy_dict(policy[0], control_str_ids, n_control_steps)
return gene_to_policy_dict(policy, control_str_ids, n_control_steps)
elif opt_method == 'bayesian_opt':
return list_to_policy(policy, control_str_ids, n_control_steps)

Expand Down Expand Up @@ -207,6 +207,9 @@ def evaluate(*individual):
copyfile(hs_file_path, tmp_hs_file)

# format policies
if sm.run.opt_method == 'genetic_algorithm':
individual = individual[0]

fmted_policies = format_policies(individual, sm.run.ctl_str_ids,
sm.run.n_ctl_steps, sm.run.opt_method)

Expand Down

0 comments on commit 3983694

Please sign in to comment.