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
public class TsvLogger extends AbstractLogger implements Logger
TheTsvLoggerwrites allIndividuals from theArchiveto the specified file. It can be configured to write the data eachiterationStepiterations or eachevaluationStepevaluations. The file format is TSV (tab separated values), according to the Definition of tab-separated-values (tsv) by IANA.
-
-
Field Summary
Fields Modifier and Type Field Description protected Archivearchive-
Fields inherited from class org.opt4j.common.logger.AbstractLogger
evaluationCount, evaluationCountLast, evaluationStep, isFirst, iterationStep
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetColumnDelimiter()TheStringseparating two columns.protected StringgetCommentDelimiter()TheStringstarting 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.voidoptimizationStarted()Callback method invoked once the optimization starts.voidoptimizationStopped()Callback method invoked once the optimization stops.-
Methods inherited from class org.opt4j.common.logger.AbstractLogger
inidividualStateChanged, iterationComplete, optimizationStarted, optimizationStopped
-
-
-
-
Field Detail
-
archive
protected final Archive archive
-
-
Method Detail
-
initWriter
protected PrintWriter initWriter(String filename)
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
public void logHeader(Collection<Objective> objectives)
Description copied from class:AbstractLoggerWrites the header.- Specified by:
logHeaderin classAbstractLogger- Parameters:
objectives- a collection of objectives
-
getColumnDelimiter
protected String 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
protected String getIndividual(Individual individual)
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
protected String getStatistics(int iteration, int evaluation, double time)
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
-
-