1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2023 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 Ensemble Of Simulations Generation
26 __author__ = "Jean-Philippe ARGAUD"
29 import daCore.NumericObjects
31 # ==============================================================================
32 def eosg(selfA, Xb, HO, outputEOX = False):
34 Ensemble Of Simulations Generation
37 __seed = numpy.random.get_state()
38 sampleList = daCore.NumericObjects.BuildComplexSampleList(
39 selfA._parameters["SampleAsnUplet"],
40 selfA._parameters["SampleAsExplicitHyperCube"],
41 selfA._parameters["SampleAsMinMaxStepHyperCube"],
42 selfA._parameters["SampleAsIndependantRandomVariables"],
47 if selfA._parameters["SetDebug"]:
48 CUR_LEVEL = logging.getLogger().getEffectiveLevel()
49 logging.getLogger().setLevel(logging.DEBUG)
50 print("===> Beginning of evaluation, activating debug\n")
51 print(" %s\n"%("-"*75,))
53 Hm = HO["Direct"].appliedTo
57 returnSerieAsArrayMatrix = True,
60 if selfA._parameters["SetDebug"]:
61 print("\n %s\n"%("-"*75,))
62 print("===> End evaluation, deactivating debug if necessary\n")
63 logging.getLogger().setLevel(CUR_LEVEL)
66 if outputEOX or selfA._toStore("EnsembleOfStates"):
67 # Attention la liste s'épuise donc il faut la recréer
68 numpy.random.set_state(__seed)
69 sampleList = daCore.NumericObjects.BuildComplexSampleList(
70 selfA._parameters["SampleAsnUplet"],
71 selfA._parameters["SampleAsExplicitHyperCube"],
72 selfA._parameters["SampleAsMinMaxStepHyperCube"],
73 selfA._parameters["SampleAsIndependantRandomVariables"],
76 # Il faut passer la liste en tuple/list pour stack
77 EOX = numpy.stack(tuple(sampleList), axis=1)
78 assert EOX.shape[1] == EOS.shape[1], " Error of number of states in Ensemble Of Simulations Generation"
79 if selfA._toStore("EnsembleOfStates"):
80 selfA.StoredVariables["EnsembleOfStates"].store( EOX )
81 if selfA._toStore("EnsembleOfSimulations"):
82 selfA.StoredVariables["EnsembleOfSimulations"].store( EOS )
89 # ==============================================================================
90 if __name__ == "__main__":
91 print('\n AUTODIAGNOSTIC\n')