public class ResultFileWriter extends java.lang.Object implements OutputWriter
#
character.
Text contained on these lines after the #
character are ignored.
An entry contains two pieces of data: 1) properties which are defined on lines starting with //
in the
same format as TypedProperties
; and 2) lines containing a sequence of floating-point numbers listing,
in order, the real-valued decision variables and objectives. Each decision variable is separated by one or more
whitespace characters. Decision variables that can not be encoded appear as -
. The writer will attempt to
output the data in a human-readable format, but falls back on Base64 encoded serialized objects to store
serializable variables.
Complete entries are always terminated by a line starting with the #
character. Incomplete entries, such
as those with the incorrect number of decision variables or objectives, are automatically removed.
When appending is enabled, this will attempt to recover any valid records from the previous file. Query the
getNumberOfEntries()
method to determine how many valid entries were recovered.
ResultFileReader
Modifier and Type | Class and Description |
---|---|
static class |
ResultFileWriter.Settings
The settings used when writing result files.
|
OutputWriter.CleanupStrategy
Constructor and Description |
---|
ResultFileWriter(Problem problem,
java.io.File file)
Constructs a result file writer with default settings.
|
ResultFileWriter(Problem problem,
java.io.File file,
ResultFileWriter.Settings settings)
Constructs a result file writer for writing the decision variables and objectives of a sequence of
non-dominated populations to a file.
|
Modifier and Type | Method and Description |
---|---|
void |
append(ResultEntry entry)
Appends the decision variables, objectives and optional properties to the output file.
|
void |
close() |
java.lang.String |
encode(Variable variable)
Encodes the decision variable into a string representation that can be safely written to a result file.
|
int |
getNumberOfEntries()
Returns the number of entries written to the result file.
|
public ResultFileWriter(Problem problem, java.io.File file) throws java.io.IOException
problem
- the problemfile
- the file to which the results are storedjava.io.IOException
- if an I/O error occurredpublic ResultFileWriter(Problem problem, java.io.File file, ResultFileWriter.Settings settings) throws java.io.IOException
problem
- the problemfile
- the file to which the results are storedsettings
- the settings to use when writing the result filejava.io.IOException
- if an I/O error occurredpublic int getNumberOfEntries()
getNumberOfEntries
in interface OutputWriter
public void append(ResultEntry entry) throws java.io.IOException
append
in interface OutputWriter
entry
- the entry to writejava.io.IOException
- if an I/O error occurredpublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public java.lang.String encode(Variable variable)
"-"
will be returned and a warning message printed.variable
- the decision variable to encodeCopyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.