Parameter space search under uncertainty for the GDS ecosystem
Project description
gds-psuu
Parameter space search under uncertainty — explore, evaluate, and optimize simulation parameters with Monte Carlo awareness.
Built on top of gds-sim, gds-psuu provides a search engine for intelligently exploring simulation parameter spaces to optimize KPIs.
Install
uv add gds-psuu
# or: pip install gds-psuu
# For Bayesian optimization (optional):
uv add "gds-psuu[bayesian]"
Quick Start
from gds_sim import Model, StateUpdateBlock
from gds_psuu import (
KPI, Continuous, GridSearchOptimizer,
ParameterSpace, Sweep, final_value, mean_agg,
)
# Define a gds-sim model
model = Model(
initial_state={"population": 100.0},
state_update_blocks=[
StateUpdateBlock(
policies={"growth": lambda s, p, **kw: {"delta": s["population"] * p["growth_rate"]}},
variables={"population": lambda s, p, signal=None, **kw: ("population", s["population"] + signal["delta"])},
)
],
)
# Define what to search and what to measure
sweep = Sweep(
model=model,
space=ParameterSpace(params={"growth_rate": Continuous(min_val=0.01, max_val=0.2)}),
kpis=[KPI(name="avg_pop", metric=final_value("population"), aggregation=mean_agg)],
optimizer=GridSearchOptimizer(n_steps=5),
timesteps=10,
runs=3,
)
results = sweep.run()
best = results.best("avg_pop")
print(f"Best growth_rate: {best.params['growth_rate']:.3f}")
Features
Composable KPIs
Metric (per-run scalar) + Aggregation (cross-run reducer) = KPI:
from gds_psuu import (
KPI, final_value, trajectory_mean, max_value, min_value,
mean_agg, std_agg, percentile_agg, probability_above, probability_below,
)
# Mean of final population across Monte Carlo runs
KPI(name="avg_pop", metric=final_value("population"), aggregation=mean_agg)
# 95th percentile of trajectory means
KPI(name="p95", metric=trajectory_mean("x"), aggregation=percentile_agg(95))
# Probability that max value exceeds a threshold
KPI(name="risk", metric=max_value("x"), aggregation=probability_above(500.0))
Per-run distributions are tracked in EvaluationResult.distributions for downstream analysis.
Parameter Spaces
Three dimension types with validation:
from gds_psuu import Continuous, Integer, Discrete, ParameterSpace
space = ParameterSpace(params={
"learning_rate": Continuous(min_val=0.001, max_val=0.1),
"layers": Integer(min_val=1, max_val=5),
"activation": Discrete(values=("relu", "tanh")),
})
Parameter Constraints
Define feasible regions with linear or functional constraints:
from gds_psuu import LinearConstraint, FunctionalConstraint
# x + y <= 1.0
LinearConstraint(coefficients={"x": 1.0, "y": 1.0}, bound=1.0)
# Custom constraint function
FunctionalConstraint(fn=lambda p: p["x"] ** 2 + p["y"] ** 2 <= 1.0)
Grid search filters infeasible points; random search uses rejection sampling.
Search Strategies
| Optimizer | Strategy | When to use |
|---|---|---|
GridSearchOptimizer(n_steps) |
Exhaustive grid | 1-2 dimensions, full coverage |
RandomSearchOptimizer(n_samples, seed) |
Uniform random | Higher dimensions, exploration |
BayesianOptimizer(n_calls, target_kpi) |
Gaussian process (optuna) | Expensive sims, optimization |
Composable Objectives
Multi-KPI optimization:
from gds_psuu import SingleKPI, WeightedSum
# Single KPI (maximize or minimize)
obj = SingleKPI(name="avg_pop", maximize=True)
# Weighted combination of multiple KPIs
obj = WeightedSum(weights={"profit": 1.0, "risk": -0.5})
results.best_by_objective(obj)
Sensitivity Analysis
Screen parameter importance before running expensive sweeps:
from gds_psuu import OATAnalyzer, MorrisAnalyzer
# One-at-a-time: vary each parameter independently
oat = OATAnalyzer(n_steps=5)
result = oat.analyze(evaluator, space)
# Morris method: elementary effects (mu_star = influence, sigma = nonlinearity)
morris = MorrisAnalyzer(r=10, levels=4)
result = morris.analyze(evaluator, space)
result.ranking("my_kpi") # parameters sorted by importance
Architecture
Parameter Point -> Simulation -> Results -> Metric -> Aggregation -> KPI
|
Optimizer.suggest() --> Evaluator.evaluate(params) --> Optimizer.observe(scores)
^ | |
| gds-sim Simulation |
+------------------------ repeat --------------------------+
Documentation
Full docs at blockscience.github.io/gds-core.
License
Apache-2.0 — BlockScience
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gds_psuu-0.99.0.tar.gz.
File metadata
- Download URL: gds_psuu-0.99.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b17975edb568468c71e7b76a0fabc7c187e1069dfe14260af07c0dbb32a3aa1
|
|
| MD5 |
53d0192e5f52eb86ff3dc5da7bb9d771
|
|
| BLAKE2b-256 |
8b0a28af83b0be5d2c2019c857d960155b94a35f83c951bc03489950e8cc9d24
|
File details
Details for the file gds_psuu-0.99.0-py3-none-any.whl.
File metadata
- Download URL: gds_psuu-0.99.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50cbf7837be0b5ad5a8b638ffac6b44fb4b18fdd9c484cb21d001d8d10f9ba8b
|
|
| MD5 |
2496ab5430b73a16880f4b71114565da
|
|
| BLAKE2b-256 |
cf5caca5e353f085812847128487e57a26901157b582e6cea7b302a6b5adde27
|