From 859ac5bc8ffe854cb5b29c1eb89ce5d56db10e12 Mon Sep 17 00:00:00 2001 From: Niko Feith Date: Wed, 12 Jul 2023 17:56:20 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=9EAcquistionFunctions/PreferenceExpected?= =?UTF-8?q?Improvement.py=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PreferenceExpectedImprovement.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/AcquistionFunctions/PreferenceExpectedImprovement.py b/AcquistionFunctions/PreferenceExpectedImprovement.py index b69595c..829b06b 100644 --- a/AcquistionFunctions/PreferenceExpectedImprovement.py +++ b/AcquistionFunctions/PreferenceExpectedImprovement.py @@ -22,10 +22,19 @@ class PreferenceExpectedImprovement: pass def rejection_sampling(self): - samples = np.empty((self.nr_samples, self.nr_dims)) - i = 0 - while i < self.nr_samples: - pass + samples = np.empty((0, self.nr_dims)) + while samples.shape[0] < self.nr_samples: + # sample from the multi variate gaussian distribution + sample = self.rng.multivariate_normal( + self.proposal_model_mean, + self.proposal_model_covariance + ) + + # check if the sample is within the bounds + if np.all(sample >= self.lower_bound) and np.all(sample <= self.upper_bound): + samples = np.append(samples, [sample], axis=0) + + return samples def expected_improvement(self):