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

Mandd/pareto front PP prestruct #1479

Merged
merged 10 commits into from
Mar 18, 2021
Merged

Mandd/pareto front PP prestruct #1479

merged 10 commits into from
Mar 18, 2021

Conversation

mandd
Copy link
Collaborator

@mandd mandd commented Mar 15, 2021


Pull Request Description

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

The current Pareto front PP can handle 2-dimensional multi-objective optimization
This PR extends PP capabilities to multiple dimensions optimization
Issue #1448 #1447

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

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.

@mandd mandd linked an issue Mar 15, 2021 that may be closed by this pull request
10 tasks
@mandd mandd requested review from wangcj05 and Jimmy-INL March 15, 2021 20:02
@@ -22,7 +22,7 @@



def nonDominatedFrontier(data, returnMask):
def nonDominatedFrontier(data, returnMask, minMask=None):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@wangcj05 I honestly feel like the required structure of returnMask and minMask might not be optimal, if you have comments/suggestions let me know

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I did not get your point here. Could you clarify it?

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 was not sure if passing the data as numpy array and min mask as a separate numpy array was the best way to pass this info to this method

@moosebuild
Copy link

Job Test mac on 40d5279 : invalidated by @mandd

for child in paramInput.subparts:
if child.getName() == 'objective':
self.objectives[child.value]={}
if child.parameterValues['goal'] in ['min','max']:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use InputTypes.makeEnumType in getInputSpecification to handle this, in that case, you do not need to check the goal input here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point: added enumType and removed checks

self.raiseAnError(IOError, 'ParetoFrontier postprocessor {}: the objective {} expects a min/max goal, but received {} inputs!".'
.format(self.name,child.value,child.parameterValues['goal']))
if 'upperLimit' in child.parameterValues.keys():
self.objectives[child.value]['upperLimit'] = child.parameterValues['upperLimit']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe you can use child.parameterValues.get('upperLimit')? Default is None if not available

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

edited

if 'upperLimit' in child.parameterValues.keys():
self.objectives[child.value]['upperLimit'] = child.parameterValues['upperLimit']
if 'lowerLimit' in child.parameterValues.keys():
self.objectives[child.value]['lowerLimit'] = child.parameterValues['lowerLimit']
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

edited

selection = data.isel(RAVEN_sample_ID=np.array(paretoFrontMask))

for obj in self.objectives.keys():
if 'upperLimit' in self.objectives[obj].keys():
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you make changes according to previous comments, this line can be changed:
if self.objectives[obj]['upperLimit']:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup, code is cleaner

if 'upperLimit' in self.objectives[obj].keys():
selection = selection.where(selection[obj]<=self.objectives[obj]['upperLimit'])
if 'lowerLimit' in self.objectives[obj].keys():
selection = selection.where(selection[obj]>=self.objectives[obj]['lowerLimit'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

edited as well

if minMask is None:
pass
elif minMask is not None and minMask.shape[0] != data.shape[1]:
raise IOError("nonDominatedFrontier method: minMask has shape " + str(data.shape) + " while minMask has shape " + str(minMask.shape))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update the error message, it seems not clear to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

message expanded and fixed

@@ -22,7 +22,7 @@



def nonDominatedFrontier(data, returnMask):
def nonDominatedFrontier(data, returnMask, minMask=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I did not get your point here. Could you clarify it?

@moosebuild
Copy link

Job Test mac on 40d5279 : invalidated by @mandd

Copy link
Collaborator Author

@mandd mandd left a comment

Choose a reason for hiding this comment

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

Addressing comments

for child in paramInput.subparts:
if child.getName() == 'objective':
self.objectives[child.value]={}
if child.parameterValues['goal'] in ['min','max']:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point: added enumType and removed checks

self.raiseAnError(IOError, 'ParetoFrontier postprocessor {}: the objective {} expects a min/max goal, but received {} inputs!".'
.format(self.name,child.value,child.parameterValues['goal']))
if 'upperLimit' in child.parameterValues.keys():
self.objectives[child.value]['upperLimit'] = child.parameterValues['upperLimit']
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

edited

if 'upperLimit' in child.parameterValues.keys():
self.objectives[child.value]['upperLimit'] = child.parameterValues['upperLimit']
if 'lowerLimit' in child.parameterValues.keys():
self.objectives[child.value]['lowerLimit'] = child.parameterValues['lowerLimit']
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

edited

selection = data.isel(RAVEN_sample_ID=np.array(paretoFrontMask))

for obj in self.objectives.keys():
if 'upperLimit' in self.objectives[obj].keys():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup, code is cleaner

if 'upperLimit' in self.objectives[obj].keys():
selection = selection.where(selection[obj]<=self.objectives[obj]['upperLimit'])
if 'lowerLimit' in self.objectives[obj].keys():
selection = selection.where(selection[obj]>=self.objectives[obj]['lowerLimit'])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

edited as well

@@ -22,7 +22,7 @@



def nonDominatedFrontier(data, returnMask):
def nonDominatedFrontier(data, returnMask, minMask=None):
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 was not sure if passing the data as numpy array and min mask as a separate numpy array was the best way to pass this info to this method

if minMask is None:
pass
elif minMask is not None and minMask.shape[0] != data.shape[1]:
raise IOError("nonDominatedFrontier method: minMask has shape " + str(data.shape) + " while minMask has shape " + str(minMask.shape))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

message expanded and fixed

@wangcj05
Copy link
Collaborator

@mandd please update the user manual regarding the input syntax changes made in this PR.

@moosebuild
Copy link

Job Test mac on 1cedcba : invalidated by @joshua-cogliati-inl

upgraded miniconda, trying again

@moosebuild
Copy link

Job Test mac on 1cedcba : invalidated by @joshua-cogliati-inl

restarted civet

@moosebuild
Copy link

Job Test mac on 40d5279 : invalidated by @mandd

@wangcj05 wangcj05 merged commit dad45d8 into devel Mar 18, 2021
@mandd mandd added RAVENv2.1 All tasks and defects that will go in RAVEN v2.1 priority_normal task This tag should be used for any new capability, improvement or enanchment labels Mar 31, 2021
@alfoa alfoa deleted the mandd/paretoFrontPPrestruct branch April 23, 2021 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority_normal RAVENv2.1 All tasks and defects that will go in RAVEN v2.1 task This tag should be used for any new capability, improvement or enanchment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TASK] Extend ParetoFront PP
3 participants