JGAP

examples.gp
Class MathProblem

java.lang.Object
  extended by org.jgap.gp.GPProblem
      extended by 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).


For details, please see the mentioned methods and the fitness function.

Since:
3.0

Nested Class Summary
static class MathProblem.FormulaFitnessFunction
          Fitness function for evaluating the produced fomulas, represented as GP programs.
 
Field Summary
static Variable vx
           
protected static java.lang.Float[] x
           
protected static float[] y
           
 
Constructor Summary
MathProblem(GPConfiguration a_conf)
           
 
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 org.jgap.gp.GPProblem
createTree, getGPConfiguration, setGPConfiguration, showTree, showTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vx

public static Variable vx

x

protected static java.lang.Float[] x

y

protected static float[] y
Constructor Detail

MathProblem

public MathProblem(GPConfiguration a_conf)
            throws InvalidConfigurationException
Throws:
InvalidConfigurationException
Method Detail

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

JGAP