Skip to content

Instantly share code, notes, and snippets.

@kgadek
Created June 19, 2015 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgadek/b908cb6e3653c8dd25c4 to your computer and use it in GitHub Desktop.
Save kgadek/b908cb6e3653c8dd25c4 to your computer and use it in GitHub Desktop.
diff --git a/algorithms/HGS/HGS.py b/algorithms/HGS/HGS.py
index f382fca..3039abb 100644
--- a/algorithms/HGS/HGS.py
+++ b/algorithms/HGS/HGS.py
@@ -26,7 +26,8 @@ class HGS(DriverGen):
crossover_variance, sprouting_variance,
mutation_variance, branch_comparison,
metaepoch_len, driver, max_children,
- mutation_probability=0.05, sproutiveness=1):
+ mutation_probability=0.05, sproutiveness=1,
+ driver_kwargs_per_level=None):
"""
@type dims: list[(float,float)] # dimensions' ranges, one per dimension
@type population: list[list[float]] # initial population
@@ -42,6 +43,7 @@ class HGS(DriverGen):
@type max_children: int # limit the number of immediate sprouts
@type mutation_probability : float
@type sproutiveness: int # number of sprouts generated on each metaepoch
+ @type driver_kwargs_per_level : list[dict]
:rtype: HGS
"""
super().__init__()
@@ -77,6 +79,7 @@ class HGS(DriverGen):
for lvl, _
in enumerate(self.scaling_coefficients)
]
+ self.driver_kwargs_per_level = driver_kwargs_per_level
self.sproutiveness = sproutiveness
self.max_children = max_children
@@ -192,7 +195,8 @@ class HGS(DriverGen):
dims=outer.dims_per_lvl[level],
fitnesses=outer.fitnesses_per_lvl[level],
mutation_variance=outer.mutation_variance,
- crossover_variance=outer.crossover_variance)
+ crossover_variance=outer.crossover_variance,
+ **outer.driver_kwargs_per_level[level])
""" :type : T <= DriverGen | DriverLegacy """
if isinstance(self.driver, DriverGen):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment