Package org.opt4j.common.logger
Class AbstractLogger
- java.lang.Object
-
- org.opt4j.common.logger.AbstractLogger
-
- All Implemented Interfaces:
IndividualStateListener,OptimizerIterationListener,OptimizerStateListener
- Direct Known Subclasses:
TsvLogger
public abstract class AbstractLogger extends Object implements OptimizerStateListener, OptimizerIterationListener, IndividualStateListener
TheAbstractLoggertriggers its refinement on specific events dependent on the iteration and evaluation count. EachAbstractLoggerhas to listen to the be registered as listener of theOptimizer(Opt4JModule.addOptimizerStateListener(Class)andOpt4JModule.addOptimizerIterationListener(Class)) and the state of theIndividual(Opt4JModule.addIndividualStateListener(Class).
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicIntegerevaluationCountprotected intevaluationCountLastprotected intevaluationStepprotected booleanisFirstprotected intiterationStep
-
Constructor Summary
Constructors Constructor Description AbstractLogger(int iterationStep, int evaluationStep)Constructs anAbstractLogger.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidinidividualStateChanged(Individual individual)Invoked if theIndividualchanges its state.voiditerationComplete(Optimizer optimizer, int iteration)Invoked if theOptimizercompletes an iteration.abstract voidlogEvent(int iteration, int evaluation)Callback method called if the specific number of iterations or evaluations is reached.abstract voidlogHeader(Collection<Objective> objectives)Writes the header.abstract voidoptimizationStarted()Callback method invoked once the optimization starts.voidoptimizationStarted(Optimizer optimizer)Invoked if theOptimizerstarts the optimization process.abstract voidoptimizationStopped()Callback method invoked once the optimization stops.voidoptimizationStopped(Optimizer optimizer)Invoked if theOptimizerstops the optimization process.
-
-
-
Field Detail
-
iterationStep
protected final int iterationStep
-
evaluationStep
protected final int evaluationStep
-
evaluationCount
protected final AtomicInteger evaluationCount
-
isFirst
protected boolean isFirst
-
evaluationCountLast
protected int evaluationCountLast
-
-
Constructor Detail
-
AbstractLogger
public AbstractLogger(int iterationStep, int evaluationStep)Constructs anAbstractLogger.- Parameters:
iterationStep- the number of iterations between two logging eventsevaluationStep- the number of evaluations between two logging events
-
-
Method Detail
-
logEvent
public abstract void logEvent(int iteration, int evaluation)Callback method called if the specific number of iterations or evaluations is reached.- Parameters:
iteration- the current iteration numberevaluation- the current evaluation number
-
logHeader
public abstract void logHeader(Collection<Objective> objectives)
Writes the header.- Parameters:
objectives- a collection of objectives
-
optimizationStarted
public abstract void optimizationStarted()
Callback method invoked once the optimization starts.
-
optimizationStopped
public abstract void optimizationStopped()
Callback method invoked once the optimization stops.
-
iterationComplete
public void iterationComplete(Optimizer optimizer, int iteration)
Description copied from interface:OptimizerIterationListenerInvoked if theOptimizercompletes an iteration.- Specified by:
iterationCompletein interfaceOptimizerIterationListener- Parameters:
optimizer- the optimizeriteration- the completed iteration
-
optimizationStarted
public void optimizationStarted(Optimizer optimizer)
Description copied from interface:OptimizerStateListenerInvoked if theOptimizerstarts the optimization process.- Specified by:
optimizationStartedin interfaceOptimizerStateListener- Parameters:
optimizer- the optimizer
-
optimizationStopped
public void optimizationStopped(Optimizer optimizer)
Description copied from interface:OptimizerStateListenerInvoked if theOptimizerstops the optimization process.- Specified by:
optimizationStoppedin interfaceOptimizerStateListener- Parameters:
optimizer- the optimizer
-
inidividualStateChanged
public void inidividualStateChanged(Individual individual)
Description copied from interface:IndividualStateListenerInvoked if theIndividualchanges its state.- Specified by:
inidividualStateChangedin interfaceIndividualStateListener- Parameters:
individual- the individual that changes the state
-
-