java.lang.Object
es.urjc.etsii.grafo.io.serializers.SolutionSerializer<S,I>
- Type Parameters:
S- Solution classI- Instance class
- Direct Known Subclasses:
DefaultJSONSolutionSerializer
Subclass to provide a custom implementation to export solutions to file.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new solution serializer with the given config -
Method Summary
Modifier and TypeMethodDescriptionabstract voidexport(BufferedWriter writer, WorkUnitResult<S, I> result) Custom export implementation.voidCustom export implementation.final voidWrite a solution to disk.protected StringgetFilename(String experimentName, String instanceName, String shortAlgName, String iterationId) Get filenamebooleanCheck if this serializer is enabledtoString()
-
Field Details
-
config
-
-
Constructor Details
-
SolutionSerializer
Create a new solution serializer with the given config- Parameters:
config- Common solution serializer configuration
-
-
Method Details
-
isEnabled
public boolean isEnabled()Check if this serializer is enabled- Returns:
- true if enabled and ready to export, false otherwise.
-
exportSolution
Write a solution to disk.- Parameters:
r- result of execution
-
getFilename
protected String getFilename(String experimentName, String instanceName, String shortAlgName, String iterationId) Get filename- Parameters:
experimentName- experiment name- Returns:
- the file name
-
export
Custom export implementation. Exports the given solution to the provided file.- Parameters:
folder- Folder where solutions should be stored according to the configurationsuggestedFilename- Suggested filename, can be ignored by the implementationresult- result to export, contains solution and extra data
-
export
Custom export implementation. Exports the given solution to disk. You do not need to handle IOExceptions. If an IOException occurs, the given solution export is skipped.- Parameters:
writer- Output, write data hereresult- Solution to export- Throws:
IOException- exception thrown in case something goes wrong
-
getConfig
-
toString
-