idaholab / raven

RAVEN is a flexible and multi-purpose probabilistic risk analysis, validation and uncertainty quantification, parameter optimization, model reduction and data knowledge-discovering framework.
https://raven.inl.gov/
Apache License 2.0
219 stars 133 forks source link

[DEFECT] SyntheticHistory ROM Interpolation Broken #2389

Open dylanjm opened 2 weeks ago

dylanjm commented 2 weeks ago

Thank you for the defect report

Defect Description

I am trying to train a SyntheticHistory ROM using a 6 sets of data. I want the data sets 0-4 to represent years 2024-2028 and then I want to interpolate between 2029-2054 using the 5 set of data.

When performing the training in RAVEN I get the following error:

Traceback (most recent call last):
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/bin/raven_framework", line 8, in <module>
    sys.exit(wheelMain())
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Driver.py", line 34, in wheelMain
    main(False)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Driver.py", line 207, in main
    raven()
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Driver.py", line 160, in raven
    simulation.run()
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Simulation.py", line 901, in run
    self.executeStep(stepInputDict, stepInstance)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Simulation.py", line 834, in executeStep
    stepInstance.takeAstep(stepInputDict)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Steps/Step.py", line 317, in takeAstep
    self._localTakeAstepRun(inDictionary)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Steps/RomTrainer.py", line 89, in _localTakeAstepRun
    ROM.train(inDictionary['Input'][0])
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/Models/ROM.py", line 372, in train
    self.supervisedContainer[0].train(self.trainingSet)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/SupervisedLearning/ROMCollection.py", line 1644, in train
    self._interpolateSteps(tdict)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/SupervisedLearning/ROMCollection.py", line 1706, in _interpolateSteps
    newModel = self._interpolateSVL(trainingDict, exampleRoms, exampleModel, self._macroTemplate, numSegments, globalInterp, interps, y)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/SupervisedLearning/ROMCollection.py", line 1786, in _interpolateSVL
    params = exampleModel._roms[0].setGlobalRomFeatures(params, pivotValues)
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/SupervisedLearning/SyntheticHistory.py", line 370, in setGlobalRomFeatures
    params = algo.setClusteringValues(settings, self._tsaTrainedParams[algo])
  File "/Users/mcdodj/.local/share/pyenv/versions/3.10.0/lib/python3.10/site-packages/ravenframework/TSA/Fourier.py", line 316, in setClusteringValues
    params[target]['intercept'] = value
KeyError: 'TOTALLOAD'

Steps to Reproduce

See attached files

Expected Behavior

I expect the interpolation to happen without issue.

Screenshots and Input Files

synthetic_history.zip

OS

MacOS

OS Version

14.7

Dependency Manager

PIP

For Change Control Board: Issue Review

For Change Control Board: Issue Closure

j-bryan commented 2 weeks ago

The issue appears to be in SyntheticHistory.py. When trying to set global ROM features, the loop for algo in self._tsaAlgorithms: ... (line 365) should probably be looping over self._tsaGlobalAlgorithms instead.

GabrielSoto-INL commented 2 weeks ago

Working on fixing what Jacob just described. But I think the actual issue happens when there are multiple algorithm nodes with different targets (e.g., two <fourier> nodes, one for target_0 and one for target_1). Seems I had implemented a fix but it's commented out on Line 368... unsure why that is, I will re-implemented in another branch with testing to cover that error.