JGAP

examples.supergene
Class SupergeneSample

java.lang.Object
  extended by examples.supergene.AbstractSupergeneTest
      extended by examples.supergene.SupergeneSample

public class SupergeneSample
extends AbstractSupergeneTest

To test the Supergene, we created the "make change" version with additional condition: the number of nickels and pennies must be both even or both odd. The supergene encloses two genes (nickels and pennies) and is valid if the condition above is satisfied.

Since:
2.0

Field Summary
 
Fields inherited from class examples.supergene.AbstractSupergeneTest
DIMES, EXISTING_SOLUTIONS_ONLY, MAX_ALLOWED_EVOLUTIONS, NICKELS, PENNIES, POPULATION_SIZE, QUARTERS, REPORT_ENABLED
 
Constructor Summary
SupergeneSample()
           
 
Method Summary
static void main(java.lang.String[] args)
           
 int makeChangeForAmount(int a_targetChangeAmount)
          Executes the genetic algorithm to determine the minimum number of coins necessary to make up the given target amount of change.
 
Methods inherited from class examples.supergene.AbstractSupergeneTest
amountOfChange, getDimesGene, getNickelsGene, getPenniesGene, getQuartersGene, report, solve, test
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SupergeneSample

public SupergeneSample()
Method Detail

makeChangeForAmount

public int makeChangeForAmount(int a_targetChangeAmount)
                        throws java.lang.Exception
Executes the genetic algorithm to determine the minimum number of coins necessary to make up the given target amount of change. The solution will then be written to System.out.

Specified by:
makeChangeForAmount in class AbstractSupergeneTest
Parameters:
a_targetChangeAmount - the target amount of change for which this method is attempting to produce the minimum number of coins
Returns:
absolute difference between the required and computed change amount
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)

JGAP