Samplers

Samplers control how candidate configurations are generated for roadmap expansion. Changing the sampler can significantly affect solver speed and solution quality.

Typical usage

from discopygal.solvers_infra.samplers import Sampler_Uniform

sampler = Sampler_Uniform(scene)
sample = sampler.sample()

See also

class discopygal.solvers_infra.samplers.Sampler(scene: Scene = None)

Abstract class for sampling methods in the scene.

Parameters:

scene (Scene) – a scene to sample in

sample() Point_2

Return a sample in the space (might be invalid)

Returns:

sampled point

Return type:

Point_2

set_scene(scene: Scene)

Set the scene the sampler should use. Can be overridded to add additional processing.

Parameters:

scene (Scene) – a scene to sample in

class discopygal.solvers_infra.samplers.SamplerWithAngle(scene: Scene = None)

Uniform sampler of random point and angle (for rotation)

sample() tuple[Point_2, FT]

Return a sample (point + angle) in the space (might be invalid)

Returns:

sampled point, sampled angle

Return type:

(Point_2, FT)

class discopygal.solvers_infra.samplers.Sampler_Elliptical(scene: Scene = None)

Elliptical sampler in the scene

Parameters:

scene (Scene) – a scene to sample in

sample()

Return a sample in the space (might be invalid)

Returns:

sampled point

Return type:

Point_2

set_bounds_manually(min_x, max_x, min_y, max_y)

Set the sampling bounds manually (instead of supplying a scene) Bounds are given in CGAL FT

set_scene(scene: Scene, bounding_box=None)

Set the scene the sampler should use. Can be overridded to add additional processing.

Parameters:

scene (Scene) – a scene to sample in

class discopygal.solvers_infra.samplers.Sampler_Uniform(scene: Scene = None)

Uniform sampler in the scene

Parameters:

scene (Scene) – a scene to sample in

sample() Point_2

Return a sample in the space (might be invalid)

Returns:

sampled point

Return type:

Point_2

set_bounds_manually(min_x: FT, max_x: FT, min_y: FT, max_y: FT) None

Set the sampling bounds manually (instead of supplying a scene) Bounds are given in CGAL FT

set_scene(scene: Scene, bounding_box: BoundingBox = None) None

Set the scene the sampler should use. Can be overridded to add additional processing.

Parameters:

scene (Scene) – a scene to sample in

:param