[ana6, com8]: Add ana6Optimisation Module, apply changes in com8MoTPSA#1245
[ana6, com8]: Add ana6Optimisation Module, apply changes in com8MoTPSA#1245RolandFischbacher wants to merge 14 commits intomasterfrom
Conversation
❌ 2 blocking issues (5 total)
@qltysh one-click actions:
|
avaframe/out3Plot/outAna6Plots.py
Outdated
| # 4) Plot | ||
| x = np.arange(len(df)) | ||
| fig, ax = plt.subplots(figsize=(12, 6)) | ||
| bars = ax.bar( |
f66f702 to
38e42ca
Compare
Squash of 20 commits from RF_com8MoTPSA branch including: - com8MoTPSA workflow improvements (chunked multiprocessing, path handling) - Bayesian optimisation integration (ana6Optimisation module) - Morris sensitivity analysis scripts - AIMEC runout reference implementation - probAna pickle saving and bounds - Plotting and config improvements
|
Coverage Impact ⬇️ Merging this pull request will decrease total coverage on Modified Components (1)
Modified Files with Diff Coverage (2)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
- Add bounds to paramValuesD in createSamplesWithVariation (StandardParameters) - Add writing of visualisation scenario and sampling method to com8MoTPSACfg.ini
| @@ -0,0 +1,886 @@ | |||
| import numpy as np | |||
There was a problem hiding this comment.
A general note for this file: use log.info instead of prints for user info
| return xBest, xBestDict, np.max(ei), np.max(lcb) | ||
|
|
||
|
|
||
| def runCom8MoTPSA(avalancheDir, xBestDict, cfgMain, i=0, optimisationType=None): |
There was a problem hiding this comment.
I think this could be solved differently, as it duplicates code that might be changed. Investigate if a direct call with updated cfgs would be better. Let me now if you need help
There was a problem hiding this comment.
Implemented a direct call of com8MoTPSAMain with updated cfgs (writeCfgFiles in optimisationUtils.py)
| if 'VISUALISATION' in config.sections(): | ||
| # config is inifile | ||
| index = config['VISUALISATION']['scenario'] | ||
|
|
||
| if 'VISUALISATION' in config.sections(): | ||
| # config is inifile | ||
| index = config['VISUALISATION']['scenario'] | ||
| if 'sampleMethod' in config['VISUALISATION']: | ||
| sampleMethod = config['VISUALISATION']['sampleMethod'] |
There was a problem hiding this comment.
if any .ini file in the config directory lacks a VISUALISATION section, the variables index and sampleMethod are never assigned, but they are unconditionally appended on lines 107-108. On the first such file, this raises UnboundLocalError. Even if subsequent iterations reuse a stale value from a previous file, the data would be silently wrong.
There was a problem hiding this comment.
Thank you for the info. I will initialize index and sampleMethod with np.nan to avoid UnboundLocalError and stale values.
| # config is inifile | ||
| index = config['VISUALISATION']['scenario'] | ||
|
|
||
| if 'VISUALISATION' in config.sections(): |
There was a problem hiding this comment.
Why the duplicate if? Copy/Paste error?
There was a problem hiding this comment.
Yes copy paste error.
avaframe/ana4Stats/probAna.py
Outdated
| if modName.lower() in ["com1dfa", "com5snowslide", "com6rockavalanche", 'com8motpsa']: | ||
| cfgStart["VISUALISATION"]["scenario"] = str(count1) | ||
| cfgStart["INPUT"]["thFromIni"] = paramValuesD["thFromIni"] | ||
| cfgStart["VISUALISATION"]["sampleMethod"] = cfg['PROBRUN']['sampleMethod'] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Added check if 'VISUALISATION' exists in cfgStart, if not, it will be added to cfgStart.
And read sample method with fallback; meaning if 'PROBANA' or 'sampleMethod' is missing sample_method contains an empty string.
…i file, delete redundant code
…Files in optimisationUtils.py), add possibility to RUN writeCfgFiles with counter
…clean header Implement modName to make code general and remove adjustText package
…ror and stale values and remove copy paste error.
… added to cfgStart. And read sample method with fallback; meaning if 'PROBANA' or 'sampleMethod' is missing sample_method contains an empty string
| if modName.lower() in ["com1dfa", "com5snowslide", "com6rockavalanche"]: | ||
| if modName.lower() in ["com1dfa", "com5snowslide", "com6rockavalanche", 'com8motpsa']: | ||
| # Check if visualisation exists in cfgStart, if not add the section | ||
| if not cfgStart.has_section("VISUALISATION"): |
| index = config['VISUALISATION']['scenario'] | ||
| if 'sampleMethod' in config['VISUALISATION']: | ||
| sampleMethod = config['VISUALISATION']['sampleMethod'] | ||
| else: |
| nCPU = cfgUtils.getNumberOfProcesses(cfgMain, len(rcfFilesChunk)) | ||
|
|
||
| with Pool(processes=nCPU) as pool: | ||
| results = pool.map(com8MoTPSATask, rcfFilesChunk) |
… docstring, tidy up code, add if __name__='__main__': in runPlotMorrisConvergence.py and improve BOConvergencePlot.

This PR introduces a new optimisation module
ana6Optimisationforcom8MoTPSAand updates the simulation workflow.The module ana6Optimisation includes:
New files in ana6Opitmisaton:
runMorrisSA.py(configuration:runMorrisSACfg.ini)runPlotMorrisConvergence.py(usesrunMorrisSACfg.ini)runOptimisation.py(configuration:runOptimisationCfg.ini)optimisationUtils.pyREADME_ana6.md(contains usage instructions)New file in out3Plot:
outAna6Plots.pyChanged workflow of runing com8MoTPSA: