wmpy.solvers.wmsampler.WMSampler¶
- class WMSampler(enumerator, domain, integrator=None, seed=None)[source]¶
Bases:
objectThe class implements a sampling algorithm for weighted SMT formulas.
The algorithm is divided: 1) an offline preprocessing phase, enumerating the convex regions and computing their relative mass via WMI 2) an online sampling phase, where the information above determines the different subsamples’ sizes
Default constructor. Solves the preprocessing step by solving WMI. Uses this information for constructing a weighted strata for subsequent sampling efforts.
- Parameters:
enumerator (
Enumerator) – an instance of Enumerator (support, weight)domain (
Collection[FNode]) – the continuous integration domain (a list of pysmt real variables)integrator (
Optional[Integrator]) – an Integrator instance (default: LatteIntegrator)
Methods
Draws a sample from (support, weight) in two phases.
- DEF_INTEGRATOR¶
alias of
LattEIntegrator
- sample(n_samples, max_iterations=1)[source]¶
Draws a sample from (support, weight) in two phases.
The subsample ratios are determined based on the strata precomputed at construction. Convex subsampling is carried over using rejection sampling.
The procedure tries to satisfy the subsample size requirement up to max_iterations, returning M <= n_samples points.