An auto-calibration tool for environmental models based on heuristic algorithms and uncertainty estimation theory.
Project description
PyCUP
This is an open-source package designed for (environmental) model calibration and uncertainty analysis. The current version is the very first version, we welcome all comments, suggestions, and improvements.
v 0.1.5 Update
Two new border check mechanisms are included for processing the generated parameters that exceed the user defined search boundaries during the heuristic algorithms' updating stage.
- (The original method) Absorb. The sample value exceeds the lower boundary/ upper boundary will be directly put on the corresponding boundary.
- Random. The sample value exceeds the lower boundary/ upper boundary will be given a random value according to the search space.
- (The currently default method) Rebound. The sample value exceeds the lower boundary/ upper boundary will be given a random value near the corresponding boundary. This method can keep the search direction and avoid the result that a lot of samples locate on the boundary.
What does it have
(1) For model calibration/optimization
- Single-objective heuristic algorithms including PSO, GWO, MFO, SOA, SCA, SSA, TSA, and WOA.
- Multi-objective heuristic algorithms including MOPSO, MODE, and NSGA-II.
- Elite opposition strategy modified heuristic algorithms -- with better optimum search abilities.
- Statistic based-method LHS-GLUE.
(2) For sensitivity & uncertainty analysis
- Likelihood uncertainty estimation used in the GLUE framework for the parameter uncertainty analysis/prediction uncertainty estimation.
- The frequency based-uncertainty estimation method for the prediction uncertainty estimation.
- The multi-linear regression method for the all-at-a-time parameter sensitivity based on statmodels.
(3) Other convenient features
- Multi-processing calibration.
- Recording and resuming during the calibration task.
- Several result plotting functions.
- A special simulation result object for multi-station & multi-event results (of environmental models) in pycup.ResLib.
- PyCUP can be linked to spotpy database for post-processing, a pycup objective function can also be generated from the spotpy objective function using the module named pycup.integrate.
How to install
The project has been uploaded onto the PyPI https://pypi.org/project/pycup/ . Or install the .whl file in the dist folder.
pip install pycup
How to use
Here is a simple example. For more details, please see the documentation.
import pycup as cp
import numpy as np
def uni_fun1(X):
# X for example np.array([1,2,3,...,30])
fitness = np.sum(np.power(X,2)) + 1 # example: 1.2
result = fitness.reshape(1,-1) # example ([1.2,])
return fitness,result
lb = -100 * np.ones(30)
ub = 100 * np.ones(30)
cp.SSA.run(pop = 1000, dim = 30, lb = lb, ub = ub, MaxIter = 30, fun = uni_fun1)
Example SWMM (Storm Water Management Model) calibration projects
IMPORTANT: PLEASE OPEN YOUR PYCHARM OR COMMAND LINE WITH THE ADMINISTRATOR RIGHTS BEFORE EXECUTING THE EXAMPLE PROJECT
Location: https://github.com/QianyangWang/PyCUP
- The example in folder 'Example01-GLUE' contains an SWMM calibration project using single-processing GLUE. Install the dependencies (for example: pip install swmm-api==0.2.0.18.3, pip install pyswmm). Execute the 'Calibrate.py' to calibrate the model. Then, execute the 'PostProcessing.py' for uncertainty analysis.
- The example in folder 'Example02-multiprocessing' contains an SWMM calibration project using multi-processing EOGWO.
- The example in folder 'Example03-multiobjective' contains an SWMM multi-objective calibration project using EOMOPSO.
- The example in folder 'Example04-validation&prediction' shows how to use our (Ensemble)Validator/(Ensemble)Predictor objects for the validation and prediction of the model using the calibrated parameter (set).
- The example in folder 'Example05-multi-station&event' shows how to use the pycup.Reslib.SimulationResult object for the storage of multi-station & multi-event simulation results, as well as the further analysis using them.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file pycup-0.1.5.tar.gz
.
File metadata
- Download URL: pycup-0.1.5.tar.gz
- Upload date:
- Size: 851.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bbe9759da33ab2f6d8757a55d4e57bb85fb23ba8594f841dc3d6405c6382b83 |
|
MD5 | b90281e236e3781e23572945deaa93f5 |
|
BLAKE2b-256 | 288b6e03eafce7f88bf9542e52e30ca7d10b44cafad52a1524a97785da9504fc |
File details
Details for the file pycup-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: pycup-0.1.5-py3-none-any.whl
- Upload date:
- Size: 874.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38eedbaebaab46558b9c2d8e1c41959b1905886a472fbbfa2a6b9ef070ac28fa |
|
MD5 | 3a2ef5880822ca63de321eed7b63e75a |
|
BLAKE2b-256 | 4ebbd5f7ceb6d481fa5f92c48910dfe82cea57cdc644785a4ed56abdb11d27e0 |