Class JsonSolution


  • public class JsonSolution
    extends Object
    This class represents the solution of a Linear Programming (LP) problem in JSON format. The generated JSON follows this structure:
     {
         "meta": {
             // Information about the processing (duration, number of threads, etc.)
         },
         "objectiveType": "min",
         "status": "optimal",
         "solution": {
             "objectiveValue": 1244.0,
             "variables": {
                 // Variable values
             }
         },
         "relaxedSolution": {
             "objectiveValue": 1244.0,
             "variables": {
                 // Relaxed solution variable values
             }
         }
     }
     
    • Method Detail

      • getJsonObject

        public jakarta.json.JsonObject getJsonObject()
        Returns the JSON object built using the jakarta.json library.
        Returns:
        JsonObject representing the solution.
      • saveToFile

        public JsonSolution saveToFile​(String path)
                                throws IOException
        Saves the JSON object to an external file.
        Parameters:
        path - The file path where the JSON should be saved.
        Returns:
        The current JsonSolution instance.
        Throws:
        IOException - if an I/O error occurs during the writing process.
      • toString

        public String toString()
        Returns the JSON representation of the solution as a String.
        Overrides:
        toString in class Object
        Returns:
        A String representation of the JSON solution.