MOEA Framework 2.12
API Specification

org.moeaframework.analysis.sensitivity
Class MetricFileWriter

java.lang.Object
  extended by org.moeaframework.analysis.sensitivity.MetricFileWriter
All Implemented Interfaces:
Closeable, OutputWriter

public class MetricFileWriter
extends Object
implements OutputWriter

Writes metric files. A metric file is the output of Evaluator and contains on each line one or more metrics separated by whitespace from one parameterization.

This writer will append the results to the file, if a previous file exists. By reading the previous file with a MetricFileReader, this writer will being appending after the last valid entry. Query the getNumberOfEntries() method to determine how many valid entries are contained in the file.

See Also:
MetricFileReader

Field Summary
static int NUMBER_OF_METRICS
          The number of metrics supported by MetricFileWriter.
 
Constructor Summary
MetricFileWriter(QualityIndicator qualityIndicator, File file)
          Constructs an output writer for writing metric files to the specified file.
 
Method Summary
 void append(ResultEntry entry)
          Evaluates the specified non-dominated population and outputs the resulting metrics to the file.
 void close()
           
 int getNumberOfEntries()
          Returns the number of entries in the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBER_OF_METRICS

public static final int NUMBER_OF_METRICS
The number of metrics supported by MetricFileWriter.

See Also:
Constant Field Values
Constructor Detail

MetricFileWriter

public MetricFileWriter(QualityIndicator qualityIndicator,
                        File file)
                 throws IOException
Constructs an output writer for writing metric files to the specified file. If the file already exists, a cleanup operation is first performed. The cleanup operation removes the last line if incomplete and records the number of correct lines in the file. The getNumberOfEntries() can then be used to resume evaluation from the last recorded entry.

Parameters:
qualityIndicator - the quality indicator for producing the metrics
file - the file to which the metrics are written
Throws:
IOException - if an I/O error occurred
Method Detail

getNumberOfEntries

public int getNumberOfEntries()
Description copied from interface: OutputWriter
Returns the number of entries in the file. If the file already existed, this returns the number of complete entries in the output file. This value is incremented on every invocation to the OutputWriter.append(org.moeaframework.analysis.sensitivity.ResultEntry) method.

Specified by:
getNumberOfEntries in interface OutputWriter
Returns:
the number of entries in the file

append

public void append(ResultEntry entry)
Evaluates the specified non-dominated population and outputs the resulting metrics to the file.

Specified by:
append in interface OutputWriter
Parameters:
entry - the non-dominated population and optional attributes

close

public void close()
Specified by:
close in interface Closeable

MOEA Framework 2.12
API Specification

Copyright 2009-2016 MOEA Framework. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage. Visit us on Github!