def __init__(self, tasks, next_generations): """Set up the next generations for this task. Args: tasks: A set of tasks to be run. next_generations: A list of generations as the next generation of the current generation. """ Generation.__init__(self, tasks, None) self._next_generations = next_generations
def __init__(self, tasks, parents, total_stucks): """Set up the meta data for the Genetic Algorithm. Args: tasks: A set of tasks to be run. parents: A set of tasks from which this new generation is produced. This set also contains the best tasks generated so far. total_stucks: The number of generations that have not seen improvement. The Genetic Algorithm will stop once the total_stucks equals to NUM_TRIALS defined in the GAGeneration class. """ Generation.__init__(self, tasks, parents) self._total_stucks = total_stucks
def __init__(self, exe_set, parents, specs): """Set up the tasks set of this generation. Args: exe_set: A set of tasks to be run. parents: A set of tasks to be used to check whether their neighbors have improved upon them. specs: A list of specs to explore. The spec specifies the flags that can be changed to find neighbors of a task. """ Generation.__init__(self, exe_set, parents) self._specs = specs # This variable will be used, by the Next method, to generate the tasks for # the next iteration. This self._next_task contains the best task in the # current iteration and it will be set by the IsImproved method. The tasks # of the next iteration are the neighbor of self._next_task. self._next_task = None
def __init__(self, exe_set, parent_task): """Set up the base line parent task. The parent task is the base line against which the new tasks are compared. The new tasks are only different from the base line from one flag f by either turning this flag f off, or lower the flag value by 1. If a new task is better than the base line, one flag is identified that gives degradation. The flag that give the worst degradation will be removed or lower the value by 1 in the base in each iteration. Args: exe_set: A set of tasks to be run. Each one only differs from the parent_task by one flag. parent_task: The base line task, against which the new tasks in exe_set are compared. """ Generation.__init__(self, exe_set, None) self._parent_task = parent_task