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 Individual
s using a
given Provider
and sets the registered
IndividualStateListener
s. The Creator
is used to create the
problem specific Genotype
with which the created Individual
is initialized.-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.google.inject.Provider<I>
protected final Set<IndividualStateListener>
-
Constructor Summary
ConstructorDescriptionAbstractIndividualFactory
(com.google.inject.Provider<I> individualProvider, Creator creator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds anIndividualStateListener
to eachIndividual
that is created by this class.create()
Creates a newIndividual
.Creates a newIndividual
with a specifiedGenotype
.protected void
injectListeners
(Set<IndividualStateListener> listeners) TheIndividualStateListener
s will be transmitted to eachIndividual
that is created by this class.void
Removes anIndividualStateListener
that is invoked if the state of anyIndividual
changes.
-
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
TheIndividualStateListener
s will be transmitted to eachIndividual
that is created by this class. The listeners are invoked if the state of theIndividual
changes.- Parameters:
listeners
- the listeners
-
addIndividualStateListener
Description copied from interface:IndividualFactory
Adds anIndividualStateListener
to eachIndividual
that is created by this class. This listener is invoked if the state of theIndividual
changes.- Specified by:
addIndividualStateListener
in interfaceIndividualFactory
- Parameters:
listener
- the listener that is invoked if the state of any individual changes- See Also:
-
create
Description copied from interface:IndividualFactory
Creates a newIndividual
.- Specified by:
create
in interfaceIndividualFactory
- Returns:
- the built individual
-
create
Description copied from interface:IndividualFactory
Creates a newIndividual
with a specifiedGenotype
.- Specified by:
create
in interfaceIndividualFactory
- Parameters:
genotype
- the genotype of the individual- Returns:
- the built individual
-
removeIndividualStateListener
Description copied from interface:IndividualFactory
Removes anIndividualStateListener
that is invoked if the state of anyIndividual
changes. AllIndividual
s created after this method call by thisIndividualFactory
do no longer use the listener.- Specified by:
removeIndividualStateListener
in interfaceIndividualFactory
- Parameters:
listener
- the listener that is invoked if the state of any individual changes- See Also:
-