def persist_to_file(self, results, file_path): """ Persist simulation results to a file in YAML format. :param results: simulation results to be persisted :param file_path: file to which the simulation results are written """ stream = file(file_path, 'w') yaml.dump(util.sanitize_results(results), stream)
def plot2d_from_memory(self, results, x_param, y_param, output_filename, title="", x_label="", y_label=""): """ Plot two-dimensional simulation results from a python data structure in memory. :param results: simulation results to be plotted :param x_param: parameter of the simulation results to be used on the x axis :param y_param: parameter of the simulation results to be used on the y axis :param output_filename: file to write the plot to :param title: title of the plot :param x_label: name of the plot x axis :param y_label: name of the y axis """ params = self._get_corresponding_results(util.sanitize_results(results), x_param, y_param) self._plot2d(util.strip_unit(params[0]), util.strip_unit(params[1]), output_filename, title, x_label, y_label)
def run_simulations(self, tag): simulation_scenarios = self.generator.generate_memory() #print len(simulation_scenarios) automator_input = [] for scenario in simulation_scenarios: automator_entry = {} automator_entry["parameters"] = scenario automator_entry["strategies"] = None automator_input.append(automator_entry) results, fails = self.automator.run(automator_input, tag) self.persistence.initialise_database_client() sanitized_results = sanitize_results(results) #print sanitized_results self.persistence.persist_to_database(self.config["Persistence"]["database"]["collection_name"], sanitized_results) return results, fails
def run_simulations(self, tag): simulation_scenarios = self.generator.generate_memory() #print len(simulation_scenarios) automator_input = [] for scenario in simulation_scenarios: automator_entry = {} automator_entry["parameters"] = scenario automator_entry["strategies"] = None automator_input.append(automator_entry) results, fails = self.automator.run(automator_input, tag) self.persistence.initialise_database_client() sanitized_results = sanitize_results(results) #print sanitized_results self.persistence.persist_to_database( self.config["Persistence"]["database"]["collection_name"], sanitized_results) return results, fails
def plot2d_from_memory(self, results, x_param, y_param, output_filename, title="", x_label="", y_label=""): """ Plot two-dimensional simulation results from a python data structure in memory. :param results: simulation results to be plotted :param x_param: parameter of the simulation results to be used on the x axis :param y_param: parameter of the simulation results to be used on the y axis :param output_filename: file to write the plot to :param title: title of the plot :param x_label: name of the plot x axis :param y_label: name of the y axis """ params = self._get_corresponding_results( util.sanitize_results(results), x_param, y_param) self._plot2d(util.strip_unit(params[0]), util.strip_unit(params[1]), output_filename, title, x_label, y_label)