Skip to content

Sequential Monte Carlo Optimization ​

Probabilistic

Sequential Monte Carlo (SMC) optimization with particle filtering.

Algorithm Overview ​

This module implements Sequential Monte Carlo (SMC) optimization, a probabilistic method using importance sampling and particle resampling.

The algorithm maintains a population of weighted particles that progressively focus on promising regions of the search space.

Usage ​

python
from opt.probabilistic.sequential_monte_carlo import SequentialMonteCarloOptimizer
from opt.benchmark.functions import sphere

optimizer = SequentialMonteCarloOptimizer(
    func=sphere,
    lower_bound=-5.12,
    upper_bound=5.12,
    dim=10,
    max_iter=500,
    population_size=50,
)

best_solution, best_fitness = optimizer.search()
print(f"Best solution: {best_solution}")
print(f"Best fitness: {best_fitness:.6e}")

Parameters ​

ParameterTypeDefaultDescription
funcCallableRequiredObjective function to minimize.
lower_boundfloatRequiredLower bound of search space.
upper_boundfloatRequiredUpper bound of search space.
dimintRequiredProblem dimensionality.
population_sizeint50Number of particles in SMC population.
max_iterint100Maximum SMC iterations.
initial_tempfloat10.0Starting temperature for importance weighting.
final_tempfloat0.1Final temperature for importance weighting.

Algorithm Metadata ​

PropertyValue
Algorithm NameSequential Monte Carlo Optimization
AcronymSMC
Year Introduced2006
AuthorsDel Moral, Pierre; Doucet, Arnaud; Jasra, Ajay
Algorithm ClassProbabilistic
ComplexityO(N*dim) per iteration with N particles
PropertiesStochastic, Adaptive
ImplementationPython 3.10+
COCO CompatibleYes

Mathematical Formulation ​

SMC maintains weighted particles and uses importance sampling:

wi(t)∝exp⁑(βˆ’f(xi(t))Tt)

Effective Sample Size (ESS) for resampling decision:

ESS=1βˆ‘i=1N(wi(t))2

Systematic Resampling when ESS < N/2:

ui=u0+iN,u0∼Uniform(0,1/N)

MCMC Move Step (Gaussian perturbation):

xi(t+1)∼N(xi(t),Οƒt2I)

where:

  • wi(t) are importance weights for particle i
  • Tt is temperature at iteration t
  • Οƒt=(bβˆ’a)Γ—(1βˆ’t/T)Γ—0.1 is adaptive step size
  • N is population_size

Temperature schedule:

Tt=T0(TfT0)t/T

Constraint handling:

  • Boundary conditions: Clamping to bounds
  • Feasibility enforcement: Hard boundary constraints via clipping

Hyperparameters ​

ParameterDefaultBBOB RecommendedDescription
population_size5010*dimNumber of particles
max_iter100500-2000Maximum SMC iterations
initial_temp10.01.0-10.0Starting temperature
final_temp0.10.01-0.5Final temperature

Sensitivity Analysis:

  • population_size: High impact - More particles improve exploration
  • initial_temp: High impact - Controls initial diversity
  • final_temp: Medium impact - Affects final convergence
  • Recommended tuning ranges: N∈[5d,20d] , T0∈[1,20]

COCO/BBOB Benchmark Settings ​

Search Space:

  • Dimensions tested: 2, 3, 5, 10, 20, 40
  • Bounds: Function-specific (typically [-5, 5] or [-100, 100])
  • Instances: 15 per function (BBOB standard)

Evaluation Budget:

  • Budget: dimΓ—10000 function evaluations
  • Independent runs: 15 (for statistical significance)
  • Seeds: 0-14 (reproducibility requirement)

Performance Metrics:

  • Target precision: 1e-8 (BBOB default)
  • Success rate at precision thresholds: [1e-8, 1e-6, 1e-4, 1e-2]
  • Expected Running Time (ERT) tracking

Raises ​

ValueError: If search space is invalid or function evaluation fails.

Notes ​

  • Uses self.seed for all random number generation
  • BBOB: Returns final best solution after max_iter iterations
  • Resampling triggered when ESS < population_size/2

Computational Complexity:

  • Time per iteration: O(Nd) for particle updates with N particles, dimension d
  • Space complexity: O(Nd) for particle population storage
  • BBOB budget usage: Typically 30-60% of dim*10000 budget for convergence

BBOB Performance Characteristics:

  • Best function classes: Multimodal functions (Rastrigin, Weierstrass, Gallagher)
  • Weak function classes: Smooth unimodal with small population
  • Typical success rate at 1e-8 precision: 30-50% (dim=5)
  • Expected Running Time (ERT): Good on multimodal, moderate on unimodal

Convergence Properties:

  • Convergence rate: Sub-linear to linear depending on resampling frequency
  • Local vs Global: Good global search via particle diversity
  • Premature convergence risk: Low - Resampling maintains diversity

Probabilistic Concepts:

  • Importance Sampling: Particles weighted by fitness-based likelihood
  • Sequential Importance Resampling: ESS-triggered resampling prevents degeneracy
  • Particle Filtering: Bayesian filtering for sequential estimation
  • Temperature Annealing: Gradually focuses particles on good regions
  • MCMC Moves: Metropolis step after resampling for local refinement

Reproducibility:

  • Deterministic: Partially - Same seed gives same results if no numpy.random calls
  • BBOB compliance: seed parameter required for 15 independent runs
  • Initialization: Uniform random sampling in [lower_bound, upper_bound]
  • RNG usage: numpy.random for particles and resampling (not using default_rng)

Implementation Details:

  • Parallelization: Not supported (sequential particle updates)
  • Constraint handling: Clamping to bounds via np.clip
  • Numerical stability: Log-weight normalization prevents underflow
  • Resampling: Systematic resampling for lower variance than multinomial

Known Limitations:

  • Not using numpy.random.default_rng - may affect reproducibility
  • Small populations may converge prematurely on unimodal functions
  • ESS threshold (N/2) is heuristic, may need tuning per problem
  • BBOB known issues: High function evaluation count on simple problems

Version History:

  • v0.1.0: Initial implementation
  • v0.1.2: Current version with BBOB compliance

References ​

[1] Del Moral, P., Doucet, A., & Jasra, A. (2006). "Sequential Monte Carlo Samplers." Journal of the Royal Statistical Society: Series B (Statistical Methodology), 68(3), 411-436. https://doi.org/10.1111/j.1467-9868.2006.00553.x

[2] Hansen, N., Auger, A., Ros, R., Mersmann, O., TuΕ‘ar, T., Brockhoff, D. (2021). "COCO: A platform for comparing continuous optimizers in a black-box setting." Optimization Methods and Software, 36(1), 114-144. https://doi.org/10.1080/10556788.2020.1808977

COCO Data Archive:

Implementation:

  • Original paper code: Not publicly available
  • This implementation: Based on [1] with systematic resampling and MCMC moves

See Also ​

AdaptiveMetropolisOptimizer: Single-chain MCMC with adaptation BBOB Comparison: AM better on unimodal, SMC better on multimodal

BayesianOptimizer: Model-based probabilistic optimization BBOB Comparison: BO more sample efficient, SMC better high-dim scaling

AbstractOptimizer: Base class for all optimizers opt.benchmark.functions: BBOB-compatible test functions

Related BBOB Algorithm Classes:

  • Probabilistic: BayesianOptimizer, AdaptiveMetropolisOptimizer
  • Swarm: ParticleSwarm, AntColony
  • Evolutionary: GeneticAlgorithm, DifferentialEvolution

Benchmark Performance ​

Results of the benchmark suite for this optimizer, on the same evaluation budget as every other optimizer and compared with a random search baseline. See the methodology for the protocol and statistics.


Source Code

View the implementation: sequential_monte_carlo.py

Released under the MIT License.