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
TheAbstractLogger
triggers its refinement on specific events dependent on the iteration and evaluation count. EachAbstractLogger
has 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 AtomicInteger
evaluationCount
protected int
evaluationCountLast
protected int
evaluationStep
protected boolean
isFirst
protected int
iterationStep
-
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 void
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
optimizationStarted()
Callback method invoked once the optimization starts.void
optimizationStarted(Optimizer optimizer)
Invoked if theOptimizer
starts the optimization process.abstract void
optimizationStopped()
Callback method invoked once the optimization stops.void
optimizationStopped(Optimizer optimizer)
Invoked if theOptimizer
stops 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:OptimizerIterationListener
Invoked if theOptimizer
completes an iteration.- Specified by:
iterationComplete
in interfaceOptimizerIterationListener
- Parameters:
optimizer
- the optimizeriteration
- the completed iteration
-
optimizationStarted
public void optimizationStarted(Optimizer optimizer)
Description copied from interface:OptimizerStateListener
Invoked if theOptimizer
starts the optimization process.- Specified by:
optimizationStarted
in interfaceOptimizerStateListener
- Parameters:
optimizer
- the optimizer
-
optimizationStopped
public void optimizationStopped(Optimizer optimizer)
Description copied from interface:OptimizerStateListener
Invoked if theOptimizer
stops the optimization process.- Specified by:
optimizationStopped
in interfaceOptimizerStateListener
- Parameters:
optimizer
- the optimizer
-
inidividualStateChanged
public void inidividualStateChanged(Individual individual)
Description copied from interface:IndividualStateListener
Invoked if theIndividual
changes its state.- Specified by:
inidividualStateChanged
in interfaceIndividualStateListener
- Parameters:
individual
- the individual that changes the state
-
-