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

Multiple Inputs for dummy models #2006

Merged
merged 4 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ def impConstr2(Input):
@ out, g, float, implicit constraint 2 evaluation function
"""
g = Input.x1**2 + Input.obj - 10
return g
return g
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ def impConstr2(Input):
@ out, g, float, implicit constraint 2 evaluation function
"""
g = Input.x1**2 + Input.obj - 10
return g
return g
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def run(self,Inputs):
@ In, Inputs, dict, additional inputs
@ Out, None
"""
self.?? = evaluate(Inputs) # Complete This # make sure the name of the objective is consistent obj
self.?? = evaluate(Inputs) # Complete This # make sure the name of the objective is consistent obj
5 changes: 0 additions & 5 deletions ravenframework/Models/Dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ def _manipulateInput(self,dataIn):
@ In, dataIn, object, the object that needs to be manipulated
@ Out, inRun, dict, the manipulated input
"""
if len(dataIn)>1:
self.raiseAnError(IOError,'Only one input is accepted by the model type '+self.type+' with name '+self.name)
if type(dataIn[0])!=tuple:
inRun = self._inputToInternal(dataIn[0]) #this might happen when a single run is used and the input it does not come from self.createNewInput
else:
Expand Down Expand Up @@ -152,9 +150,6 @@ def createNewInput(self,myInput,samplerType,**kwargs):
a mandatory key is the sampledVars'that contains a dictionary {'name variable':value}
@ Out, ([(inputDict)],copy.deepcopy(kwargs)), tuple, return the new input in a tuple form
"""
if len(myInput)>1:
self.raiseAnError(IOError,'Only one input is accepted by the model type '+self.type+' with name'+self.name)

Comment on lines -155 to -157
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mandd I guess we can remove this constraint for external model, but I think we still need it for ROM. Could you just remove this constraint in the external model.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

inputDict = self._inputToInternal(myInput[0])
self._replaceVariablesNamesWithAliasSystem(inputDict,'input',False)

Expand Down
17 changes: 17 additions & 0 deletions ravenframework/Models/ROM.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ def applyRunInfo(self, runInfo):
"""
self.numThreads = runInfo.get('NumThreads', 1)

def createNewInput(self,myInput,samplerType,**kwargs):
"""
This function will return a new input to be submitted to the model, it is called by the sampler.
here only a PointSet is accepted a local copy of the values is performed.
For a PointSet, only the last set of entries are copied
The copied values are returned as a dictionary back
@ In, myInput, list, the inputs (list) to start from to generate the new one
@ In, samplerType, string, is the type of sampler that is calling to generate a new input
@ In, **kwargs, dict, is a dictionary that contains the information coming from the sampler,
a mandatory key is the sampledVars'that contains a dictionary {'name variable':value}
@ Out, ([(inputDict)],copy.deepcopy(kwargs)), tuple, return the new input in a tuple form
"""
if len(myInput)>1:
self.raiseAnError(IOError,'Only one input is accepted by the model type '+self.type+' with name'+self.name)
[(inputDict)],kwargs = super().createNewInput(myInput,samplerType,**kwargs)
return ([(inputDict)],kwargs)

def _readMoreXML(self,xmlNode):
"""
Function to read the portion of the xml input that belongs to this specialized class
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/AnalyticModels/linModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def main(Input):
Input['x1'] = 5.5
Input['x2'] = 8
a,b,c = main(Input)
print(a,b,c)
print(a,b,c)
2 changes: 1 addition & 1 deletion tests/framework/ROM/pickleTests/eRl_setAddtlParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ def main():
sys.exit(results['fail'])

if __name__ == '__main__':
main()
main()