Skip to content
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

Global TSA via ROMCollection #2189

Merged
merged 11 commits into from
Oct 5, 2023
Merged

Conversation

GabrielSoto-INL
Copy link
Collaborator

@GabrielSoto-INL GabrielSoto-INL commented Sep 28, 2023


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

#2188

What are the significant changes in functionality due to this change request?

New attribute for TSA Algorithms for "global" which defaults to False. If true, that algorithm is added to a new _tsaGlobalAlgorithms list otherwise they are added to the original _tsaAlgorithms. Calls to the normal train and evaluate within TSAUser have a new input to specify whether to use the local or global set of algorithms.


For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in XML block, the node <internalParallel> to True.
  • 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

Copy link
Collaborator

@dylanjm dylanjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments for consideration

Allows any global settings to be applied to the signal collected by the ROMCollection instance.
Note this is called on the GLOBAL templateROM from the ROMcollection, NOT on the LOCAL supspace segment ROMs!
@ In, evaluation, dict, {target: np.ndarray} evaluated full (global) signal from ROMCollection
TODO finish docs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like there is a few input params left to finish: settings, weights, slicer

TODO finish docs
@ Out, evaluation, dict, {target: np.ndarray} adjusted global evaluation
"""
if len(self._tsaGlobalAlgorithms)>0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we raise a warning or error here if len(self._tsaGlobalAlgorithms) == 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is called in ROMCollection in evaluate( ) and it seems like it was called regardless of whether a global or local algorithm was specified. the way I have it now, it just reports back the same evaluation if no global algorithms were specified so there shouldn't be an error as is

evaluation[key] = val
return evaluation

def finalizeLocalRomSegmentEvaluation(self, settings, evaluation, globalPicker, localPicker=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a required method to satisfy some abstract method definition? Seems odd to just return the input evaluation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had overloaded the method from SupervisedLearning because the inputs were different, but comparing with the finalizeLocalRomSegmentEvaluation( ) method in the SupervisedLearning.ARMA it seems that the ARMA version just has an additional optional input that had not been updated in the parent version.

I am removing this method from SyntheticHistory.py, updating the method in SupervisedLearning.py with the additional optional input it is missing so that it functions as the "abstract/do nothing" parent method (since it also just returns evaluation) for TSA

@@ -95,6 +99,8 @@ def readTSAInput(self, spec):
elif self.pivotParameterID not in self.target:
# NOTE this assumes that every TSAUser is also an InputUser!
raise IOError('TSA: The pivotParameter must be included in the target space.')
if len(self._tsaAlgorithms)==0:
print("No Segmenting algorithms were requested.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have access to the messageHandler through this class? Perhaps we should self.raiseAWarning() here instead of print.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in TSAUser, but we have access in SyntheticHistory.py. will move the check to handleInput there

@ In, evalGlobal, bool, are these algos trained on global signal?
@ In, evaluation, dict, realization dictionary of values for each target
@ In, slicer, list of slice, indexer for data range of this segment FROM GLOBAL SIGNAL
@ Out, evaluation, dict, realization dictionary of values for each target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be called rlz instead of evaluation

rlz = dict((target, result[:, t]) for t, target in enumerate(noPivotTargets))
rlz[self.pivotParameterID] = self.pivotParameterValues
if needToRecombine:
# tmp_array = np.zeros((len(slicer), len(noPivotTargets)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants