results.py 1017 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import json
  2. class SolverResult:
  3. _data = dict()
  4. status = None
  5. time_elapsed = None
  6. condition = None
  7. constraints = None
  8. objectives = None
  9. variables = None
  10. solutions = None
  11. def __init__(self):
  12. pass
  13. def read(self, file):
  14. with open(file) as f:
  15. self._data = json.load(f)
  16. solver = self._data['Solver'][0]
  17. problem = self._data['Problem'][0]
  18. solution = self._data['Solution'][0]
  19. self.status = solver['Status']
  20. self.time_elapsed = solver['Time']
  21. self.condition = solver['Termination condition']
  22. self.status = solver['Status']
  23. self.constraints = problem['Number of constraints']
  24. self.objectives = problem['Number of objectives']
  25. self.variables = problem['Number of variables']
  26. self.solutions = solution['number of solutions']
  27. sr = SolverResult()
  28. sr.read('results2.json')
  29. print(sr.time_elapsed, sr.status, sr.condition)