# ScenarioReducer
![License](https://img.shields.io/github/license/DanieleGioia/ScenarioReducer)
![Issues](https://img.shields.io/github/issues/DanieleGioia/ScenarioReducer)
This library implements several approximate scenario reduction algorithms. Given a probability distribution with finite support, they aim to determine a probability measure with support of reduced and fixed cardinality by selecting the closest to the original one in terms of a selected statistical distance.
## Installation
1. (Recommended) The easiest way to install and use ScenarioReducer is through pip:
```Bash
pip install ScenarioReducer
```
2. (Alternative) You can directly clone the repository
```Bash
git clone https://github.com/DanieleGioia/ScenarioReducer.git
```
## Code structure
```Bash
|____main_example.py
|____scenarioReducer
| |____scenario_reducer.py
| |______init__.py
| |____fast_forward.py
|____tests
| |____test_fast_forward.py
```
### ScenarioReducer Class
It is an abstract class for a scenario reducer that suggests the methods that a scenario reducer should possess. The main method **reduce**, given a fixed n, must reduce an original set of scenarios with cardinality N to a smaller one of cardinality n.
Different strategies can vary, for example, w.r.t.:
- The statistical distance.
- The selection order (Fast Forward, Backward, Simultaneous Backward, ...).
### Fast_forward class
This class implements a scenario reducer that follows a *Fast Forward* (FF) technique from:
[1] Heitsch, Holger, and Werner Römisch. "Scenario reduction algorithms in stochastic programming." Computational optimization and applications 24.2-3 (2003): 187-206.
FF is preferred for $n\le \frac{N}{4}$ , where $n$ is the new reduced cardinality of the support and $N$ is the original one. For further details please refer to the article.
### Example
An easy example to familiarize yourself with the library is provided in **main_example.py**
### Available tests
1. *test_fast_forward* creates a starting set of one-dimensional Gaussian distributed scenarios of known mean and variance. The test then uses the *Fast_Forward* class to reduce the number of scenarios. Mean, standard deviation, and 0.05, 0.5, and 0.95 quantiles are eventually compared between the original scenario set and the reduced scenario set to confirm that such statistical measures are close.
Raw data
{
"_id": null,
"home_page": "",
"name": "ScenarioReducer",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "stochastic-programming,probability-metric,scenario-reduction,scenario-tree",
"author": "",
"author_email": "Daniele Giovani Gioia <daniele.gioia@polito.it>",
"download_url": "https://files.pythonhosted.org/packages/e5/9a/52718353bc15849c5041099dac72b8266549dd545b7d9215a6d675a7c814/scenarioreducer-1.0.0.tar.gz",
"platform": null,
"description": "# ScenarioReducer\n\n![License](https://img.shields.io/github/license/DanieleGioia/ScenarioReducer)\n![Issues](https://img.shields.io/github/issues/DanieleGioia/ScenarioReducer)\n\nThis library implements several approximate scenario reduction algorithms. Given a probability distribution with finite support, they aim to determine a probability measure with support of reduced and fixed cardinality by selecting the closest to the original one in terms of a selected statistical distance.\n\n## Installation\n\n1. (Recommended) The easiest way to install and use ScenarioReducer is through pip:\n\n ```Bash\n pip install ScenarioReducer\n ```\n\n2. (Alternative) You can directly clone the repository\n\n ```Bash\n git clone https://github.com/DanieleGioia/ScenarioReducer.git\n ```\n\n## Code structure\n\n```Bash\n|____main_example.py\n|____scenarioReducer\n| |____scenario_reducer.py\n| |______init__.py\n| |____fast_forward.py\n|____tests\n| |____test_fast_forward.py\n```\n\n### ScenarioReducer Class\n\nIt is an abstract class for a scenario reducer that suggests the methods that a scenario reducer should possess. The main method **reduce**, given a fixed n, must reduce an original set of scenarios with cardinality N to a smaller one of cardinality n.\n\nDifferent strategies can vary, for example, w.r.t.:\n\n- The statistical distance.\n- The selection order (Fast Forward, Backward, Simultaneous Backward, ...).\n\n### Fast_forward class\n\nThis class implements a scenario reducer that follows a *Fast Forward* (FF) technique from:\n\n[1] Heitsch, Holger, and Werner R\u00f6misch. \"Scenario reduction algorithms in stochastic programming.\" Computational optimization and applications 24.2-3 (2003): 187-206.\n\nFF is preferred for $n\\le \\frac{N}{4}$ , where $n$ is the new reduced cardinality of the support and $N$ is the original one. For further details please refer to the article.\n\n### Example\n\nAn easy example to familiarize yourself with the library is provided in **main_example.py**\n\n### Available tests\n\n1. *test_fast_forward* creates a starting set of one-dimensional Gaussian distributed scenarios of known mean and variance. The test then uses the *Fast_Forward* class to reduce the number of scenarios. Mean, standard deviation, and 0.05, 0.5, and 0.95 quantiles are eventually compared between the original scenario set and the reduced scenario set to confirm that such statistical measures are close.\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Scenario Reduction Algorithms in Stochastic Programming",
"version": "1.0.0",
"project_urls": {
"changelog": "https://github.com/DanieleGioia/ScenarioReducer/blob/main/CHANGELOG.md",
"repository": "https://github.com/DanieleGioia/ScenarioReducer/blob/main/README.md"
},
"split_keywords": [
"stochastic-programming",
"probability-metric",
"scenario-reduction",
"scenario-tree"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8c4f60b3611b48a29874b8e113f35968b7ccd3b561faa8c5659abeb1e5ea443",
"md5": "314867092a27dab2fa484f900cb320ad",
"sha256": "194d7437787babce4e459402903a315d69d92ab852bd347c1a94b4be8544a3ee"
},
"downloads": -1,
"filename": "scenarioreducer-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "314867092a27dab2fa484f900cb320ad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5590,
"upload_time": "2023-06-06T17:43:35",
"upload_time_iso_8601": "2023-06-06T17:43:35.081062Z",
"url": "https://files.pythonhosted.org/packages/f8/c4/f60b3611b48a29874b8e113f35968b7ccd3b561faa8c5659abeb1e5ea443/scenarioreducer-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e59a52718353bc15849c5041099dac72b8266549dd545b7d9215a6d675a7c814",
"md5": "fd3bb5f536385dc8405fefbfff5956b8",
"sha256": "01a4aa62c96592b16c208891ef7fab738c5c9a96fe281059caca4a8a27f98115"
},
"downloads": -1,
"filename": "scenarioreducer-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "fd3bb5f536385dc8405fefbfff5956b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4297,
"upload_time": "2023-06-06T17:43:36",
"upload_time_iso_8601": "2023-06-06T17:43:36.913665Z",
"url": "https://files.pythonhosted.org/packages/e5/9a/52718353bc15849c5041099dac72b8266549dd545b7d9215a6d675a7c814/scenarioreducer-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-06 17:43:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DanieleGioia",
"github_project": "ScenarioReducer",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "scenarioreducer"
}