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
The
AbstractLogger
triggers its refinement on specific events
dependent on the iteration and evaluation count. Each AbstractLogger
has to listen to the be registered as listener of the Optimizer
(
Opt4JModule.addOptimizerStateListener(Class)
and
Opt4JModule.addOptimizerIterationListener(Class)
) and the state of
the Individual
(Opt4JModule.addIndividualStateListener(Class)
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final AtomicInteger
protected int
protected final int
protected boolean
protected final int
-
Constructor Summary
ConstructorDescriptionAbstractLogger
(int iterationStep, int evaluationStep) Constructs anAbstractLogger
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
inidividualStateChanged
(Individual individual) Invoked if theIndividual
changes its state.void
iterationComplete
(Optimizer optimizer, int iteration) Invoked if theOptimizer
completes an iteration.abstract void
logEvent
(int iteration, int evaluation) Callback method called if the specific number of iterations or evaluations is reached.abstract void
logHeader
(Collection<Objective> objectives) Writes the header.abstract void
Callback method invoked once the optimization starts.void
optimizationStarted
(Optimizer optimizer) Invoked if theOptimizer
starts the optimization process.abstract void
Callback method invoked once the optimization stops.void
optimizationStopped
(Optimizer optimizer) Invoked if theOptimizer
stops the optimization process.
-
Field Details
-
iterationStep
protected final int iterationStep -
evaluationStep
protected final int evaluationStep -
evaluationCount
-
isFirst
protected boolean isFirst -
evaluationCountLast
protected int evaluationCountLast
-
-
Constructor Details
-
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 Details
-
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
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
Description copied from interface:OptimizerIterationListener
Invoked if theOptimizer
completes an iteration.- Specified by:
iterationComplete
in interfaceOptimizerIterationListener
- Parameters:
optimizer
- the optimizeriteration
- the completed iteration
-
optimizationStarted
Description copied from interface:OptimizerStateListener
Invoked if theOptimizer
starts the optimization process.- Specified by:
optimizationStarted
in interfaceOptimizerStateListener
- Parameters:
optimizer
- the optimizer
-
optimizationStopped
Description copied from interface:OptimizerStateListener
Invoked if theOptimizer
stops the optimization process.- Specified by:
optimizationStopped
in interfaceOptimizerStateListener
- Parameters:
optimizer
- the optimizer
-
inidividualStateChanged
Description copied from interface:IndividualStateListener
Invoked if theIndividual
changes its state.- Specified by:
inidividualStateChanged
in interfaceIndividualStateListener
- Parameters:
individual
- the individual that changes the state
-