model = persalys.SymbolicPhysicalModel('aModelPhys', [X0, X1], [Y0],
                                       ['sin(X0)+8*X1'])
anOTStudy.add(model)

# Design of Experiment ##
aDesign = persalys.GridDesignOfExperiment('aDesign_1', model,
                                          [[0.9, 1.1], [1.8, 2.2]])
anOTStudy.add(aDesign)

aDesign.run()
print('outs=', aDesign.getResult().getDesignOfExperiment().getOutputSample())

# Design of Experiment ##
filename = 'normal.csv'
ot.Normal(3).getSample(10).exportToCSVFile(filename)
aDesign2 = persalys.ImportedDesignOfExperiment('aDesign_2', model, filename,
                                               [0, 2])
anOTStudy.add(aDesign2)

aDesign2.run()
print('outs=', aDesign2.getResult().getDesignOfExperiment().getOutputSample())

# Design of Experiment ##
aDesign3 = persalys.ProbabilisticDesignOfExperiment('aDesign_3', model, 10,
                                                    'QUASI_MONTE_CARLO')
anOTStudy.add(aDesign3)

aDesign3.run()
print('outs=', aDesign3.getResult().getDesignOfExperiment().getOutputSample())

# Design of Experiment ##
aDesign4 = persalys.FixedDesignOfExperiment('aDesign_4', model)
# fixed design ##
ot.RandomGenerator.SetSeed(0)
fixedDesign = persalys.FixedDesignOfExperiment('fixedDesign', symbolicModel)
inputSample = ot.LHSExperiment(ot.ComposedDistribution([ot.Uniform(0., 10.), ot.Uniform(0., 10.)]), 10).generate()
inputSample.stack(ot.Sample(10, [0.5]))
fixedDesign.setOriginalInputSample(inputSample)
fixedDesign.run()
myStudy.add(fixedDesign)

# grid ##
values = [[0.5+i*1.5 for i in range(7)], [0.5+i*1.5 for i in range(7)], [1]]
grid = persalys.GridDesignOfExperiment('grid', symbolicModel, values)
myStudy.add(grid)

# importDesign ##
importDesign = persalys.ImportedDesignOfExperiment('importDesign', symbolicModel, 'data.csv', [0, 2, 3])
importDesign.run()
myStudy.add(importDesign)

# onePointDesign ##
onePointDesign = persalys.GridDesignOfExperiment('onePointDesign', pythonModel)
myStudy.add(onePointDesign)

# twoPointsDesign ##
twoPointsDesign = persalys.GridDesignOfExperiment('twoPointsDesign', pythonModel, [[0.2], [1.2], [-0.2, 1.]])
myStudy.add(twoPointsDesign)

# fixed DataModel ##
fixedDataModel = persalys.DataModel('fixedDataModel', fixedDesign.getOriginalInputSample(), fixedDesign.getResult().getDesignOfExperiment().getOutputSample())
myStudy.add(fixedDataModel)
Example #3
0
filename = 'données.csv'
ot.RandomGenerator_SetSeed(0)
ot.Normal(3).getSample(10).exportToCSVFile(filename)
inColumns = [0, 2]

# Model 1
model = persalys.DataModel('myDataModel', filename, inColumns)
myStudy.add(model)
print(model)

# Model 2
model2 = persalys.SymbolicPhysicalModel(
    'SM', [persalys.Input('A'), persalys.Input('B')], [persalys.Output('S')],
    ['A+B+2'])
myStudy.add(model2)
importedDOE = persalys.ImportedDesignOfExperiment('doeI', model2, filename,
                                                  inColumns)
myStudy.add(importedDOE)

# script
script = myStudy.getPythonScript()
print(script)

# save
xmlFileName = 'file_with_données.xml'
myStudy.save(xmlFileName)

# open
s = persalys.Study.Open('file_with_données.xml')
print(s.getPythonScript())

os.remove(filename)
# Designs of Experiment ##

# design 2 ##
values = [[0.5 + i * 1.5 for i in range(7)], [0.5 + i * 1.5 for i in range(7)],
          [1]]
design_2 = persalys.GridDesignOfExperiment('design_2', model1, values)
myStudy.add(design_2)

# design 4 ##
probaDesign = persalys.ProbabilisticDesignOfExperiment('probaDesign', model1,
                                                       100, "MONTE_CARLO")
probaDesign.run()
myStudy.add(probaDesign)

design_3 = persalys.ImportedDesignOfExperiment('design_3', model1, 'data.csv',
                                               [0, 2, 3])
design_3.run()
myStudy.add(design_3)

# 1- meta model1 ##

# 1-a Kriging ##
kriging = persalys.KrigingAnalysis('kriging', probaDesign)
kriging.setBasis(ot.LinearBasisFactory(2).build())
kriging.setCovarianceModel(ot.MaternModel(2))
kriging.setTestSampleValidation(True)
kriging.setKFoldValidation(True)
kriging.setInterestVariables(['y0', 'y1'])
myStudy.add(kriging)

# 1-b Chaos ##