Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
GPmp-contrib 0.9.37 documentation
Logo
GPmp-contrib 0.9.37 documentation
  • Installation
  • Getting started
  • User guide
    • Concepts
    • Models and computer experiments
    • Parameter selection
    • Model state and parameter objects
    • Diagnostics and inspection
    • Priors for REMAP selection
    • Sequential design, optimization, and set estimation
    • Relaxed Gaussian processes
  • Examples
    • Example 01: computer experiments
    • Example 02: models, diagnostics, and prediction
    • Example 04: noisy sequential prediction
    • Example 10: expected improvement on a fixed grid
    • Example 11: expected improvement with SMC search
    • Example 20: relaxed Gaussian process
    • Example 30: excursion set on a fixed grid
    • Example 31: excursion set with BSS-style SMC search
    • Example 40: set inversion on a fixed grid
    • Example 41: set inversion with BSS-style particles
  • API reference
    • gpmpcontrib package
    • Numerical backend objects
    • Computer experiments
    • Model containers
    • Provided Matérn container classes
    • Sequential procedures
    • Sampling criteria and optimization procedures
    • Relaxed Gaussian processes
    • Plotting functions
    • Test problems
  • References
Back to top
View this page
Edit this page

Example 31: excursion set with BSS-style SMC search¶

Script: examples/example31_excursionset_smc.py

Purpose¶

The script estimates an excursion set with ExcursionSetBSS. It replaces the fixed grid of example30 by a particle population. The particle target is controlled by an interpolation parameter mu between an initial threshold and the final excursion threshold. The construction is related to Bayesian subset simulation [1].

What is computed¶

  • posterior mean and variance at particle positions.

  • the threshold u(mu) = (1 - mu) * u_init + mu * u_target.

  • a target log-density proportional to log P(Y(x) > u(mu) | observations) inside the input box.

  • SMC reweighting, resampling, and Markov moves of the particle population.

  • excursion probabilities and excursion-set criteria at the current threshold.

Main objects¶

  • gpmpcontrib.optim.excursionset.ExcursionSetBSS

  • gpmpcontrib.SequentialStrategyBSS

  • gpmp.mcmc.smc.SMC

Outputs¶

Run python examples/example31_excursionset_smc.py from the repository root to execute the example. Regenerate the static figure with cd docs && python make_example_results.py.

BSS excursion-set design with SMC particles and relative target density.

Intermediate threshold with mu = 0.85. Top panel: current GP posterior and observations. Middle panel: excursion-set criterion at the current threshold. Lower panel: excursion probability with SMC particles. Particle heights show the current target density up to a multiplicative constant.¶

Source excerpt¶

        print("(m[n]) Move particles without updating threshold [n] times (default: 1)")
        print("(u[n]) Move particles and update threshold [n] times (default: 1)")
        print("--")
        print("(e[n]) Make a new evaluation [n] times (default: 1)")
        print("--")
        print("(r) Restart the particles")
        print("(p) Plot current state")
        print("(q) Quit")

        user_input = input("Enter your choice: ").strip().lower()

        # Extract command and optional number or value (supports "m3", "u2", "s 0.4", "n 0.2", etc.)
        match = re.match(r"([muerpsqn])\s*([\d\.]*)", user_input)

        if not match:
            print("Invalid input. Please enter a valid choice.")
            continue

        user_choice, param_str = match.groups()

        # Handle the "s" option separately (setting mu manually)
        if user_choice == "s":
            try:
                mu_value = float(param_str)
                if not (0 <= mu_value <= 1):
                    print("mu must be between 0 and 1.")
                    continue
                algo.mu = mu_value
                print(f"Set mu to {algo.mu:.4f}")
            except ValueError:
                print("Invalid value for mu. Please enter a number between 0 and 1.")
            continue  # Skip to next iteration after setting mu

        # Default repeat count for commands that take an integer (m, u, e)
        repeat = int(param_str) if param_str.isdigit() else 1

Next
Example 40: set inversion on a fixed grid
Previous
Example 30: excursion set on a fixed grid
Copyright © 2022-2026, CentraleSupelec
Made with Sphinx and @pradyunsg's Furo
On this page
  • Example 31: excursion set with BSS-style SMC search
    • Purpose
    • What is computed
    • Main objects
    • Outputs
    • Source excerpt