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 Individuals 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
FieldsFields inherited from class org.opt4j.common.logger.AbstractLogger
evaluationCount, evaluationCountLast, evaluationStep, isFirst, iterationStep -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringTheStringseparating two columns.protected StringTheStringstarting a line comment.protected StringgetIndividual(Individual individual) Creates aStringrepresentation of the givenIndividual.protected StringgetStatistics(int iteration, int evaluation, double time) Statistics for the giveniterationandevaluation.protected PrintWriterinitWriter(String filename) Initialize the print write from a filenamevoidlogEvent(int iteration, int evaluation) Callback method called if the specific number of iterations or evaluations is reached.voidlogHeader(Collection<Objective> objectives) Writes the header.voidCallback method invoked once the optimization starts.voidCallback 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:AbstractLoggerCallback method invoked once the optimization starts.- Specified by:
optimizationStartedin classAbstractLogger
-
logEvent
public void logEvent(int iteration, int evaluation) Description copied from class:AbstractLoggerCallback method called if the specific number of iterations or evaluations is reached.- Specified by:
logEventin classAbstractLogger- Parameters:
iteration- the current iteration numberevaluation- the current evaluation number
-
optimizationStopped
public void optimizationStopped()Description copied from class:AbstractLoggerCallback method invoked once the optimization stops.- Specified by:
optimizationStoppedin classAbstractLogger
-
logHeader
Description copied from class:AbstractLoggerWrites the header.- Specified by:
logHeaderin classAbstractLogger- Parameters:
objectives- a collection of objectives
-
getColumnDelimiter
TheStringseparating two columns. The tab character ("\t") is the default, which leads to a tab separated values file format (TSV).- Returns:
- the delimiter
-
getIndividual
Creates aStringrepresentation of the givenIndividual. Per default, theValues of allObjectivesof the individual, separated bygetColumnDelimiter(), are returned. TheStringrepresentation of aValuemust not contain the tab character.- Parameters:
individual- the individual- Returns:
- the corresponding string
-
getStatistics
Statistics for the giveniterationandevaluation. 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
TheStringstarting a line comment. Default is the empty String ("") according to the TSV specification.- Returns:
- the comment delimiter
-