def restore(self): print "Restoring Profile." data = State.get_data(self.version, self.StateID) q = False for inputsize in data: try: algdata = inputsize["Algorithm"] except: inputsize = { "ResourceVariables": self.variables, "InputParameters": self.parameters, "Algorithm": {} } State.checkpoint(self.version, self.StateID, data) break if algdata != None and algdata != []: if inputsize["InputParameters"] == self.parameters: q = True self.strategy.update_state(algdata) #if profiling with the input size was finished go to the next one if not self.strategy.stop_condition(): break if not q: return [] return data
def restore(self): #load state data = State.get_data(self.version, self.StateID) for inputsize in data: try: algdata = inputsize["Methodology"] except: inputsize = { "Input": self.newinput, "BenchmarkInput": self.benchmark_input, "Methodology": {}, } State.checkpoint(self.version, self.StateID, data) continue if not (algdata in [None, {}, []]): self.benchmark_input = inputsize["BenchmarkInput"] self.benchmark_solutions = None for sol in self.profiling_solutions: if sol["Input"] == self.benchmark_input: self.benchmark_solutions = sol["Configurations"] if not self.benchmark_solutions: #the benchmark input from the save file doesn't have any solution explored self.benchmark_input = self.profiling_solutions[-1][ "Input"] self.benchmark_solutions = self.profiling_solutions[-1][ "Configurations"] self.strategy.update_state(algdata) #if profiling with the input size was finished go to the next one if not self.strategy.stop_condition(): break return data
def restore(self): if self.Data == {}: #load state for v in self.versions: version = ".".join(map(lambda s: str(s), v)) data = State.get_data(version, self.StateID) if data in [None, {}, []]: continue self.Data[version] = data[0]
def get_explored_solutions(self): data = State.get_data(self.version, self.StateID) if data in [None, []]: return self.variables, None solutions = [] for info in data: solutions.append({ "Input": info["InputParameters"], "Configurations": info["Algorithm"]["solutions"] }) return self.variables, solutions
def save_state(self): print "Save state to file." data = State.get_data(self.version, self.StateID) algdata = self.strategy.get_state() info = { "Input": self.newinput, "BenchmarkInput": self.benchmark_input, "Methodology": algdata } q = False for inputsize in data: if inputsize["Input"] == self.newinput: inputsize.update(info) q = True if not q: data.append(info) State.checkpoint(self.version, self.StateID, data)
def save_state(self): print "Save state to file." data = State.get_data(self.version, self.StateID) algdata = self.strategy.get_state() info = { "ResourceVariables": self.variables, "InputParameters": self.parameters, "Algorithm": algdata } q = False for inputsize in data: if inputsize["InputParameters"] == self.parameters: inputsize.update(info) q = True if not q: data.append(info) State.checkpoint(self.version, self.StateID, data)