-
Notifications
You must be signed in to change notification settings - Fork 9
[ana6, com8]: Add ana6Optimisation Module, apply changes in com8MoTPSA #1245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RolandFischbacher
wants to merge
5
commits into
master
Choose a base branch
from
RF_com8MoTPSA
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
15f5438
[com8MoTPSA] Squashed branch: MoT-PSA workflow, optimisation, and ana6
fso42 e41ff1c
refactor(runScripts): `runPlotAreaRefDiffs`,removing unused condition…
fso42 a7f0a5e
fix(probAna): restore missing bounds and config writing after merge
RolandFischbacher 3f4d1e5
Merge remote-tracking branch 'origin/RF_com8MoTPSA' into RF_com8MoTPSA
RolandFischbacher 97fd380
fix: handle new _L1/_L2 naming in merging logic and rename some varia…
RolandFischbacher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # ana6 – Sensitivity Analysis & Optimisation | ||
qltysh[bot] marked this conversation as resolved.
Show resolved
Hide resolved
fso42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| The `ana6Optimisation` module provides tools for performing Morris sensitivity analysis and parameter optimisation within the AvaFrame workflow. It supports input parameter ranking, convergence analysis of sensitivity indices and surrogate-based optimisation strategies. The module can be used either sequentially (Morris analysis followed by optimisation) or independently for direct optimisation. | ||
|
|
||
| --- | ||
|
|
||
| ## Module Structure | ||
|
|
||
| The module contains the following files: | ||
|
|
||
| - `runMorrisSA.py` (configuration: `runMorrisSACfg.ini`) | ||
| - `runPlotMorrisConvergence.py` (uses `runMorrisSACfg.ini`) | ||
| - `runOptimisation.py` (configuration: `runOptimisationCfg.ini`) | ||
| - `optimisationUtils.py` | ||
|
|
||
| --- | ||
|
|
||
| ## Workflow | ||
| ### Reference Data and Working Directory | ||
|
|
||
| All scripts must be executed within the directory: `avaframe/ana6Optimisation` | ||
|
|
||
| In `avaframeCfg.ini`, the avalanche reference directory (`avalancheDir`) must include the suffix `../`, for example: `../data/avaFleisskar` | ||
|
|
||
| This ensures correct relative path resolution within the AvaFrame project structure. | ||
|
|
||
| To compute goodness-of-fit metrics between reference and simulation results and to perform AIMEC analysis, the following reference data must be provided in: `avaframe/data/<avaName>/Inputs` | ||
|
|
||
| The required folder structure is: | ||
| Folder: | ||
| - **LINES** | ||
| Contains the AIMEC path. | ||
|
|
||
| - **POLYGONS** | ||
| Contains Cropshape and defines the maximal extent of runout area that is used for calculating areal indicators. | ||
|
|
||
| - **REFDATA** | ||
| Defines the runout area of the reference event. | ||
|
|
||
| - **REL** | ||
| Defines the release area of the avalanche event. | ||
|
|
||
| File: | ||
| - **Digital Elevation Model (DEM)** | ||
| Must be placed directly in the `Inputs` directory and must cover the entire affected area. | ||
|
|
||
| More Details here: https://docs.avaframe.org/en/latest/moduleCom1DFA.html | ||
|
|
||
| ___ | ||
|
|
||
| ### Morris Sensitivity Analysis (MorrisSA) | ||
|
|
||
| The Morris sensitivity analysis provides a ranking of input parameters based on their influence on the model response. | ||
|
|
||
| Before running `runMorrisSA.py`, the following step is required prior: | ||
|
|
||
| - Execute `runAna4ProbAnaCom8MoTPSA` | ||
| - In `probAnaCfg.ini`: | ||
| - Set the sampling method to `'morris'` | ||
| - Define the number of Morris trajectories (`nSample`) | ||
| - Select the input parameters and define their variation bounds | ||
|
|
||
| This step generates the required simulations and stores the sampled parameters and their bounds in a pickle file. | ||
|
|
||
| **Afterwards:** | ||
|
|
||
| - Run `runMorrisSA.py` | ||
| - Configure settings via `runMorrisSACfg.ini` | ||
| - The `MORRIS_CONVERGENCE` setting can be ignored for standard sensitivity analysis | ||
|
|
||
| **Outputs:** | ||
|
|
||
| - Pickle file containing: | ||
| - Ranked input parameters | ||
| - Morris sensitivity indices | ||
| - Parameter bounds | ||
| - Visualisation plots of the sensitivity results | ||
|
|
||
| --- | ||
|
|
||
| ### Morris Convergence Analysis | ||
|
|
||
| The convergence analysis evaluates how the Morris sensitivity indices stabilise with increasing numbers of trajectories. Its purpose is to determine the minimum number of trajectories that yields robust results. | ||
|
|
||
| **Requirements:** | ||
|
|
||
| - Run `runAna4ProbAnaCom8MoTPSA` multiple times with different numbers of Morris trajectories | ||
| - Rename Output folders afterwards with the following naming convention: OutputsR<number> | ||
|
|
||
|
|
||
| where `<number>` corresponds to the number of trajectories | ||
|
|
||
| This process is computationally expensive, as it requires a large number of simulations. | ||
|
|
||
| **Execution:** | ||
|
|
||
| - Run `runPlotMorrisConvergence.py` | ||
|
|
||
| **Output:** | ||
|
|
||
| - Convergence plots of Morris sensitivity indices | ||
|
|
||
| --- | ||
|
|
||
| ### Optimisation | ||
|
|
||
| The optimisation process identifies the set of input parameters that yields the best agreement between simulation results and a defined reference. "Best" is defined by the objective function implemented in the optimisation routine. | ||
|
|
||
| Optimisation can be performed in two ways: | ||
|
|
||
| **With prior Morris analysis:** | ||
| - Parameter ranking is available | ||
| - Parameter bounds are already defined | ||
| - Execute `runOpmisiation.py` with scenario 1 in `runOptimisationCfg.ini` | ||
|
|
||
| **Without prior Morris analysis:** | ||
| - Execute `runAna4ProbAnaCom8MoTPSA.py` to generate some initial samples (for surrogate) | ||
| - In `probAnaCfg.ini`: | ||
| - Set the sampling method to `'latin'` | ||
| - Define the number of model runs (`nSample`) | ||
| - Select the input parameters and define their variation bounds | ||
| - Execute `runOpmisiation.py` with scenario 2 in `runOptimisationCfg.ini` | ||
|
|
||
| **Two optimisation strategies are implemented:** | ||
|
|
||
| - Surrogate-based non-sequential optimisation | ||
| - Surrogate-based Bayesian (sequential) optimisation | ||
|
|
||
| **Outputs:** | ||
|
|
||
| - Optimal parameter set | ||
| - Visualisation plots of the optimisations results and progress | ||
|
|
||
| --- | ||
|
|
||
| ## Notes | ||
|
|
||
| - Performing Morris sensitivity analysis before optimisation is recommended to reduce the parameter space. | ||
| - Convergence analysis significantly increases computational cost. | ||
| - All workflows are controlled via `.ini` configuration files. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new line cfgStart["VISUALISATION"]["sampleMethod"] = cfg['PROBRUN']['sampleMethod'] reads sampleMethod from cfg['PROBRUN'].
However, probAnaCfg.ini has sampleMethod under [PROBRUN] only when probAna is the caller. If createCfgFiles is called from a different path where cfg doesn't have PROBRUN.sampleMethod, this will raise KeyError. The code also assumes VISUALISATION section exists in cfgStart for com8MoTPSA — while the new com8MoTPSACfg.ini does add it, there's no sampleMethod default there, making the flow dependent on the caller always providing this key.