test_on_effective_size_drop.cpp
Go to the documentation of this file.
1 // Copyright 2024 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <gtest/gtest.h>
16 
17 #include <vector>
18 
20 
21 namespace {
22 
23 TEST(OnEffectiveSizeDropPolicy, TriggerOnDropBelow30Percent) {
25  auto weights1 = std::vector{1.0, 1.0, 1.0, 1.0, 1.0};
26  auto weights2 = std::vector{1.0, 0.0, 0.0, 0.0, 0.0}; // Fewer effective particles
27 
28  ASSERT_FALSE(policy(weights1)); // Initial ESS should not trigger the policy
29  ASSERT_TRUE(policy(weights2)); // ESS drops below 30% on the second call, triggering the policy
30 }
31 
32 TEST(OnEffectiveSizeDropPolicy, NoTriggerAbove30Percent) {
34  auto weights1 = std::vector{1.0, 1.0, 1.0, 1.0, 1.0};
35  auto weights2 = std::vector{1.0, 1.0, 0.0, 0.0, 0.0}; // Still above 30%
36 
37  ASSERT_FALSE(policy(weights1)); // Initial ESS should not trigger the policy
38  ASSERT_FALSE(policy(weights1)); // ESS remains above 30%, no trigger
39 }
40 
41 TEST(OnEffectiveSizeDropPolicy, TriggerOnDropBelowDefaultThreshold) {
43  auto weights = std::vector{1.0, 1.0, 0.0, 0.0, 0.0};
44 
45  ASSERT_TRUE(policy(weights)); // ESS drops below 50%
46 }
47 
48 } // namespace
on_effective_size_drop.hpp
Defines a policy for triggering an action based on the Effective Sample Size (ESS) metric.
beluga::policies::on_effective_size_drop
constexpr policy< detail::on_effective_size_drop_policy > on_effective_size_drop
Policy that can be used to trigger an action based on the Effective Sample Size (ESS) metric.
Definition: on_effective_size_drop.hpp:64
beluga::views::weights
constexpr auto weights
Definition: particles.hpp:34
beluga::TEST
TEST(Bresenham, MultiPassGuarantee)
Definition: test_bresenham.cpp:27


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53