Delta Module optimization
----------------
The **Delta Module** is designed for sensitivity analysis, allowing users to explore the impact of parameter variations on optimization results. By creating multiple variations (called "deltas"), the module runs a series of optimizations to assess how different parameter values affect the outcome. This is particularly useful in understanding the robustness of a solution and identifying key drivers in the system's behavior.
.. warning::
The Delta Module operation should be used with caution due to its potential volumetry.
Many optimizations may be triggered, which can require significant time and computational resources.
Misuse of this operation (e.g., launching too many optimizations or using excessively large contexts)
can lead to server slowdown and severe issues.
---
### Workflow
#### Step 1: Import Reference Contexts into ACSG
Import one or more reference contexts into a specific study in ACSG. These contexts represent the baseline scenarios or test cases for assets that will be modified later.
#### Step 2: Calibrate Reference Contexts
Once imported, calibrate the reference contexts in ACSG to ensure they represent the desired model. This calibration involves:
- Running the contexts multiple times to ensure accuracy.
- Analysing KPIs
- Testing different **XPRS engine options** to identify the fastest one. For more details, see the section `Launch context optimization` in the [Operations](../views/operations.md) documentation.
- Estimating the **RAM requirements** needed to solve the context, allowing maximum parallelization of calculations.
#### Step 3: Launch Delta Optimization
Initiate the **Delta Optimization Module** from ACSG. The system will prompt you to upload a ZIP file containing:
1. A folder with the **Delta Plan** (self-contained folder with references to the study contexts).
2. A folder containing the **KPIs to calculate**, along with user-defined filters.
Configure the following advanced options:
- **Memory Allocation Configuration**: Set to **Custom**.
- **Custom Memory Value**: Enter a memory value with a 10% margin based on the calibration results.
- **XPRS Options**: Choose the engine option that was fastest during calibration.
#### Step 4: Analyze Calculated KPIs
Once the delta optimization is complete, view the calculated **scalar KPIs** in ACSG. Delta indexes are added to the results to distinguish between different contexts.
#### Step 5: Export and Further Analysis
Results can be exported for further manipulation. You can calculate additional statistical indicators or perform other analyses using ACSG’s tools.
---
### Delta Module Operation
#### Expected ZIP File Structure
The **Delta Module** expects a ZIP file with the following structure:
- The **csv_files** folder contains configuration files for deltas, paths, timeseries, and curves.
- The `kpis.csv` file specifies the KPIs to calculate for each context-delta combination.
- The **filters** folder contains CSV files defining filters for each KPI specified in `kpis.csv`.
You can download an example of the ZIP file here: [Download the Delta.zip file](../../_static/Delta.zip). This `Delta.zip` works with this example context [BaseCaseDemo_FRonly](../../_static/BCDemo_FRonly.zip)
---
#### Delta Definition: `deltas.csv`
The `deltas.csv` file defines the changes (deltas) applied to assets and parameters. For each delta, a series of actions either **replace** or **rescale** an attribute of an asset.
**Available Actions**
- **Replace**: Replace the current value with another value (double, timeseries, or curve).
- **Rescale**: Multiply the current value by a given factor.
Example: deltas.csv
deltas.csv contains serialized Deltas information.
| name | object | data | type | value |
|--------------|-------------------|-----------------------|---------|----------|
| low_demand | Power demand_FR | DEMAND | rescale | 0.9 |
| high_demand | Power demand_FR | DEMAND | rescale | 1.1 |
| no_nuke | Nuclear energy_FR | PMAX | replace | 0 |
| low_nuke | Nuclear energy_FR | PMAX | rescale | 0.5 |
| low_nuke | Gas production_FR | PRODUCTION_COST_CURVE | replace | #CURVE_1 |
| high_nuke | Nuclear energy_FR | PMAX | replace | #TS1 |
| high_nuke | Gas production_FR | PRODUCTION_COST_CURVE | replace | #CURVE_2 |
Replacement timeseries are prefixed with the usual tag `#TS` and curve data is prefixed with the tag `#`.
- **name**: Name of the delta. A delta can apply modifications to multiple assets and parameters.
- **object**: Name of the asset the delta is applied to. Use a wildcard (`*`) to match multiple assets (e.g., `Solar*` applies to all assets starting with "Solar").
- **data**: Attribute to modify.
- **type**: Either `replace` or `rescale`.
- **value**: A double, timeseries, or curve. Timeseries are prefixed with `#TS`, and curves are prefixed with `#`.
---
#### Associating Deltas with Reference Contexts: `paths.csv`
The `paths.csv` file maps deltas to specific contexts. The user can specify up to 10 deltas per context or test case.
Example: paths.csv
paths.csv contains the delta paths defining which deltas to apply to each context and test case.
| context | test_case | delta1 | delta2 |
|------------------|-----------|-------------|-------------|
| BCDemo_FRonly | * | no_nuke | low_demand |
| BCDemo_FRonly | * | low_nuke | low_demand |
| BCDemo_FRonly | * | high_nuke | low_demand |
| BCDemo_FRonly | * | | low_demand |
| BCDemo_FRonly | * | no_nuke | high_demand |
| BCDemo_FRonly | * | low_nuke | high_demand |
| BCDemo_FRonly | * | high_nuke | high_demand |
| BCDemo_FRonly | * | | high_demand |
Wildcards (`*`) allow applying a combination of deltas to all test cases of a given context. Non-contiguous delta entries are not necessary, but they allow for convenient delta ordering.
- **context**: Name of a context from the ACSG study.
- **test_case**: Name of the test case for the context. Use `*` to apply the deltas to all test cases.
- **delta1, delta2, ..., deltaN**: Names of deltas from `deltas.csv`.
---
#### Defining Timeseries and Curves: `timeseries.csv` and `curves.csv`
The `timeseries.csv` file contains timeseries data required for delta modifications.
- **Date**: Column for dates or timestamps.
- **Other Columns**: Each additional column contains a timeseries. The header must match the name in `deltas.csv`.
Example: timeseries.csv
timeseries.csv contains replacement timeseries.
| Date | 1 |
|------------------|-----|
| 01/01/2030 00:00 | 100 |
| 01/01/2030 01:00 | 100 |
| 01/01/2030 02:00 | 100 |
| 01/01/2030 03:00 | 100 |
| ... | ... |
| 31/12/2030 23:00 | 100 |
The `curves.csv` file contains curve data required for deltas. Each curve has its own column with coordinates listed in the same column.
Example: curves.csv
curves.csv contains replacement curve data.
Each column defines a curve, a series of couples (x_i,y_i) where x_i is a breaking
point and y_i is a slope. These numbers are expected to be separated by a semicolon (;) and are converted to integers.
Typically, the x_i are interpreted as a percentage of Pmax (in case of production costs, for instance).
| CURVE_1 | CURVE_2 |
|---------------|---------------|
| "20;30" | "20;5" |
| "70;80" | "80;25" |
| "90;210" | "90;50" |
---
#### KPI Selection: `kpis.csv`
The `kpis.csv` file specifies the KPIs to calculate for each context-delta combination.
- **kpi**: List of KPIs.
- **to_compute**: Indicates whether the KPI should be computed for all context combinations specified in `paths.csv`.
> **Note**: Temporal KPIs cannot be computed for delta optimizations as they generate too large data volumes.
.. warning::
KPIs already available in your study will be overwritten with the delta module optimization.
---
#### Defining KPI Filters: `filters/`
The `filters/` folder contains CSV files defining filters for calculating KPIs. Each file corresponds to a KPI listed in `kpis.csv`.
- If no filter file exists for a KPI, it will be calculated for all combinations of contexts and deltas.
- Filter columns must match index columns in the results dataframe.
Example: KPIs Filters
This table outlines the filters for KPIs, specifying the parameters to apply during calculations.
| energy | asset | technology | node |
|-------------|------------------------|------------|--------|
| electricity | Hybrid_heat_pump_FR | * | * |
| * | Hybrid_heat_pump_DE | * | * |
| * | * | TRANSMISSION| * |
| electricity | * | PIPELINE | * |
| * | * | PIPELINE | FR |
In this example, wildcards (*) are used to indicate that there are no specific filters applied for that column.
Before launching the delta module, ensure that KPIs and filters are properly defined to avoid performance bottlenecks due to large data volumes.
---