Package org.opt4j.common.logger
Class TsvLogger
java.lang.Object
org.opt4j.common.logger.AbstractLogger
org.opt4j.common.logger.TsvLogger
- All Implemented Interfaces:
Logger
,IndividualStateListener
,OptimizerIterationListener
,OptimizerStateListener
The
TsvLogger
writes all Individual
s from the Archive
to the specified file. It can be configured to write the data each
iterationStep
iterations or each evaluationStep
evaluations.
The file format is TSV (tab separated values), according to the Definition of tab-separated-values (tsv) by IANA.-
Field Summary
Fields inherited from class org.opt4j.common.logger.AbstractLogger
evaluationCount, evaluationCountLast, evaluationStep, isFirst, iterationStep
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
TheString
separating two columns.protected String
TheString
starting a line comment.protected String
getIndividual
(Individual individual) Creates aString
representation of the givenIndividual
.protected String
getStatistics
(int iteration, int evaluation, double time) Statistics for the giveniteration
andevaluation
.protected PrintWriter
initWriter
(String filename) Initialize the print write from a filenamevoid
logEvent
(int iteration, int evaluation) Callback method called if the specific number of iterations or evaluations is reached.void
logHeader
(Collection<Objective> objectives) Writes the header.void
Callback method invoked once the optimization starts.void
Callback method invoked once the optimization stops.Methods inherited from class org.opt4j.common.logger.AbstractLogger
inidividualStateChanged, iterationComplete, optimizationStarted, optimizationStopped
-
Field Details
-
archive
-
-
Constructor Details
-
TsvLogger
Creates anTsvLogger
.
-
-
Method Details
-
initWriter
Initialize the print write from a filename- Parameters:
filename
- the filename- Returns:
- the print writer
-
optimizationStarted
public void optimizationStarted()Description copied from class:AbstractLogger
Callback method invoked once the optimization starts.- Specified by:
optimizationStarted
in classAbstractLogger
-
logEvent
public void logEvent(int iteration, int evaluation) Description copied from class:AbstractLogger
Callback method called if the specific number of iterations or evaluations is reached.- Specified by:
logEvent
in classAbstractLogger
- Parameters:
iteration
- the current iteration numberevaluation
- the current evaluation number
-
optimizationStopped
public void optimizationStopped()Description copied from class:AbstractLogger
Callback method invoked once the optimization stops.- Specified by:
optimizationStopped
in classAbstractLogger
-
logHeader
Description copied from class:AbstractLogger
Writes the header.- Specified by:
logHeader
in classAbstractLogger
- Parameters:
objectives
- a collection of objectives
-
getColumnDelimiter
TheString
separating two columns. The tab character ("\t") is the default, which leads to a tab separated values file format (TSV).- Returns:
- the delimiter
-
getIndividual
Creates aString
representation of the givenIndividual
. Per default, theValue
s of allObjectives
of the individual, separated bygetColumnDelimiter()
, are returned. TheString
representation of aValue
must not contain the tab character.- Parameters:
individual
- the individual- Returns:
- the corresponding string
-
getStatistics
Statistics for the giveniteration
andevaluation
. Per default, the iteration, the number of evaluations and the optimization run time in milliseconds, separated bygetColumnDelimiter()
, are returned.- Parameters:
iteration
- the current iterationevaluation
- the current number of evaluationstime
- the current runtime of the optimization- Returns:
- the corresponding string
-
getCommentDelimiter
TheString
starting a line comment. Default is the empty String ("") according to the TSV specification.- Returns:
- the comment delimiter
-