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

fix pca related tests. #496

Merged
merged 6 commits into from
Dec 20, 2017
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
8 changes: 5 additions & 3 deletions framework/Samplers/AdaptiveSobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def localGenerateInput(self,model,oldInput):
for key in varName.strip().split(','):
self.values[key] = pt[v]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(pt[v])
self.inputInfo['ProbabilityWeight-'+varName.replace(",","-")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight-'+varName] = self.inputInfo['SampledVarsPb'][varName]
# compute the SampledVarsPb for N-D distribution
elif self.variables2distributionsMapping[varName]['totDim'] > 1 and self.variables2distributionsMapping[varName]['reducedDim'] == 1:
dist = self.variables2distributionsMapping[varName]['name']
Expand All @@ -396,11 +396,13 @@ def localGenerateInput(self,model,oldInput):
for key in var.strip().split(','):
self.values[key] = pt[location]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(ndCoordinates)
self.inputInfo['ProbabilityWeight-'+varName.replace(",","!")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight']*=self.inputInfo['ProbabilityWeight-'+varName.replace(",","!")]
self.inputInfo['ProbabilityWeight-'+dist] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight']*=self.inputInfo['ProbabilityWeight-'+dist]
self.inputInfo['PointProbability'] = reduce(mul,self.inputInfo['SampledVarsPb'].values())
# reassign SampledVarsPb to fully correlated variables
self._reassignSampledVarsPbToFullyCorrVars()
# reassign probability weight to correlated variables
self._reassignPbWeightToCorrelatedVars()
self.inputInfo['SamplerType'] = 'Adaptive Sparse Grids for Sobol'

def _addPointToDataObject(self,subset,point):
Expand Down
8 changes: 5 additions & 3 deletions framework/Samplers/AdaptiveSparseGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def localGenerateInput(self,model,myInput):
for key in varName.strip().split(','):
self.values[key] = pt[v]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(pt[v])
self.inputInfo['ProbabilityWeight-'+varName.replace(",","-")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight-'+varName] = self.inputInfo['SampledVarsPb'][varName]
# compute the SampledVarsPb for N-D distribution
elif self.variables2distributionsMapping[varName]['totDim'] > 1 and self.variables2distributionsMapping[varName]['reducedDim'] ==1:
dist = self.variables2distributionsMapping[varName]['name']
Expand All @@ -354,11 +354,13 @@ def localGenerateInput(self,model,myInput):
for key in var.strip().split(','):
self.values[key] = pt[location]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(ndCoordinates)
self.inputInfo['ProbabilityWeight-'+varName.replace(",","!")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight']*=self.inputInfo['ProbabilityWeight-'+varName.replace(",","!")]
self.inputInfo['ProbabilityWeight-'+dist] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight']*=self.inputInfo['ProbabilityWeight-'+dist]
self.inputInfo['PointProbability'] = reduce(mul,self.inputInfo['SampledVarsPb'].values())
# reassign SampledVarsPb to fully correlated variables
self._reassignSampledVarsPbToFullyCorrVars()
# reassign probability weight to correlated variables
self._reassignPbWeightToCorrelatedVars()
self.inputInfo['SamplerType'] = self.type

def localFinalizeActualSampling(self,jobObject,model,myInput):
Expand Down
2 changes: 1 addition & 1 deletion framework/Samplers/Sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def _constantVariables(self):
# we consider that CDF of the constant variables is equal to 1 (same as its Pb Weight)
self.inputInfo['SampledVarsPb'].update(dict.fromkeys(self.constants.keys(),1.0))
pbKey = ['ProbabilityWeight-'+key for key in self.constants.keys()]
self.addMetaKeys(pbKey)
self.addMetaKeys(*pbKey)
self.inputInfo.update(dict.fromkeys(['ProbabilityWeight-'+key for key in self.constants.keys()],1.0))

def amIreadyToProvideAnInput(self): #inLastOutput=None):
Expand Down
8 changes: 6 additions & 2 deletions framework/Samplers/Sobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def localGenerateInput(self,model,myInput):
for key in varName.strip().split(','):
self.values[key] = pt[v]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(pt[v])
self.inputInfo['ProbabilityWeight-'+varName.replace(",","-")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight-'+varName] = self.inputInfo['SampledVarsPb'][varName]
# compute the SampledVarsPb for N-D distribution
elif self.variables2distributionsMapping[varName]['totDim'] > 1 and self.variables2distributionsMapping[varName]['reducedDim'] == 1:
dist = self.variables2distributionsMapping[varName]['name']
Expand All @@ -220,8 +220,12 @@ def localGenerateInput(self,model,myInput):
for key in var.strip().split(','):
self.values[key] = pt[location]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(ndCoordinates)
self.inputInfo['ProbabilityWeight-'+varName.replace(",","!")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight-'+dist] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['PointProbability'] = reduce(mul,self.inputInfo['SampledVarsPb'].values())
self.inputInfo['ProbabilityWeight'] = np.atleast_1d(1.0) # weight has no meaning for sobol
# reassign SampledVarsPb to fully correlated variables
self._reassignSampledVarsPbToFullyCorrVars()
# reassign probability weight to correlated variables
self._reassignPbWeightToCorrelatedVars()
self.inputInfo['SamplerType'] = 'Sparse Grids for Sobol'

6 changes: 4 additions & 2 deletions framework/Samplers/SparseGridCollocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def localGenerateInput(self,model,myInput):
for key in varName.strip().split(','):
self.values[key] = pt[v]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(pt[v])
self.inputInfo['ProbabilityWeight-'+varName.replace(",","-")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight-'+varName] = self.inputInfo['SampledVarsPb'][varName]
# compute the SampledVarsPb for N-D distribution
# Assume only one N-D distribution is associated with sparse grid collocation method
elif self.variables2distributionsMapping[varName]['totDim'] > 1 and self.variables2distributionsMapping[varName]['reducedDim'] ==1:
Expand All @@ -313,12 +313,14 @@ def localGenerateInput(self,model,myInput):
for key in var.strip().split(','):
self.values[key] = pt[location]
self.inputInfo['SampledVarsPb'][varName] = self.distDict[varName].pdf(ndCoordinates)
self.inputInfo['ProbabilityWeight-'+varName.replace(",","!")] = self.inputInfo['SampledVarsPb'][varName]
self.inputInfo['ProbabilityWeight-'+dist] = self.inputInfo['SampledVarsPb'][varName]

self.inputInfo['ProbabilityWeight'] = weight
self.inputInfo['PointProbability'] = reduce(mul,self.inputInfo['SampledVarsPb'].values())
# reassign SampledVarsPb to fully correlated variables
self._reassignSampledVarsPbToFullyCorrVars()
# reassign probability weight to correlated variables
self._reassignPbWeightToCorrelatedVars()
self.inputInfo['SamplerType'] = 'Sparse Grid Collocation'

def readFromROM(self):
Expand Down
23 changes: 22 additions & 1 deletion scripts/conversionScripts/toBasicStatsPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,21 @@ def convert(tree,fileName=None):

steps = simulation.find('Steps')
postProcess = steps.findall('PostProcess')

TestInfo = simulation.find('TestInfo')
revisions = TestInfo.find('revisions')
hasRev = True
if revisions is None:
revisions = ET.Element('revisions')
hasRev = False
rev = ET.Element('revision')
rev.attrib['author'] = 'wangc'
rev.attrib['date'] = '2017-12-20'
rev.text = 'convert test to use the new DataObjects with the new structure of basic statistic'
revisions.append(rev)
if not hasRev:
TestInfo.append(revisions)

toRemove = []

if models is None: return tree # no models, no BasicStats
timeDep = {}
Expand Down Expand Up @@ -201,6 +215,7 @@ def convert(tree,fileName=None):
hasPrint = False
for output in outputs:
if output.attrib['class'] == 'Files':
toRemove.append(output.text)
output.attrib['class'] = 'DataObjects'
output.attrib['type'] = 'PointSet' if pivotParam is None else 'HistorySet'
output.text = dataSetName
Expand All @@ -218,6 +233,12 @@ def convert(tree,fileName=None):
printNode.attrib['class'] = 'OutStreams'
printNode.attrib['type'] = 'Print'
printNode.text = dataSetName + '_dump'
# move unused files
if len(toRemove) > 0:
files = simulation.find('Files')
for inputFile in files:
if inputFile.attrib['name'] in toRemove:
files.remove(inputFile)

return tree

Expand Down
4 changes: 0 additions & 4 deletions tests/framework/PostProcessors/Metrics/test_metric.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@
<type>csv</type>
<source>pp1_metric</source>
</Print>
<Print name="pp1_metric_dump">
<type>csv</type>
<source>pp1_metric</source>
</Print>
</OutStreams>

</Simulation>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
x2,x1,constantine,OutputPlaceHolder
0.02,0.777044571556,3.14159,1.0
0.02,0.373049301773,3.14159,2.0
0.02,0.407090028487,3.14159,3.0
0.6,0.777044571556,3.14159,4.0
0.6,0.373049301773,3.14159,5.0
0.6,0.407090028487,3.14159,6.0
x2,x1,constantine,OutputPlaceHolder,ProbabilityWeight
0.02,0.777044571556,3.14159,1.0,0.31
0.02,0.373049301773,3.14159,2.0,0.31
0.02,0.407090028487,3.14159,3.0,0.31
0.6,0.777044571556,3.14159,4.0,0.31
0.6,0.373049301773,3.14159,5.0,0.31
0.6,0.407090028487,3.14159,6.0,0.31
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Print name='PointsetEnsembleForward'>
<type>csv</type>
<source>PointsetEnsembleForward</source>
<what>input, output, metadata|ProbabilityWeight</what>
</Print>
</OutStreams>

Expand All @@ -74,7 +75,7 @@

<DataObjects>
<PointSet name='PointsetEnsembleForward'>
<Input>x1,x2,constantine</Input>
<Input>x2,x1,constantine</Input>
<Output>OutputPlaceHolder</Output>
</PointSet>
</DataObjects>
Expand Down
22 changes: 11 additions & 11 deletions tests/framework/pca_LHS/gold/LHS/testPrintPointSet_dump.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
x1,y1,z1,x0,y0,z0,PointProbability,ProbabilityWeight,x,y,z
-0.53105898794,-0.569259389682,3.22893095003,-1.0913123605,0.899681849331,1.04029440408,0.000255355698073,1.31295915554e-05,-0.743344602433,0.349632634293,0.97067349756
0.445025704532,1.26351501403,-2.17818337975,0.608051846435,1.61265799898,3.3588520593,0.00241437203718,0.000213147185818,0.812297452923,1.90404948914,3.20401930369
1.24579814031,-0.0876059462285,-4.00510478781,2.0978643737,1.17733859737,2.37653038289,9.56794906349e-06,3.12591774386e-07,1.97554170164,2.20081407068,2.3096735992
-1.00397803541,-1.3874935316,1.71331609343,-1.00199872676,-0.229362887287,0.771562803628,0.00337588854906,0.00135362045116,-0.882251413774,-0.746858813451,0.737821112961
-1.46557772951,-0.986101660274,0.573811760616,-1.27787951207,-0.617228954739,1.44513538013,0.0113152619358,0.00339980732463,-1.18567259467,-1.26305898464,1.38828328975
-0.425684337499,-0.327671122605,4.06143380958,-1.23656660264,1.28144786679,1.05433777113,1.43936178528e-05,3.12591774385e-07,-0.792745407311,0.660293593444,0.974220965504
0.0460394675712,2.04616646561,-0.277225472711,-0.383031935436,2.08526636488,3.74883044634,0.00752367171833,0.00339980732463,0.0745705028493,1.91863109543,3.5410991572
-0.0491383622033,0.0881018431042,-1.09705713377,0.179069729999,0.789398859874,2.29747910141,0.0346079784075,0.00135362045116,0.298845409293,0.881111142501,2.17994344681
2.10377576773,0.372641118679,2.36918706333,1.3659604187,3.39352026782,1.31141113685,0.000391429078475,0.000213147185818,1.78425882579,4.10538892065,1.34594100663
0.675431749619,0.82782638421,-3.32436118114,1.18737346547,1.33889328799,3.15655260213,0.000142915570757,1.31295915554e-05,1.24432178869,1.90385379507,3.02540830647
x1,y1,z1,x0,y0,z0,x,y,z,ProbabilityWeight,PointProbability
-0.53105898794,-0.569259389682,3.22893095003,-1.0913123605,0.899681849331,1.04029440408,-0.743344602433,0.349632634293,0.97067349756,1.31295915554e-05,0.000255355698073
0.445025704532,1.26351501403,-2.17818337975,0.608051846435,1.61265799898,3.3588520593,0.812297452923,1.90404948914,3.20401930369,0.000213147185818,0.00241437203718
1.24579814031,-0.0876059462285,-4.00510478781,2.0978643737,1.17733859737,2.37653038289,1.97554170164,2.20081407068,2.3096735992,3.12591774386e-07,9.56794906349e-06
-1.00397803541,-1.3874935316,1.71331609343,-1.00199872676,-0.229362887287,0.771562803628,-0.882251413774,-0.746858813451,0.737821112961,0.00135362045116,0.00337588854906
-1.46557772951,-0.986101660274,0.573811760616,-1.27787951207,-0.617228954739,1.44513538013,-1.18567259467,-1.26305898464,1.38828328975,0.00339980732463,0.0113152619358
-0.425684337499,-0.327671122605,4.06143380958,-1.23656660264,1.28144786679,1.05433777113,-0.792745407311,0.660293593444,0.974220965504,3.12591774385e-07,1.43936178528e-05
0.0460394675712,2.04616646561,-0.277225472711,-0.383031935436,2.08526636488,3.74883044634,0.0745705028493,1.91863109543,3.5410991572,0.00339980732463,0.00752367171833
-0.0491383622033,0.0881018431042,-1.09705713377,0.179069729999,0.789398859874,2.29747910141,0.298845409293,0.881111142501,2.17994344681,0.00135362045116,0.0346079784075
2.10377576773,0.372641118679,2.36918706333,1.3659604187,3.39352026782,1.31141113685,1.78425882579,4.10538892065,1.34594100663,0.000213147185818,0.000391429078475
0.675431749619,0.82782638421,-3.32436118114,1.18737346547,1.33889328799,3.15655260213,1.24432178869,1.90385379507,3.02540830647,1.31295915554e-05,0.000142915570757
Loading