pub trait Sampler<S> {
// Required method
fn sample<R: Rng + ?Sized>(&mut self, rng: &mut R) -> S;
// Provided method
fn sample_informed<Sp, R>(
&mut self,
space: &Sp,
rng: &mut R,
start: &S,
goal: &S,
max_cost: f64,
) -> Option<S>
where Sp: StateSpace<State = S>,
R: Rng + ?Sized { ... }
}Expand description
Draws states for a planner.
&mut self lets stateful samplers (low-discrepancy sequences, informed samplers) advance.
The RNG is borrowed, never owned, so one seeded RNG drives a whole planning run.
Required Methods§
Provided Methods§
Sourcefn sample_informed<Sp, R>(
&mut self,
space: &Sp,
rng: &mut R,
start: &S,
goal: &S,
max_cost: f64,
) -> Option<S>
fn sample_informed<Sp, R>( &mut self, space: &Sp, rng: &mut R, start: &S, goal: &S, max_cost: f64, ) -> Option<S>
Draws a state directly from the informed set
{x : d(start, x) + d(x, goal) <= max_cost} within this sampler’s support, or returns
None to make the planner fall back to rejection sampling from Sampler::sample.
Informed planners (RrtStar with
informed, BIT*) call this once a solution
exists. A returned state must lie in the informed set under space’s metric and be
distributed uniformly over the informed set intersected with the support of
Sampler::sample; otherwise the planner loses its optimality guarantees.
When direct sampling does not apply (an unsupported space, or a set so large that
rejection is cheaper), return None without drawing from rng, so that the
fallback sees the same random stream as without this method. None after drawing is
allowed when an attempt budget runs out.
The default returns None: rejection sampling, which works for every sampler and space.
UniformBox samples a ProlateHyperspheroid in Euclidean spaces.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".