| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import json
- class SolverResult:
- _data = dict()
- status = None
- time_elapsed = None
- condition = None
- constraints = None
- objectives = None
- variables = None
- solutions = None
- def __init__(self):
- pass
- def read(self, file):
- with open(file) as f:
- self._data = json.load(f)
- solver = self._data['Solver'][0]
- problem = self._data['Problem'][0]
- solution = self._data['Solution'][0]
- self.status = solver['Status']
- self.time_elapsed = solver['Time']
- self.condition = solver['Termination condition']
- self.status = solver['Status']
- self.constraints = problem['Number of constraints']
- self.objectives = problem['Number of objectives']
- self.variables = problem['Number of variables']
- self.solutions = solution['number of solutions']
- sr = SolverResult()
- sr.read('results2.json')
- print(sr.time_elapsed, sr.status, sr.condition)
|