Skip to content

Commit

Permalink
Use randomly generated initial harmonies for the example
Browse files Browse the repository at this point in the history
  • Loading branch information
Shing Hei Zhan authored and Shing Hei Zhan committed Jul 5, 2018
1 parent 62d0a1d commit 113e112
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/2-D_continuous_specified_initial_harmonies.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@ def maximize(self):
obj_fun = ObjectiveFunction()
num_processes = 1
num_iterations = 1 # because random_seed is defined, there's no point in running this multiple times
initial_harmonies = [[123, -123] for _ in range(100)] # set the initial harmonies for 100 individuals to [123, -123]
initial_harmonies = [[random.randint(-1000, 1000) for _ in range(2)] for _ in range(100)]
results = harmony_search(obj_fun, num_processes, num_iterations, initial_harmonies=initial_harmonies)
print('Elapsed time: {}\nBest harmony: {}\nBest fitness: {}'.format(results.elapsed_time, results.best_harmony, results.best_fitness))

0 comments on commit 113e112

Please sign in to comment.