Skip to main content

Parameter Space Exploration and CMA-ES Optimisation

This package might be useful if you have a model taking as input a set of parameters.

Start simulations from any sample(s) drown from the parameter space. Sampling may be analytical (like ParameterSpaceExploration with param iterators) or unknown (like ParameterSpaceAsk for CMA-ES).

The simulation parameters are the main model parameters. Optimisation parameters define a subset of simu params and spawn the parameter space. This package basically builds SimulationParameters for any sample of the parameter space, allowing to easily start simulations, and optimisation.

Install

pip install optimflow

Run parameters exploration

out_path = Path(__file__).parent / "out"

# Declare parameters of interest
class Params(OptimParams):
    p1 = param.Number(1, bounds=(0, 1), doc="Parameter 1")
    p2 = param.Number(1, bounds=(0.9, 1.1), doc="Parameter 2")

# Create simulation and exploration parameters
simulation_params = SimulationParams()
optim_params = Params()

# Define your simulation worker
def worker(dname: str):
    # Load parameters from the directory (prepared by dump_params)
    params = SimulationParams.load_from(dname)

    # mock the model's result
    t = np.linspace(0, 1, 100)
    res = params.p1 * np.sin(params.p2 * 2 * np.pi * t)
    np.savetxt(params.out_dir / "result.txt", res)

# Main class to start exploring the parameter space
explo = ParameterSpaceExploration(out_path)
explo.dump_params(simulation_params, optim_params)  # linear iterator
explo.run(worker, parallel=True)  # start all models
explo.gather_results()  # build a big pandas dataframe
explo.plot_results()  # plot model results for each varying optim param

Metadata

Release files for optimflow 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for optimflow 0.0.5
File Size Uploaded
optimflow-0.0.5.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for optimflow 0.0.5
File Interpreter ABI Platform
optimflow-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / optimflow-0.0.5.tar.gz

Download URL optimflow-0.0.5.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
33597847fd6b4e4172feb0ad55ee8186efb14b9beb7ebfbf7e70f9b1bd316797
BLAKE2b-256 checksum
How to use checksums
5e3d14edf8e8bdabd96f954d354610902285fe8daf05f2fc963b2011447fa624
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / optimflow-0.0.5-py3-none-any.whl

Download URL optimflow-0.0.5-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b097dc424ce544bc89ab13ce4375ef2c4fdb066f63253bfa9241eef69aa46666
BLAKE2b-256 checksum
How to use checksums
3af493c1cf2649bbf9e01e7759a04b1c23c3413b146e1fafb3d5e5145a835b50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page