37#include "ompl/base/samplers/deterministic/HaltonSequence.h"
42#include <boost/math/special_functions/prime.hpp>
70 i = std::floor(i / base_);
86 if (bases.size() != dimensions)
88 OMPL_WARN(
"Number of bases does not match dimensions. Using first n primes instead.");
93 for (
auto base : bases)
95 halton_sequences_1d_[i].setBase(base);
103 std::vector<double> samples;
104 for (
auto &seq : halton_sequences_1d_)
106 samples.push_back(seq.sample());
111 void HaltonSequence::setBasesToPrimes()
114 unsigned int current = 2;
115 for (
unsigned int i = 0; i < dimensions_; i++)
117 current = boost::math::prime(i);
118 halton_sequences_1d_[i].setBase(current);
An abstract class for deterministic sequences in arbitrary dimensions.
void setBase(unsigned int base)
Sets the base of the halton sequence.
double sample()
Returns the next sample in the interval [0,1].
HaltonSequence1D()
Constructor.
std::vector< double > sample() override
Returns the next sample in the interval [0,1].
HaltonSequence(unsigned int dimensions)
Constructor, only specifiying the dimensions, first n primes will be used as bases.
#define OMPL_WARN(fmt,...)
Log a formatted warning string.
Main namespace. Contains everything in this library.