org.jgap.impl
Class JGAPFactory
- java.lang.Object
-
- org.jgap.impl.JGAPFactory
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, IJGAPFactory, ICloneable
public class JGAPFactory extends java.lang.Object implements IJGAPFactory, java.io.Serializable, ICloneable, java.lang.Comparable
Central factory for creating default objects to use, e.g. random generators. Could be made configurable. An instance of JGAPFactory can be accessed viaGenotype.getConfiguration().getJGAPFactory();To use your own factory class instead, use:
System.setProperty(Configuration.PROPERTY_JGAPFACTORY_CLASS, "myFactory");with "myFactory" representing the name of your class to use.- Since:
- 2.6
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description JGAPFactory(boolean a_useCaching)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.Objectclone()intcompareTo(java.lang.Object a_other)RandomGeneratorcreateRandomGenerator()booleanequals(java.lang.Object a_other)The equals-methodICloneHandlergetCloneHandlerFor(java.lang.Object a_obj, java.lang.Class a_classToClone)Retrieves a clone handler capable of clone the given class.ICompareToHandlergetCompareToHandlerFor(java.lang.Object a_obj, java.lang.Class a_classToCompareTo)Retrieves a handler capable of comparing two instances of the given class.IGeneticOperatorConstraintgetGeneticOperatorConstraint()IInitializergetInitializerFor(java.lang.Object a_obj, java.lang.Class a_class)Retrieves an initializer capable of initializing the Object of the given class.java.util.CollectiongetParameters()java.lang.StringgetUniqueKey(java.lang.String a_context)Returns a unique key for the given context.booleanisUseCaching()intregisterCloneHandler(ICloneHandler a_cloneHandler)Registers a clone handler that could be retrieved by getCloneHandlerFor(Class).intregisterCompareToHandler(ICompareToHandler a_compareToHandler)Registers a compareTo-handler that could be retrieved by getCompareToHandlerFor(Class).intregisterInitializer(IInitializer a_chromIniter)Registers an initializer that could be retrieved by getInitializerFor(Class).ICloneHandlerremoveCloneHandler(int a_index)Removes a clone handler at a given index (which is obtained from registerCloneHandler).ICompareToHandlerremoveCompareToHandler(int a_index)Removes a compareTo-handler at a given index (which is obtained from registerCompareToHandler).IInitializerremoveInitializer(int a_index)Removes an initializer at a given index (which is obtained from registerInitializer).voidsetGeneticOperatorConstraint(IGeneticOperatorConstraint a_constraint)voidsetParameters(java.util.Collection a_parameters)Allows setting (generic because unknown) parameters for creating objects.
-
-
-
Method Detail
-
setParameters
public void setParameters(java.util.Collection a_parameters)
Allows setting (generic because unknown) parameters for creating objects.- Specified by:
setParametersin interfaceIJGAPFactory- Parameters:
a_parameters- Collection of generic parameters- Since:
- 2.6
-
getParameters
public java.util.Collection getParameters()
- Returns:
- Collection of generic parameters
- Since:
- 3.0
-
createRandomGenerator
public RandomGenerator createRandomGenerator()
- Specified by:
createRandomGeneratorin interfaceIJGAPFactory- Returns:
- newly created instance of a RandomGenerator
-
registerCloneHandler
public int registerCloneHandler(ICloneHandler a_cloneHandler)
Registers a clone handler that could be retrieved by getCloneHandlerFor(Class).- Specified by:
registerCloneHandlerin interfaceIJGAPFactory- Parameters:
a_cloneHandler- the ICloneHandler to register- Returns:
- index of the added clone handler, needed when removeCloneHandler will be called
- Since:
- 2.6
-
removeCloneHandler
public ICloneHandler removeCloneHandler(int a_index)
Removes a clone handler at a given index (which is obtained from registerCloneHandler).- Parameters:
a_index- the index of the clone handler to remove- Returns:
- the removed ICloneHandler, or Exception if not successfull
- Since:
- 2.6
-
getCloneHandlerFor
public ICloneHandler getCloneHandlerFor(java.lang.Object a_obj, java.lang.Class a_classToClone)
Retrieves a clone handler capable of clone the given class.- Specified by:
getCloneHandlerForin interfaceIJGAPFactory- Parameters:
a_obj- the object to clone (maybe null)a_classToClone- the class to clone an object of (maybe null)- Returns:
- the clone handler found capable of clone the given class, or null if none registered
- Since:
- 2.6
-
registerInitializer
public int registerInitializer(IInitializer a_chromIniter)
Registers an initializer that could be retrieved by getInitializerFor(Class).- Specified by:
registerInitializerin interfaceIJGAPFactory- Parameters:
a_chromIniter- the IChromosomeInitializer to register- Returns:
- index of the added initializer, needed when removeChromosomeInitializer will be called
- Since:
- 2.6
-
removeInitializer
public IInitializer removeInitializer(int a_index)
Removes an initializer at a given index (which is obtained from registerInitializer).- Parameters:
a_index- the index of the initializer to remove- Returns:
- the removed IInitializer, or null if not successfull
- Since:
- 2.6
-
getInitializerFor
public IInitializer getInitializerFor(java.lang.Object a_obj, java.lang.Class a_class)
Retrieves an initializer capable of initializing the Object of the given class.- Specified by:
getInitializerForin interfaceIJGAPFactory- Parameters:
a_obj- the object to init (maybe null)a_class- the object class to init (maybe null)- Returns:
- new instance (should be!) of initialized object
- Since:
- 2.6
-
setGeneticOperatorConstraint
public void setGeneticOperatorConstraint(IGeneticOperatorConstraint a_constraint)
- Specified by:
setGeneticOperatorConstraintin interfaceIJGAPFactory
-
getGeneticOperatorConstraint
public IGeneticOperatorConstraint getGeneticOperatorConstraint()
- Specified by:
getGeneticOperatorConstraintin interfaceIJGAPFactory
-
getCompareToHandlerFor
public ICompareToHandler getCompareToHandlerFor(java.lang.Object a_obj, java.lang.Class a_classToCompareTo)
Retrieves a handler capable of comparing two instances of the given class.- Specified by:
getCompareToHandlerForin interfaceIJGAPFactory- Parameters:
a_obj- the object to compare (maybe null)a_classToCompareTo- the class instances to compare (maybe null)- Returns:
- the handler found capable of comparing instances of the given class, or null if none registered
- Since:
- 2.6
-
registerCompareToHandler
public int registerCompareToHandler(ICompareToHandler a_compareToHandler)
Registers a compareTo-handler that could be retrieved by getCompareToHandlerFor(Class).- Specified by:
registerCompareToHandlerin interfaceIJGAPFactory- Parameters:
a_compareToHandler- the ICompareToHandler to register- Returns:
- index of the added handler, needed when removeCompareToHandler will be called
- Since:
- 2.6
-
removeCompareToHandler
public ICompareToHandler removeCompareToHandler(int a_index)
Removes a compareTo-handler at a given index (which is obtained from registerCompareToHandler).- Parameters:
a_index- the index of the handler to remove- Returns:
- the removed handler, or Exception if not successfull
- Since:
- 2.6
-
isUseCaching
public boolean isUseCaching()
- Returns:
- true: caching used, false: no caching used
- Since:
- 3.0
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceICloneable- Overrides:
clonein classjava.lang.Object- Returns:
- clone of the current object instance
-
equals
public boolean equals(java.lang.Object a_other)
The equals-method- Overrides:
equalsin classjava.lang.Object- Parameters:
a_other- sic- Returns:
- sic
- Since:
- 3.2
-
compareTo
public int compareTo(java.lang.Object a_other)
- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
a_other- other object to compare- Returns:
- as always
- Since:
- 3.2
-
getUniqueKey
public java.lang.String getUniqueKey(java.lang.String a_context)
Returns a unique key for the given context. The key uses the current date and time and a GUID. Thus it is quite probable, that the key is unique worldwide.- Parameters:
a_context- the context to get the next key for, like "Chromosome".- Returns:
- the unique key for the given context
- Since:
- 3.5
-
-
DMelt 3.0 © DataMelt by jWork.ORG