File: t_SRCAnalysis_std.py

package info (click to toggle)
persalys 19.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 46,900 kB
  • sloc: xml: 97,263; cpp: 61,701; python: 4,109; sh: 397; makefile: 84
file content (58 lines) | stat: -rwxr-xr-x 1,257 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/env python

import openturns as ot
import persalys

myStudy = persalys.Study("myStudy")

# Model
x0 = persalys.Input("x0", ot.Normal())
x1 = persalys.Input("x1", ot.Normal())
y00 = persalys.Output("fake_y0")
y00.setIsSelected(False)
y0 = persalys.Output("y0")

formula_y00 = "x0"
formula_y0 = "10+3*x0+x1"
model = persalys.SymbolicPhysicalModel(
    "aModel", [x0, x1], [y00, y0], [formula_y00, formula_y0]
)
myStudy.add(model)

# SRC ##
analysis = persalys.SRCAnalysis("aSRC", model)
analysis.setSimulationsNumber(1000)
analysis.setSeed(2)
myStudy.add(analysis)
print(analysis)

analysis.run()

print("result=", analysis.getResult())

# SRC ##
X2 = persalys.Input("x2", 10)
model.addInput(X2)
model.addOutput(persalys.Output("y1"))
model.setFormula("y1", "3*x0 + x1 + x2")

analysis2 = persalys.SRCAnalysis("aSRC2", model)
analysis2.setSimulationsNumber(1000)
analysis2.setSeed(2)
analysis2.setInterestVariables(["y1"])
myStudy.add(analysis2)
print(analysis2)

analysis2.run()

result2 = analysis2.getResult()
print("result=", result2)

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

# check getImplementation
analysis3 = persalys.Analysis(analysis2).getImplementation()
assert analysis3.getSimulationsNumber() == 1000