(self, num_iterations=10, X=None, y=None)
return self.incumbents[-1], self.incumbents_values[-1]
The main Bayesian optimization loop

        Parameters
        ----------
        num_iterations: int
            The number of iterations
        X: np.ndarray(N,D)
            Initial points that are already evaluated
        y: np.ndarray(N,1)
            Function values of the already evaluated points

        Returns
        -------
        np.ndarray(1,D)
            Incumbent
        np.ndarray(1,1)
            (Estimated) function value of the incumbent
The main Bayesian optimization loop
The main Bayesian optimization loop
def run(self, num_iterations=10, X=None, y=None):
        """
        The main Bayesian optimization loop

        Parameters
        ----------
        num_iterations: int
            The number of iterations
        X: np.ndarray(N,D)
            Initial points that are already evaluated
        y: np.ndarray(N,1)
            Function values of the already evaluated points

        Returns
        -------
        np.ndarray(1,D)
            Incumbent
        np.ndarray(1,1)
            (Estimated) function value of the incumbent
        """
        # Save the time where we start the Bayesian optimization procedure
        self.time_start = time.time()

        if X is None and y is None:

            # Initial design
            X = []
            y = []

            start_time_overhead = time.time()
            init = self.initial_design(self.lower,
                                       self.upper,
                                       self.init_points,
                                       rng=self.rng)
            time_overhead = (time.time() - start_time_overhead) / self.init_points

            for i, x in enumerate(init):

                logger.info("Evaluate: %s", x)

                start_time = time.time()
                new_y = self.objective_func(x)

                X.append(x)
                y.append(new_y)
                self.time_func_evals.append(time.time() - start_time)
                self.time_overhead.append(time_overhead)

                logger.info("Configuration achieved a performance of %f in %f seconds",
                            y[i], self.time_func_evals[i])

                # Use best point seen so far as incumbent
                best_idx = np.argmin(y)
                incumbent = X[best_idx]
                incumbent_value = y[best_idx]

                self.incumbents.append(incumbent.tolist())
                self.incumbents_values.append(incumbent_value)

                self.runtime.append(time.time() - self.start_time)

                if self.output_path is not None:
                    self.save_output(i)

            self.X = np.array(X)
            self.y = np.array(y)
        else:
            self.X = X
            self.y = y

        # Main Bayesian optimization loop
        for it in range(self.init_points, num_iterations):
            logger.info("Start iteration %d ... ", it)

            start_time = time.time()

            if it % self.train_interval == 0:
                do_optimize = True
            else:
                do_optimize = False

            # Choose next point to evaluate
            new_x = self.choose_next(self.X, self.y, do_optimize)

            self.time_overhead.append(time.time() - start_time)
            logger.info("Optimization overhead was %f seconds", self.time_overhead[-1])
            logger.info("Next candidate %s", str(new_x))

            # Evaluate
            start_time = time.time()
            new_y = self.objective_func(new_x)
            self.time_func_evals.append(time.time() - start_time)

            logger.info("Configuration achieved a performance of %f ", new_y)
            logger.info("Evaluation of this configuration took %f seconds", self.time_func_evals[-1])

            # Extend the data
            self.X = np.append(self.X, new_x[None, :], axis=0)
            self.y = np.append(self.y, new_y)

            # Estimate incumbent
            best_idx = np.argmin(self.y)
            incumbent = self.X[best_idx]
            incumbent_value = self.y[best_idx]

            self.incumbents.append(incumbent.tolist())
            self.incumbents_values.append(incumbent_value)
            logger.info("Current incumbent %s with estimated performance %f",
                        str(incumbent), incumbent_value)

            self.runtime.append(time.time() - self.start_time)

            if self.output_path is not None:
                self.save_output(it)

        logger.info("Return %s as incumbent with error %f ",
                    self.incumbents[-1], self.incumbents_values[-1])

        return self.incumbents[-1], self.incumbents_values[-1]
def run ( self , num_iterations = 10 , X = None , y = None ) : # Save the time where we start the Bayesian optimization procedure self . time_start = time . time ( ) if X is None and y is None : # Initial design X = [ ] y = [ ] start_time_overhead = time . time ( ) init = self . initial_design ( self . lower , self . upper , self . init_points , rng = self . rng ) time_overhead = ( time . time ( ) - start_time_overhead ) / self . init_points for i , x in enumerate ( init ) : logger . info ( "Evaluate: %s" , x ) start_time = time . time ( ) new_y = self . objective_func ( x ) X . append ( x ) y . append ( new_y ) self . time_func_evals . append ( time . time ( ) - start_time ) self . time_overhead . append ( time_overhead ) logger . info ( "Configuration achieved a performance of %f in %f seconds" , y [ i ] , self . time_func_evals [ i ] ) # Use best point seen so far as incumbent best_idx = np . argmin ( y ) incumbent = X [ best_idx ] incumbent_value = y [ best_idx ] self . incumbents . append ( incumbent . tolist ( ) ) self . incumbents_values . append ( incumbent_value ) self . runtime . append ( time . time ( ) - self . start_time ) if self . output_path is not None : self . save_output ( i ) self . X = np . array ( X ) self . y = np . array ( y ) else : self . X = X self . y = y # Main Bayesian optimization loop for it in range ( self . init_points , num_iterations ) : logger . info ( "Start iteration %d ... " , it ) start_time = time . time ( ) if it % self . train_interval == 0 : do_optimize = True else : do_optimize = False # Choose next point to evaluate new_x = self . choose_next ( self . X , self . y , do_optimize ) self . time_overhead . append ( time . time ( ) - start_time ) logger . info ( "Optimization overhead was %f seconds" , self . time_overhead [ - 1 ] ) logger . info ( "Next candidate %s" , str ( new_x ) ) # Evaluate start_time = time . time ( ) new_y = self . objective_func ( new_x ) self . time_func_evals . append ( time . time ( ) - start_time ) logger . info ( "Configuration achieved a performance of %f " , new_y ) logger . info ( "Evaluation of this configuration took %f seconds" , self . time_func_evals [ - 1 ] ) # Extend the data self . X = np . append ( self . X , new_x [ None , : ] , axis = 0 ) self . y = np . append ( self . y , new_y ) # Estimate incumbent best_idx = np . argmin ( self . y ) incumbent = self . X [ best_idx ] incumbent_value = self . y [ best_idx ] self . incumbents . append ( incumbent . tolist ( ) ) self . incumbents_values . append ( incumbent_value ) logger . info ( "Current incumbent %s with estimated performance %f" , str ( incumbent ) , incumbent_value ) self . runtime . append ( time . time ( ) - self . start_time ) if self . output_path is not None : self . save_output ( it ) logger . info ( "Return %s as incumbent with error %f " , self . incumbents [ - 1 ] , self . incumbents_values [ - 1 ] ) return self . incumbents [ - 1 ] , self . incumbents_values [ - 1 ]