JAGA Homepage

org.jaga.individualRepresentation.greycodedNumbers
Class NDecimalsIndividualSimpleFactory

java.lang.Object
  extended by org.jaga.individualRepresentation.greycodedNumbers.NDecimalsIndividualSimpleFactory
All Implemented Interfaces:
IndividualsFactory

public class NDecimalsIndividualSimpleFactory
extends java.lang.Object
implements IndividualsFactory

TODO: Complete these comments.

Project: JAGA - Java API for Genetic Algorithms.

Company: University College London and JAGA.Org (http://www.jaga.org).

Copyright: (c) 2004 by G. Paperin.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, ONLY if you include a note of the original author(s) in any redistributed/modified copy.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/gpl.html

Version:
JAGA public release 1.0 beta
Author:
Greg Paperin (greg@jaga.org)

Field Summary
private  RangeConstraint[] constraints
           
private  double decimalScale
           
private  int individualSize
           
private  int precision
           
 
Constructor Summary
NDecimalsIndividualSimpleFactory()
           
NDecimalsIndividualSimpleFactory(int varsPerIndividual, int decPrecision, int representationLen)
           
 
Method Summary
 Individual createDefaultIndividual(GAParameterSet params)
          Creates a new default individual.
 Individual createRandomIndividual(GAParameterSet params)
          Creates a random individual according to this factory's current internal settings and expariment paramanters.
 Individual createSpecificIndividual(BitString initVal)
           
 Individual createSpecificIndividual(double[] initVal)
           
 Individual createSpecificIndividual(NDecimalsIndividual initVal)
           
 Individual createSpecificIndividual(java.lang.Object init, GAParameterSet params)
          Creates a new individual and initialises it to the specified value(s).
private  double[] getAllowedRange(int varInd)
           
 RangeConstraint getConstraint(int variableIndex)
          Gets the constraint for individuals' variable with specified index.
 int getDecimalScale()
           
 int getIndividualSize()
           
 int getPrecision()
           
 void setConstraint(int variableIndex, RangeConstraint constraint)
          Sets the constraints for individuals' variable at the specified index.
 void setDecimalScale(int val)
           
 void setIndividualSize(int size)
           
 void setPrecision(int val)
           
 boolean valid(NDecimalsIndividual indiv)
          Checks if the values of the specified individual are in the ranges specified by constraints of this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

individualSize

private int individualSize

decimalScale

private double decimalScale

precision

private int precision

constraints

private RangeConstraint[] constraints
Constructor Detail

NDecimalsIndividualSimpleFactory

public NDecimalsIndividualSimpleFactory()

NDecimalsIndividualSimpleFactory

public NDecimalsIndividualSimpleFactory(int varsPerIndividual,
                                        int decPrecision,
                                        int representationLen)
Method Detail

getDecimalScale

public int getDecimalScale()

setDecimalScale

public void setDecimalScale(int val)

getIndividualSize

public int getIndividualSize()

setIndividualSize

public void setIndividualSize(int size)

getConstraint

public RangeConstraint getConstraint(int variableIndex)
Gets the constraint for individuals' variable with specified index.

Parameters:
variableIndex - the index of the variable inside the individuals to which the constraint applies.
Returns:
the constraint vor variables at the specified index.

setConstraint

public void setConstraint(int variableIndex,
                          RangeConstraint constraint)
Sets the constraints for individuals' variable at the specified index.

Parameters:
variableIndex - index of the variable to which the consteraint applies.
constraint - the constraint.

getPrecision

public int getPrecision()

setPrecision

public void setPrecision(int val)

valid

public boolean valid(NDecimalsIndividual indiv)
Checks if the values of the specified individual are in the ranges specified by constraints of this factory.

Parameters:
indiv - some individual
Returns:
true if all values encoded by this individual are inside the ranges specified by the constrains applicable to this factory; false otherwise.

createDefaultIndividual

public Individual createDefaultIndividual(GAParameterSet params)
Description copied from interface: IndividualsFactory
Creates a new default individual. For same factory settings, this method must always return the same individual (a new instance holding the same values), which is considered the defaut individual for those settings.

Specified by:
createDefaultIndividual in interface IndividualsFactory
Parameters:
params - Experiment parameters.
Returns:
A new instance of the dafault individual for this factory's current settings.

createRandomIndividual

public Individual createRandomIndividual(GAParameterSet params)
Description copied from interface: IndividualsFactory
Creates a random individual according to this factory's current internal settings and expariment paramanters.

Specified by:
createRandomIndividual in interface IndividualsFactory
Parameters:
params - Experiment parameters.
Returns:
A new instanc eof a randomly created individual.

createSpecificIndividual

public Individual createSpecificIndividual(java.lang.Object init,
                                           GAParameterSet params)
Description copied from interface: IndividualsFactory
Creates a new individual and initialises it to the specified value(s). The parameter init can hold any value(s) which this factory knows to interprete.
In particular, a factory should be able to handle Individual-objects of the same type as produced by the factory. If such an Individual-object is passed as the init-value, a deep copy of the individual should be created and returned by this method.
Any other type is permited for the init-value, but the value should not be null. This method should create a new individual and initialise it with the value(s) packed encoded in init.

Specified by:
createSpecificIndividual in interface IndividualsFactory
Parameters:
init - Initialisation value(s) for a new individual.
params - Experiment parameters.
Returns:
A new instance of an individual produced by this factory, initialised to the value(s) specified in init.

createSpecificIndividual

public Individual createSpecificIndividual(NDecimalsIndividual initVal)

createSpecificIndividual

public Individual createSpecificIndividual(BitString initVal)

createSpecificIndividual

public Individual createSpecificIndividual(double[] initVal)

getAllowedRange

private double[] getAllowedRange(int varInd)
                          throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

JAGA Homepage

Go to JAGA Homepage