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