diff --git a/examples/analytical-function/example_analytical_function_testSequential.py b/examples/analytical-function/example_analytical_function_testSequential.py index dcbf7dcc889b5a1a74c40a34fb5f40d599396285..9abb57ef60da9cae387c80612f850d2220b5b2f8 100644 --- a/examples/analytical-function/example_analytical_function_testSequential.py +++ b/examples/analytical-function/example_analytical_function_testSequential.py @@ -238,6 +238,7 @@ if __name__ == "__main__": - exploration = 'Voronoi' creates mismatching numbers of candidates and weights - exploration = 'loocv' needs MetaModel.create_ModelError, which does not exist - exploration = 'dual annealing' restricted in what it allows as exploitation methods + - tradeoff = 'adaptive' perhaps not possible in the first AL iteration? The following combinations are running through: - BayesActDesign quite fast @@ -253,7 +254,7 @@ if __name__ == "__main__": tradeoff_schemes = [None, 'equal', 'epsilon-decreasing', 'adaptive'] #sampling_method = ['random', 'latin-hypercube', 'sobol', 'halton', # 'hammersley', 'chebyshev', 'grid'] - exploration_schemes = ['Voronoi', 'random', 'latin-hypercube', 'LOOCV', + exploration_schemes = ['Voronoi', 'global_mc', 'random', 'latin-hypercube', 'LOOCV', 'dual annealing'] exploration_schemes = ['random', 'dual annealing'] exploitation_schemes = ['BayesOptDesign', 'BayesActDesign', 'VarOptDesign', diff --git a/src/bayesvalidrox/surrogate_models/engine.py b/src/bayesvalidrox/surrogate_models/engine.py index 54f6bd888a379e1623280d78fa38f939b59a1b5e..08b3a05d1fffe44123d658fe00552f0135a8d6c2 100644 --- a/src/bayesvalidrox/surrogate_models/engine.py +++ b/src/bayesvalidrox/surrogate_models/engine.py @@ -488,6 +488,7 @@ class Engine: # self.MetaModel.ExpDesignFlag = 'sequential' # TODO: this is only a fix, remove as soon as possible to # avoid circular dependencies! + self.SeqDesign._y_hat_prev = self._y_hat_prev if self.ExpDesign.exploit_method.lower() == 'bayesoptdesign': self.SeqDesign.engine = self Xnew, updatedPrior = self.SeqDesign.choose_next_sample(TotalSigma2, diff --git a/src/bayesvalidrox/surrogate_models/sequential_design.py b/src/bayesvalidrox/surrogate_models/sequential_design.py index 1a3591a6ca4aa204ebc933fa840ab010fa4cba98..72779f022122a6a8218ff5e6054af5ad8bef1c88 100644 --- a/src/bayesvalidrox/surrogate_models/sequential_design.py +++ b/src/bayesvalidrox/surrogate_models/sequential_design.py @@ -597,6 +597,11 @@ class SequentialDesign: mseError = mean_squared_error(pce_y, y) # Mean squared CV - error for last design point + # TODO: _y_hat_prev is only calculated after the first sequential + # iteration scheme! Either work around this, or calculate + # anyway. + if self._y_hat_prev is None: + raise AttributeError('Adaptive tradeoff scheme cannot be used in the first sequential iteration!') pce_y_prev = np.array(list(self._y_hat_prev.values()))[:, 0] mseCVError = mean_squared_error(pce_y_prev, y)