def _add_measured_configuration_to_experiment( self, configuration: Configuration) -> None: """ Save configuration after passing all checks. This method also sends an update to API (front-end). :param configuration: Configuration object. :return: None """ self.measured_configurations.append(configuration) if configuration.is_better(self.get_objectives_minimization(), self.get_objectives_priorities(), self.current_best_configurations[0]): # we do not need warm_startup_info anymore, since better configuration was found self.current_best_configurations[0].warm_startup_info = {} self.current_best_configurations = [configuration] self.database.update_record( collection_name="warm_startup_info", query={"Exp_unique_ID": self.unique_id}, new_val={"wsi": configuration.warm_startup_info}) else: # this configuration did not improve the previous solution, no need to keep track its solutions. configuration.warm_startup_info = {} self.database.write_one_record( "Measured_configurations", configuration.get_configuration_record()) self.send_state_to_db() self.api.send("new", "configuration", configurations=[configuration.parameters], results=[configuration.results]) self.logger.info("Adding to Experiment: %s" % configuration)
def default_configuration(self, default_configuration: Configuration): if self._is_valid_configuration_instance(default_configuration): if not self._default_configuration: self._default_configuration = default_configuration self.api.send( "default", "configuration", configurations=[default_configuration.parameters], results=[default_configuration.results]) self.measured_configurations.append(default_configuration) if not self.current_best_configurations: self.current_best_configurations = [default_configuration] self.database.write_one_record( "Measured_configurations", default_configuration.get_configuration_record()) self.database.write_one_record( collection_name="warm_startup_info", record={ "Exp_unique_ID": self.unique_id, "wsi": default_configuration.warm_startup_info }) else: raise ValueError( "The default Configuration was registered already.")