Model sampling, sensitivity analisys, uncertainty, surrogates
Project description
Corrai: A Framework for Modeling, Sampling, Optimization and Surrogates
Corrai is a Python library for scientific exploration of complex systems.
It provides a unified framework for model definition, parameterization, sampling, optimization, sensitivity analysis, and surrogate modeling.
While originally motivated by building energy research, Corrai is domain-independent and can be applied to any problem requiring model calibration, uncertainty quantification, or reduced-order modeling.
Main Features
-
Sampling methods
- Generate experimental designs using built-in samplers: Sobol, Latin Hypercube, FAST, Morris, random, or custom samplers (
SampleandSampler). - Easily connect samples with model parameters to prepare sensitivity or optimization studies.
- Generate experimental designs using built-in samplers: Sobol, Latin Hypercube, FAST, Morris, random, or custom samplers (
-
Sensitivity & uncertainty analysis
- Built-in analyzers for variance-based (Sobol), screening (Morris), and FAST methods (sensitivity.py).(SAlib).
- Quantify the influence of each parameter on model outputs.
-
Optimization and calibration
- Single and multi-objective parameter identification and model calibration (
optimize.py). - Integrated with evolutionary and gradient-based optimizers (pymoo).
- Single and multi-objective parameter identification and model calibration (
-
Surrogate modeling
- Train ML-based surrogates (linear, polynomial, SVR, random forest, MLP, …).
- Grid-search hyperparameter tuning (sklearn).
- Evaluate accuracy with statistical metrics (
nmbe,cv_rmse).
-
Visualization support
- Plotting utilities to inspect results, sensitivity indices, surrogate accuracy, etc.
-
Model abstraction
- Define analytical, external simulator, numerical, or FMU-driven models (classes
ModelandModelicaFmuModel). - Associate parameters with model properties such as domain, initial values, continuity (class
Parameter)
- Define analytical, external simulator, numerical, or FMU-driven models (classes
Getting started
Installation
Corrai requires Python 3.10 or above. The recommended way to install corrai is via pip:
pip install corrai
This will install python-tide and all its dependencies.
Quick example
import pandas as pd
from corrai.base.parameter import Parameter
from corrai.sensitivity import SobolSanalysis, MorrisSanalysis
from corrai.base.model import IshigamiDynamic
SIMULATION_OPTIONS = {
"start": "2009-01-01 00:00:00",
"end": "2009-01-01 05:00:00",
"timestep": "h",
}
PARAMETER_LIST = [
Parameter("par_x1", (-3.14159265359, 3.14159265359), model_property="x1"),
Parameter("par_x2", (-3.14159265359, 3.14159265359), model_property="x2"),
Parameter("par_x3", (-3.14159265359, 3.14159265359), model_property="x3"),
]
# Configure a Sobol sensitivity analysis
sobol = SobolSanalysis(
parameters=PARAMETER_LIST,
model=IshigamiDynamic(),
simulation_options=SIMULATION_OPTIONS,
)
# Draw sample, and run simulations
sobol.add_sample(15 ** 2, simulate=True, n_cpu=1, calc_second_order=True)
# Corrai works for models that returns time series
# Ishigami model here will return the same value for the given parameters
# from START to END at 1h timestep
sobol.analyze('res', method="mean")["mean_res"]
# Default aggregation method is mean value of the timeseries
sobol.plot_bar('res')
# Display 2nd order matrix for parameters interaction
sobol.plot_s2_matrix('res')
# Display mean output values of the sample as hist
sobol.sampler.sample.plot_hist('res')
# Compute dynamic sensitivity analisys at plot
# Obviously, in this example indexes value do not vary
sobol.plot_dynamic_metric('res', sensitivity_metric="ST", freq="h")
Sponsors
|
|
The development of this library has been supported by METABUILDING LABS Project, which has received funding from the European Union’s Horizon 2020 Research and Innovation Programme under Grant Agreement No. 953193. The sole responsibility for the content of this library lies entirely with the author’s view. The European Commission is not responsible for any use that may be made of the information it contains. |
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 corrai-1.1.0.tar.gz.
File metadata
- Download URL: corrai-1.1.0.tar.gz
- Upload date:
- Size: 53.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6c3bd80f23741ab05476d247f5c03fe4ae21d37dbbf78cd3a87828d8a5388fa
|
|
| MD5 |
5c3a4a00bf5692970c03619134c05bd8
|
|
| BLAKE2b-256 |
28829982c89dbf28ede0987f30bb2cae9d460c89c79dd9edd9d0f46aec1c1599
|
Provenance
The following attestation bundles were made for corrai-1.1.0.tar.gz:
Publisher:
build.yaml on BuildingEnergySimulationTools/corrai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corrai-1.1.0.tar.gz -
Subject digest:
a6c3bd80f23741ab05476d247f5c03fe4ae21d37dbbf78cd3a87828d8a5388fa - Sigstore transparency entry: 588793171
- Sigstore integration time:
-
Permalink:
BuildingEnergySimulationTools/corrai@eb35b6730bf47736edd376ab350059878d0e46d5 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/BuildingEnergySimulationTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@eb35b6730bf47736edd376ab350059878d0e46d5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file corrai-1.1.0-py3-none-any.whl.
File metadata
- Download URL: corrai-1.1.0-py3-none-any.whl
- Upload date:
- Size: 57.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e7f26d102841f8215bd42e39077b48832bec86bec7329b2c4d3c632c005883e
|
|
| MD5 |
2c08c27f26afef8e7137b52cf6a4f5da
|
|
| BLAKE2b-256 |
a2b4082a5ef8b51b1fd6b46f60cbf600902db1944c91cd2732b1170a88e691fc
|
Provenance
The following attestation bundles were made for corrai-1.1.0-py3-none-any.whl:
Publisher:
build.yaml on BuildingEnergySimulationTools/corrai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
corrai-1.1.0-py3-none-any.whl -
Subject digest:
5e7f26d102841f8215bd42e39077b48832bec86bec7329b2c4d3c632c005883e - Sigstore transparency entry: 588793217
- Sigstore integration time:
-
Permalink:
BuildingEnergySimulationTools/corrai@eb35b6730bf47736edd376ab350059878d0e46d5 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/BuildingEnergySimulationTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yaml@eb35b6730bf47736edd376ab350059878d0e46d5 -
Trigger Event:
push
-
Statement type: