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 Details

    • iterationStep

      protected final int iterationStep
    • evaluationStep

      protected final int evaluationStep
    • evaluationCount

      protected final AtomicInteger evaluationCount
    • isFirst

      protected boolean isFirst
    • evaluationCountLast

      protected int evaluationCountLast
  • Constructor Details

    • AbstractLogger

      public AbstractLogger(int iterationStep, int evaluationStep)
      Constructs an AbstractLogger.
      Parameters:
      iterationStep - the number of iterations between two logging events
      evaluationStep - 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 number
      evaluation - 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 the Optimizer completes an iteration.
      Specified by:
      iterationComplete in interface OptimizerIterationListener
      Parameters:
      optimizer - the optimizer
      iteration - the completed iteration
    • optimizationStarted

      public void optimizationStarted(Optimizer optimizer)
      Description copied from interface: OptimizerStateListener
      Invoked if the Optimizer starts the optimization process.
      Specified by:
      optimizationStarted in interface OptimizerStateListener
      Parameters:
      optimizer - the optimizer
    • optimizationStopped

      public void optimizationStopped(Optimizer optimizer)
      Description copied from interface: OptimizerStateListener
      Invoked if the Optimizer stops the optimization process.
      Specified by:
      optimizationStopped in interface OptimizerStateListener
      Parameters:
      optimizer - the optimizer
    • inidividualStateChanged

      public void inidividualStateChanged(Individual individual)
      Description copied from interface: IndividualStateListener
      Invoked if the Individual changes its state.
      Specified by:
      inidividualStateChanged in interface IndividualStateListener
      Parameters:
      individual - the individual that changes the state