adams.genetic
Class MTAbstractGeneticAlgorithm.GeneticAlgorithmJob

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.multiprocess.Job
          extended by adams.genetic.MTAbstractGeneticAlgorithm.GeneticAlgorithmJob
All Implemented Interfaces:
CleanUpHandler, SizeOfHandler, Serializable
Enclosing class:
MTAbstractGeneticAlgorithm

public abstract static class MTAbstractGeneticAlgorithm.GeneticAlgorithmJob
extends Job

A job class specific to genetic algorithms.

Version:
$Revision: 4584 $
Author:
dale
See Also:
Serialized Form

Field Summary
protected  int m_chrom_num
          the number of chromosomes.
protected  Double m_fitness
          the current fitness.
protected  MTAbstractGeneticAlgorithm m_genetic
          the algorithm object this job belongs to.
protected  int[] m_weights
          the weights of the chromosomes (0 = turned off, 1 = turned on).
 
Fields inherited from class adams.multiprocess.Job
m_complete, m_completed, m_depends, m_ExecutionError, m_jobInfo, m_jobParams
 
Constructor Summary
MTAbstractGeneticAlgorithm.GeneticAlgorithmJob(MTAbstractGeneticAlgorithm g, int num, int[] w)
          Initializes the job.
 
Method Summary
abstract  void calcNewFitness()
          Calculates the new fitness.
 void cleanUp()
          Cleans up data structures, frees up memory.
 Double getFitness()
          Returns the fitness.
 MTAbstractGeneticAlgorithm getGenetic()
          Returns the algorithm this job belongs to.
 int getNumChrom()
          Returns the number of chromosomes.
 int[] getWeights()
          Returns the current weights of the attributes.
protected  String postProcessCheck()
          Checks whether all post-conditions have been met.
protected  String preProcessCheck()
          Checks whether all pre-conditions have been met.
protected  void process()
          Does the actual execution of the job.
 String toString()
          Returns a string representation of the job.
 String weightsToString()
          Turns the weights into a string representation.
 
Methods inherited from class adams.multiprocess.Job
addDependency, addParam, execute, getAdditionalErrorInformation, getAsVector, getDependencies, getExecutionError, getJobCompleteListener, getJobInfo, getParam, hasExecutionError, isComplete, jobCompleted, setJobCompleteListener
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_weights

protected int[] m_weights
the weights of the chromosomes (0 = turned off, 1 = turned on).


m_genetic

protected MTAbstractGeneticAlgorithm m_genetic
the algorithm object this job belongs to.


m_fitness

protected Double m_fitness
the current fitness.


m_chrom_num

protected int m_chrom_num
the number of chromosomes.

Constructor Detail

MTAbstractGeneticAlgorithm.GeneticAlgorithmJob

public MTAbstractGeneticAlgorithm.GeneticAlgorithmJob(MTAbstractGeneticAlgorithm g,
                                                      int num,
                                                      int[] w)
Initializes the job.

Parameters:
g - the algorithm object this job belongs to
num - the number of chromsomes
w - the initial weights
Method Detail

getGenetic

public MTAbstractGeneticAlgorithm getGenetic()
Returns the algorithm this job belongs to.

Returns:
the owner

getWeights

public int[] getWeights()
Returns the current weights of the attributes.

Returns:
the weights

getNumChrom

public int getNumChrom()
Returns the number of chromosomes.

Returns:
the number of chromosomes

getFitness

public Double getFitness()
Returns the fitness.

Returns:
the fitness

weightsToString

public String weightsToString()
Turns the weights into a string representation.

Returns:
the weights as string

calcNewFitness

public abstract void calcNewFitness()
Calculates the new fitness.


preProcessCheck

protected String preProcessCheck()
Checks whether all pre-conditions have been met.

Specified by:
preProcessCheck in class Job
Returns:
null if everything is OK, otherwise an error message

process

protected void process()
Does the actual execution of the job.

Specified by:
process in class Job

postProcessCheck

protected String postProcessCheck()
Checks whether all post-conditions have been met.

Specified by:
postProcessCheck in class Job
Returns:
always null

cleanUp

public void cleanUp()
Cleans up data structures, frees up memory. Sets the weights and the genetic algorithm to null.

Specified by:
cleanUp in interface CleanUpHandler
Overrides:
cleanUp in class Job

toString

public String toString()
Returns a string representation of the job.

Specified by:
toString in class Job
Returns:
a string representation


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.