examples.gp
Class MathProblem
java.lang.Object
org.jgap.gp.GPProblem
examples.gp.MathProblem
public class MathProblem
- extends GPProblem
Example demonstrating Genetic Programming (GP) capabilities of JGAP.
Also demonstrates usage of ADF's.
The problem is to find a formula for a given truth table (X/Y-pairs).
- The setup of the GP is done in method main and specifically in method
create()
- The problem solving process is started via gp.evolve(800) in the main
method, with 800 the maximum number of evolutions to take place.
- The evaluation of the evolved formula is done in fitness function
FormulaFitnessFunction, which is implemented in this class, MathProblem
For details, please see the mentioned methods and the fitness function.
- Since:
- 3.0
Field Summary |
static Variable |
vx
|
protected static java.lang.Float[] |
x
|
protected static float[] |
y
|
Method Summary |
GPGenotype |
create()
This method is used for setting up the commands and terminals that can be
used to solve the problem. |
static void |
main(java.lang.String[] args)
Starts the example. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
vx
public static Variable vx
x
protected static java.lang.Float[] x
y
protected static float[] y
MathProblem
public MathProblem(GPConfiguration a_conf)
throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
create
public GPGenotype create()
throws InvalidConfigurationException
- This method is used for setting up the commands and terminals that can be
used to solve the problem.
In this example an ADF (an automatically defined function) is used for
demonstration purpuses. Using an ADF is optional. If you want to use one,
care about the places marked with "ADF-relevant:" below. If you do not want
to use an ADF, please remove the below places (and reduce the outer size of
the arrays "types", "argTypes" and "nodeSets" to one).
Please notice, that the variables types, argTypes and nodeSets correspond
to each other: they have the same number of elements and the element at
the i'th index of each variable corresponds to the i'th index of the other
variables!
- Specified by:
create
in class GPProblem
- Returns:
- GPGenotype
- Throws:
InvalidConfigurationException
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Starts the example.
- Parameters:
args
- ignored
- Throws:
java.lang.Exception
- Since:
- 3.0