Interface OutputWriter

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
MetricFileWriter, ResultFileWriter

public interface OutputWriter extends Closeable
Writes output files. As they allow the Evaluator to automatically resume itself at the last known good result, output writers are expected to cleanup the file and return the number of valid entries through getNumberOfEntries().
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Common settings when creating an output writer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Appends the specified non-dominated population and optional attributes to the file.
    int
    Returns the number of entries in the file.
    static boolean
    replace(File source, File destination)
    Replaces the destination file with the source file, but only if content is different.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • getNumberOfEntries

      int getNumberOfEntries()
      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 append(org.moeaframework.analysis.io.ResultEntry) method.
      Returns:
      the number of entries in the file
    • append

      void append(ResultEntry entry) throws IOException
      Appends the specified non-dominated population and optional attributes to the file.
      Parameters:
      entry - the non-dominated population and optional attributes
      Throws:
      IOException - if an I/O error occurred
    • replace

      static boolean replace(File source, File destination) throws IOException
      Replaces the destination file with the source file, but only if content is different. This avoids changing the modification timestamp on the file if the files are identical.
      Parameters:
      source - the source file, which is required to exist
      destination - the destination file, which might not exist
      Returns:
      true if the destination was updated; false otherwise
      Throws:
      IOException - if an I/O error occurred