Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Nikhil Cheerla | f7c2e1a | 2015-07-09 12:06:37 -0700 | [diff] [blame] | 16 | package org.onlab.graph; |
| 17 | |
| 18 | /** |
| 19 | * Interface representing an "organism": a specific solution |
| 20 | * to a problem where solutions can be evaluated in terms |
| 21 | * of fitness. These organisms can be used to represent any |
| 22 | * class of problem that genetic algorithms can be run on. |
| 23 | */ |
| 24 | interface GAOrganism { |
| 25 | /** |
| 26 | * A fitness function that determines how |
| 27 | * optimal a given organism is. |
| 28 | * |
| 29 | * @return fitness of organism |
| 30 | */ |
Andrey Komarov | 2398d96 | 2016-09-26 15:11:23 +0300 | [diff] [blame] | 31 | Comparable fitness(); |
Nikhil Cheerla | f7c2e1a | 2015-07-09 12:06:37 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * A method that slightly mutates an organism. |
| 35 | */ |
| 36 | void mutate(); |
| 37 | |
| 38 | /** |
| 39 | * Creates a new random organism. |
| 40 | * |
| 41 | * @return random GAOrganism |
| 42 | */ |
| 43 | GAOrganism random(); |
| 44 | |
| 45 | /** |
| 46 | * Returns a child organism that is the result |
| 47 | * of "crossing" this organism with another. |
| 48 | * |
| 49 | * @param other Other organism to cross with |
| 50 | * @return child organism |
| 51 | */ |
| 52 | GAOrganism crossWith(GAOrganism other); |
| 53 | } |