Yuheng Long | f20cffa | 2013-06-03 18:46:00 -0700 | [diff] [blame] | 1 | """A generation of a set of tasks. |
| 2 | |
| 3 | This contains the core algorithm of producing the next generation of execution. |
| 4 | """ |
| 5 | |
| 6 | __author__ = 'yuhenglong@google.com (Yuheng Long)' |
| 7 | |
| 8 | |
| 9 | class Generation(object): |
| 10 | """A generation of a framework run. |
| 11 | |
| 12 | This also contains the core implementation, reproducing new generations. |
| 13 | """ |
| 14 | |
| 15 | def __init__(self, pool): |
| 16 | """Set up the tasks set of this generation. |
| 17 | |
| 18 | Args: |
| 19 | pool: a set of tasks to be run |
| 20 | """ |
| 21 | self._pool = pool |
| 22 | |
| 23 | def next(self): |
| 24 | """Calculate the next generation. |
| 25 | |
| 26 | This is the core of the framework implementation. |
| 27 | |
| 28 | Returns: |
| 29 | A new generation. |
| 30 | """ |
| 31 | |
| 32 | def pool(self): |
| 33 | """Return the task set of this generation.""" |
| 34 | pass |
| 35 | |
| 36 | def improve(self): |
| 37 | """True if this generation has improvement over its parent generation.""" |
| 38 | pass |
| 39 | |
| 40 | def get_best(self): |
| 41 | """Get the best flagset.""" |
| 42 | return self._pool[0] |