Class DefaultJSONSolutionSerializer<S extends Solution<S,I>,I extends Instance>

java.lang.Object
es.urjc.etsii.grafo.io.serializers.SolutionSerializer<S,I>
es.urjc.etsii.grafo.io.serializers.json.DefaultJSONSolutionSerializer<S,I>
Type Parameters:
S - type of the problem solution
I - type of the problem instance

public class DefaultJSONSolutionSerializer<S extends Solution<S,I>,I extends Instance> extends SolutionSerializer<S,I>
This class converts solution objects into their JSON equivalent by mapping the solution object variable names and value to JSON properties
  • Constructor Details

    • DefaultJSONSolutionSerializer

      public DefaultJSONSolutionSerializer(JSONConfig config)
      Construct a DefaultJSONSolutionSerializer object given the properties indicated in
      Parameters:
      config - configuration of the JSON Serializer
  • Method Details

    • export

      public void export(BufferedWriter writer, WorkUnitResult<S,I> result)
      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.

      JSON export method. Exports the given solution to the provided file in JSON format.

      Specified by:
      export in class SolutionSerializer<S extends Solution<S,I>,I extends Instance>
      Parameters:
      writer - Output, write data here
      result - Solution to export
    • export

      public void export(String folder, String suggestedFilename, WorkUnitResult<S,I> result)
      Custom export implementation. Exports the given solution to the provided file.

      JSON export method. Exports the given solution to the provided file in JSON format.

      Overrides:
      export in class SolutionSerializer<S extends Solution<S,I>,I extends Instance>
      Parameters:
      folder - Folder where solutions should be stored according to the configuration
      suggestedFilename - Suggested filename, can be ignored by the implementation
      result - result to export, contains solution and extra data