Skip to content

Conversation

Konikz
Copy link

@Konikz Konikz commented Apr 5, 2025

Description

This PR improves the efficiency of the burn-in phase in sampling functions by avoiding unnecessary storage and deletion of burn-in points. Instead of storing points during burn-in and then clearing them, we now use a NoOpWalkPolicy that simply discards these points.

Changes

  • Added NoOpWalkPolicy that discards points during burn-in phase
  • Modified sampling functions to use NoOpWalkPolicy instead of store-and-clear approach
  • Added performance test to verify improvements

Before

if (nburns > 0) {
    RandomPointGenerator::apply(P, p, nburns, walk_len, randPoints,
                                push_back_policy, rng);
    randPoints.clear();
}

After

if (nburns > 0) {
    RandomPointGenerator::apply(P, p, nburns, walk_len, randPoints,
                                no_op_policy, rng);
}

Benefits

  • Eliminates unnecessary memory allocations
  • Reduces memory usage during burn-in phase
  • Maintains same functionality and API compatibility

Testing

Added burn_in_efficiency_test.cpp that compares performance and verifies correctness of both implementations.

Fixes #180

…nctions - Add NoOpWalkPolicy and update tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inefficient handling of burn in phase in sampling functions
1 participant