Package org.opt4j.core
Class AbstractIndividualFactory<I extends Individual>
java.lang.Object
org.opt4j.core.AbstractIndividualFactory<I>
- Type Parameters:
I- the type of Individual
- All Implemented Interfaces:
IndividualFactory
- Direct Known Subclasses:
DefaultIndividualFactory,ParticleFactory
public class AbstractIndividualFactory<I extends Individual>
extends Object
implements IndividualFactory
The
AbstractIndividualFactory creates Individuals using a
given Provider and sets the registered
IndividualStateListeners. The Creator is used to create the
problem specific Genotype with which the created Individual
is initialized.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.google.inject.Provider<I>protected final Set<IndividualStateListener> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractIndividualFactory(com.google.inject.Provider<I> individualProvider, Creator creator) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anIndividualStateListenerto eachIndividualthat is created by this class.create()Creates a newIndividual.Creates a newIndividualwith a specifiedGenotype.protected voidinjectListeners(Set<IndividualStateListener> listeners) TheIndividualStateListeners will be transmitted to eachIndividualthat is created by this class.voidRemoves anIndividualStateListenerthat is invoked if the state of anyIndividualchanges.
-
Field Details
-
creator
-
individualProvider
-
individualStateListeners
-
-
Constructor Details
-
AbstractIndividualFactory
- Parameters:
individualProvider- the provider that creates new individualscreator- the creator that creates random genotypes
-
-
Method Details
-
injectListeners
TheIndividualStateListeners will be transmitted to eachIndividualthat is created by this class. The listeners are invoked if the state of theIndividualchanges.- Parameters:
listeners- the listeners
-
addIndividualStateListener
Description copied from interface:IndividualFactoryAdds anIndividualStateListenerto eachIndividualthat is created by this class. This listener is invoked if the state of theIndividualchanges.- Specified by:
addIndividualStateListenerin interfaceIndividualFactory- Parameters:
listener- the listener that is invoked if the state of any individual changes- See Also:
-
create
Description copied from interface:IndividualFactoryCreates a newIndividual.- Specified by:
createin interfaceIndividualFactory- Returns:
- the built individual
-
create
Description copied from interface:IndividualFactoryCreates a newIndividualwith a specifiedGenotype.- Specified by:
createin interfaceIndividualFactory- Parameters:
genotype- the genotype of the individual- Returns:
- the built individual
-
removeIndividualStateListener
Description copied from interface:IndividualFactoryRemoves anIndividualStateListenerthat is invoked if the state of anyIndividualchanges. AllIndividuals created after this method call by thisIndividualFactorydo no longer use the listener.- Specified by:
removeIndividualStateListenerin interfaceIndividualFactory- Parameters:
listener- the listener that is invoked if the state of any individual changes- See Also:
-