de.kumpe.hadooptimizer
Class OptimizerConfiguration<I>

java.lang.Object
  extended by de.kumpe.hadooptimizer.OptimizerConfiguration<I>
Type Parameters:
I - the individuals' type
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
EaOptimizerConfigurationBase

public abstract class OptimizerConfiguration<I>
extends Object
implements Serializable, Cloneable

The base class of all Optimizer configurations.

Subclasses have to override clone() to cast the result to themself and validate() to validate them.

Author:
Christian Kumpe
See Also:
Serialized Form

Constructor Summary
OptimizerConfiguration()
           
 
Method Summary
 OptimizerConfiguration<I> clone()
          Returns a shallow copy of this configuration.
static
<I,T extends OptimizerConfiguration<I>>
T
deepClone(T original)
           
 boolean equals(Object obj)
           
 PopulationReader<I> getPopulationReader()
           
 PopulationWriter<I> getPopulationWriter()
           
 RandomGeneratorFactory getRandomGeneratorFactory()
           
 int hashCode()
           
protected  void injectRandomGenerator(Object instance, org.apache.commons.math.random.RandomGenerator randomGenerator)
          Inject the given RandomGenerator object into the passed instance, if instance is implementing NeedsRandomGenerator.
 void injectRandomGenerator(org.apache.commons.math.random.RandomGenerator randomGenerator)
          Will inject the given RandomGenerator instance into all contained components which are implementing NeedsRandomGenerator.
 void setPopulationReader(PopulationReader<I> populationReader)
           
 void setPopulationWriter(PopulationWriter<I> populationWriter)
           
 void setRandomGeneratorFactory(RandomGeneratorFactory randomGeneratorFactory)
           
 void validate()
          Validates the configuration for completeness and correctness.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptimizerConfiguration

public OptimizerConfiguration()
Method Detail

clone

public OptimizerConfiguration<I> clone()
Returns a shallow copy of this configuration. This will not clone the configuration's components.

Subclasses should override this method to cast the result to themself.

Overrides:
clone in class Object
Returns:
the shallow copy of this configuration

deepClone

public static <I,T extends OptimizerConfiguration<I>> T deepClone(T original)
Returns:
the deep copy of the specified configuration

validate

public void validate()
Validates the configuration for completeness and correctness.

Subclasses have to override this method, then first call this method from the superclass and then do their own additional validation.

Verifies that a populationReader and populationWriter has been set.

Throws:
IllegalStateException - if this configuration is not valid

injectRandomGenerator

public void injectRandomGenerator(org.apache.commons.math.random.RandomGenerator randomGenerator)
Will inject the given RandomGenerator instance into all contained components which are implementing NeedsRandomGenerator.

Subclasses must override this method, if they contain additional components. Then first call this method from the superclass and then call injectRandomGenerator(Object, RandomGenerator) for their additional components.

Calls injectRandomGenerator(Object, RandomGenerator) on the given populationReader and populationWriter.

Parameters:
randomGenerator - the RandomGenerator instance to inject

injectRandomGenerator

protected final void injectRandomGenerator(Object instance,
                                           org.apache.commons.math.random.RandomGenerator randomGenerator)
Inject the given RandomGenerator object into the passed instance, if instance is implementing NeedsRandomGenerator.

Parameters:
instance - the instance for injecting the randomGenerator, if needed
randomGenerator - the RandomGenerator object to inject

getPopulationReader

public final PopulationReader<I> getPopulationReader()
Returns:
the configured PopulationReader; null if none has been set

setPopulationReader

public final void setPopulationReader(PopulationReader<I> populationReader)
Parameters:
populationReader - the PopulationReader for this configuration
Throws:
NullPointerException - if populationReader is null

getPopulationWriter

public final PopulationWriter<I> getPopulationWriter()
Returns:
the configured PopulationWriter; null if none has been set

setPopulationWriter

public final void setPopulationWriter(PopulationWriter<I> populationWriter)
Parameters:
populationWriter - the PopulationWriter for this configuration
Throws:
NullPointerException - if populationWriter is null

getRandomGeneratorFactory

public RandomGeneratorFactory getRandomGeneratorFactory()
Returns:
the configured RandomGeneratorFactory; per default this returns a factory which creates instances of Well44497b

setRandomGeneratorFactory

public void setRandomGeneratorFactory(RandomGeneratorFactory randomGeneratorFactory)
Parameters:
randomGeneratorFactory - the RandomGeneratorFactory for this configuration
Throws:
NullPointerException - if randomGeneratorFactory is null

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2011 Christian Kumpe. All Rights Reserved.