Nikhil Cheerla | f7c2e1a | 2015-07-09 12:06:37 -0700 | [diff] [blame] | 1 | package org.onlab.graph; |
| 2 | |
| 3 | /** |
| 4 | * Interface representing an "organism": a specific solution |
| 5 | * to a problem where solutions can be evaluated in terms |
| 6 | * of fitness. These organisms can be used to represent any |
| 7 | * class of problem that genetic algorithms can be run on. |
| 8 | */ |
| 9 | interface GAOrganism { |
| 10 | /** |
| 11 | * A fitness function that determines how |
| 12 | * optimal a given organism is. |
| 13 | * |
| 14 | * @return fitness of organism |
| 15 | */ |
| 16 | double fitness(); |
| 17 | |
| 18 | /** |
| 19 | * A method that slightly mutates an organism. |
| 20 | */ |
| 21 | void mutate(); |
| 22 | |
| 23 | /** |
| 24 | * Creates a new random organism. |
| 25 | * |
| 26 | * @return random GAOrganism |
| 27 | */ |
| 28 | GAOrganism random(); |
| 29 | |
| 30 | /** |
| 31 | * Returns a child organism that is the result |
| 32 | * of "crossing" this organism with another. |
| 33 | * |
| 34 | * @param other Other organism to cross with |
| 35 | * @return child organism |
| 36 | */ |
| 37 | GAOrganism crossWith(GAOrganism other); |
| 38 | } |