Hi Luiz,
An OpenTURNS function has to return a sequence of float.
If you want to filter output values you have to do it on the output sample.
For example if you want to retain only positive values:
import openturns as ot
In [2]: def a_exec(X):
...: Y = [0]
...: Y[0] = X[0] + X[1]
...: return Y
In [2]: def a_exec(X):
...: Y = [0]
...: Y[0] = X[0] + X[1]
...: return Y
In [3]: myFunc = ot.PythonFunction(2, 1, a_exec)
In [4]: inS = ot.Normal(2).getSample(10)
In [4]: inS = ot.Normal(2).getSample(10)
In [9]: pos=ot.Sample(0,1)
...: for i in range(len(outS)):
...: if outS[i,0] >0.0:
...: pos.add(outS[i])
...: for i in range(len(outS)):
...: if outS[i,0] >0.0:
...: pos.add(outS[i])
In [10]: pos
Out[10]: class=Sample name=Unnamed implementation=class=SampleImplementation name=Unnamed size=4 dimension=1 data="">
Out[10]: class=Sample name=Unnamed implementation=class=SampleImplementation name=Unnamed size=4 dimension=1 data="">
j
De : [email protected] <[email protected]> de la part de Luiz augusto da silva Florêncio <[email protected]>
Envoyé : lundi 9 octobre 2017 16:41:44
À : [email protected]
Objet : [ot-users] Stored process of function results in Monte Carlo simulation
Envoyé : lundi 9 octobre 2017 16:41:44
À : [email protected]
Objet : [ot-users] Stored process of function results in Monte Carlo simulation
Hi all,
I am a new user of OpenTurns and I have two questions about how I can handle the results of a Python function in a Monte Carlo simulation algorithm:
1) I would like to skip the stored process of a specific values calculated from my OpenTurns Python Function or store a Null/None value in the outputRandomVector. For example, if I have the script:
class modelePYTHON(OpenTURNSPythonFunction):
def __init__(self):
OpenTURNSPythonFunction.__init__(self,4,1)
def _exec(self,x):
E = x[0]
F = x[1]
L = x[2]
I = x[3]
uy = (F*L*L*L)/(3*E*I)
if uy <= 15.0:
return[uy]
else:
# Here I face my problem
return[None()]
deviation = NumericalMathFunction(modelePYTHON())
that possibility does not work, so how can I solve my problem?
2) Is it possible to transfrom the outputRandomVectors in a list of its sample valuesand modify their values according to the propreties of list from Python? ( delete a value, add new ones)
Thanks for your time,
Luiz Augusto.
_______________________________________________ OpenTURNS users mailing list [email protected] http://openturns.org/mailman/listinfo/users
- [ot-users] Stored process of function res... Luiz augusto da silva Florêncio
- Re: [ot-users] Stored process of fun... Julien Schueller | Phimeca
