blob: 1384c9a8c5e96f891b4259a060906a3f352e220b [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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 Cheerlaf7c2e1a2015-07-09 12:06:37 -070016package 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 */
24interface GAOrganism {
25 /**
26 * A fitness function that determines how
27 * optimal a given organism is.
28 *
29 * @return fitness of organism
30 */
Andrey Komarov2398d962016-09-26 15:11:23 +030031 Comparable fitness();
Nikhil Cheerlaf7c2e1a2015-07-09 12:06:37 -070032
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}