1 #@ AJOUT OpenturnsSolver Macro
2 # -*- coding: iso-8859-1 -*-
6 Ce module contient le generateur Etude pour Openturns
11 defaultSTD = """#! /usr/bin/env python
13 class StudyFileGenerationError:
14 def __init__ (self, st):
17 return "'%s'" % self.st
19 raise StudyFileGenerationError, "The study file was not generated. Check analysis type."
22 headerSTD = """#! /usr/bin/env python
24 # Chargement du module systeme
28 # Chargement du module math
31 # Chargement du module Open TURNS
32 from openturns import *
39 from openturns.viewer import ViewImage,StopViewer,WaitForViewer
44 # Flush des messages en attente
47 # Terminaison du fichier
51 #=============================================
52 # La classe de creation du fichier STD
53 #=============================================
58 Generation du fichier python
60 def __init__ (self, appli, DictMCVal, ListeVariablesIn, ListeVariablesOut, DictLois ) :
61 self.DictMCVal = DictMCVal
62 self.ListeVariablesIn = ListeVariablesIn
63 self.ListeVariablesOut = ListeVariablesOut
64 self.DictLois = DictLois
65 #print "DictMCVal=", DictMCVal
66 print "ListeVariablesIn=", ListeVariablesIn
67 print "ListeVariablesOut=", ListeVariablesOut
68 #print "DictLois=", DictLois
69 self.texteSTD = defaultSTD
70 self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path
72 # Ce dictionnaire fait la correspondance entre le mot lu dans le dictionnaire des mots-clefs et la methode a appeler
76 { "Experiment Plane" : "ExperimentPlane",
77 "Random Sampling" : "MinMaxRandomSampling",
80 "Central Uncertainty" :
81 ( "CentralUncertainty",
82 { "Taylor Variance Decomposition" : "TaylorVarianceDecomposition",
83 "Random Sampling" : "CentralUncertaintyRandomSampling",
86 "Threshold Exceedence" :
87 ( "ThresholdExceedence",
88 { "Simulation" : "Simulation",
89 "FORM_SORM" : "Analytical",
90 "MonteCarlo" : "MonteCarlo",
92 "ImportanceSampling" : "ImportanceSampling",
93 "FirstOrder" : "FORM",
94 "SecondOrder" : "SORM",
96 "AbdoRackwitz" : "AbdoRackwitz",
101 # Ce dictionnaire liste le nom des variables utilisees dans le script
102 # La clef est le nom attendu par les methodes, la valeur est le nom produit dans le fichier de sortie
103 # Le fait de passer par un dictionnaire permet de controler que les variables existent et sont correctement nommees
104 # meme si clef == valeur
108 "wrapper" : "wrapper",
109 "wrapperdata" : "wrapperdata",
110 "frameworkdata" : "frameworkdata",
111 "framework" : "framework",
112 "studyid" : "studyid",
113 "studycase" : "studycase",
114 "componentname" : "componentname",
116 "scaledVector" : "scaledVector",
117 "translationVector" : "translationVector",
119 "myCenteredReductedGrid" : "myCenteredReductedGrid",
120 "myExperimentPlane" : "myExperimentPlane",
121 "inputSample" : "inputSample",
122 "outputSample" : "outputSample",
123 "minValue" : 'results["minValue"]',
124 "maxValue" : 'results["maxValue"]',
127 "distribution" : "distribution",
128 "marginal" : "marginal",
129 "collection" : "collection",
131 "correlation" : "correlation",
134 "description" : "description",
135 "inputRandomVector" : "inputRandomVector",
136 "outputRandomVector" : "outputRandomVector",
137 "myQuadraticCumul" : "myQuadraticCumul",
138 "meanFirstOrder" : 'results["meanFirstOrder"]',
139 "meanSecondOrder" : 'results["meanSecondOrder"]',
140 "standardDeviationFirstOrder" : 'results["standardDeviationFirstOrder"]',
141 "importanceFactors" : 'results["importanceFactors"]',
142 "importanceFactorsGraph" : "importanceFactorsGraph",
143 "importanceFactorsDrawing" : "importanceFactorsDrawing",
144 "empiricalMean" : 'results["empiricalMean"]',
145 "empiricalStandardDeviation" : 'results["empiricalStandardDeviation"]',
146 "empiricalQuantile" : 'results["empiricalQuantile"]',
149 "PCCcoefficient" : 'results["PCCcoefficient"]',
150 "PRCCcoefficient" : 'results["PRCCcoefficient"]',
151 "SRCcoefficient" : 'results["SRCcoefficient"]',
152 "SRRCcoefficient" : 'results["SRRCcoefficient"]',
154 "kernelSmoothedDist" : "kernelSmoothedDist",
155 "kernelSmoothedPDFDrawing" : "kernelSmoothedPDFDrawing",
156 "kernelSmoothedGraph" : "kernelSmoothedGraph",
157 "meanVector" : "meanVector",
158 "importanceDensity" : "importanceDensity",
159 "myEvent" : "myEvent",
161 "myResult" : "myResult",
162 "probability" : 'results["probability"]',
163 "standardDeviation" : 'results["standardDeviation"]',
166 "coefficientOfVariation" : 'results["coefficientOfVariation"]',
167 "convergenceGraph" : "convergenceGraph",
168 "convergenceDrawing" : "convergenceDrawing",
169 "simulationNumbers" : 'results["simulationNumbers"]',
170 "myOptimizer" : "myOptimizer",
171 "specificParameters" : "specificParameters",
172 "startingPoint" : "startingPoint",
173 "hasoferReliabilityIndex" : 'results["hasoferReliabilityIndex"]',
174 "standardSpaceDesignPoint" : 'results["standardSpaceDesignPoint"]',
175 "physicalSpaceDesignPoint" : 'results["physicalSpaceDesignPoint"]',
176 "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]',
177 "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]',
178 "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph",
179 "eventProbabilitySensitivityDrawing" : "eventProbabilitySensitivityDrawing",
180 "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph",
181 "hasoferReliabilityIndexSensitivityDrawing" : "hasoferReliabilityIndexSensitivityDrawing",
182 "modelEvaluationCalls" : 'results["modelEvaluationCalls"]',
183 "modelGradientCalls" : 'results["modelGradientCalls"]',
184 "modelHessianCalls" : 'results["modelHessianCalls"]',
185 "tvedtApproximation" : 'results["tvedtApproximation"]',
186 "hohenBichlerApproximation" : 'results["hohenBichlerApproximation"]',
187 "breitungApproximation" : 'results["breitungApproximation"]',
190 # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque
192 "DebugMessages" : "Log.DBG",
193 "WrapperMessages" : "Log.WRAPPER",
194 "UserMessages" : "Log.USER",
195 "InfoMessages" : "Log.INFO",
196 "WarningMessages" : "Log.WARN",
197 "ErrorMessages" : "Log.ERROR",
202 Pilotage de la creation du fichier python
205 if ( self.DictMCVal.has_key( 'Type' ) ):
206 TypeAnalyse = self.DictMCVal[ 'Type' ]
210 if ( self.traitement.has_key( TypeAnalyse ) ):
211 (Traitement, subDict) = self.traitement[ TypeAnalyse ]
213 if ( Traitement is not None ):
214 self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) )
220 Imprime l entete commun a tous les fichiers
222 txt = headerSTD % self.OpenTURNS_path
224 txt += "# Definit le niveau d'affichage de la log\n"
225 txt += "%s = Log.NONE\n" % self.variable["flags"]
226 for flag in self.logFlags.keys():
227 if ( self.DictMCVal.has_key( flag ) ):
228 val = self.DictMCVal[ flag ]
232 txt += "%s = %s %s %s\n" % (self.variable["flags"], self.variable["flags"], op, self.logFlags[ flag ])
233 txt += "Log.Show( %s )\n" % self.variable["flags"]
239 Imprime le pied de page commun a tous les fichiers
243 def MinMax (self, subDict):
245 Produit le fichier study correspondant a une analyse Min/Max
251 if ( self.DictMCVal.has_key( 'Method' ) ):
252 Methode = self.DictMCVal[ 'Method' ]
255 if ( subDict.has_key( Methode ) ):
256 Traitement = subDict[ Methode ]
258 if ( Traitement is not None ):
259 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
261 txt += self.MinMaxResult()
268 Importe le modele physique
270 if ( self.DictMCVal.has_key( 'FileName' ) ):
271 name = self.DictMCVal[ 'FileName' ]
273 txt = "# Charge le modele physique\n"
274 txt += "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name)
275 txt += "%s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"])
277 txt += "# Ces lignes sont utiles pour le fonctionnement du script sous Salome\n"
278 txt += "if globals().has_key('%s'):\n" % self.variable["framework"]
279 txt += " %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"])
280 txt += " %s.studyid_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studyid"])
281 txt += " %s.studycase_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studycase"])
282 txt += " %s.componentname_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"])
283 txt += " %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"])
284 txt += " %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"])
285 txt += "# Fin des lignes pour Salome\n"
287 txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],)
288 txt += "%s = %s.getInputDimension()\n" % (self.variable["n"], self.variable["model"])
292 def ExperimentPlane (self):
294 Etude par plan d experience
296 txt = "# Etude par plan d'experience\n"
298 txt += self.CenteredReductedGrid()
299 txt += self.ScaledVector()
300 txt += self.TranslationVector()
301 txt += "%s = %s\n" % (self.variable["inputSample"], self.variable["myExperimentPlane"])
303 txt += "# Etude 'Min/Max'\n"
305 txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"])
309 def MinMaxRandomSampling (self):
311 Etude par echantillonage aleatoire
314 if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ):
315 size = self.DictMCVal[ 'SimulationsNumber' ]
317 txt = "# Etude par echantillonage aleatoire\n"
318 txt += self.InputDistribution()
319 txt += self.InputRandomVector()
321 txt += "# Etude 'Min/Max'\n"
323 txt += "%s = %d\n" % (self.variable["inSize"], size)
324 txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"])
325 txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"])
328 def InputDistribution (self):
330 Cree la loi jointe des variables d entree
332 txt = "# Definit la loi jointe des variables d'entree\n"
333 txt += "%s = DistributionCollection( %s )\n" % (self.variable["collection"], self.variable["n"])
334 txt += "%s = Description( %s )\n" % (self.variable["description"], self.variable["n"])
338 for variable in self.ListeVariablesIn:
339 nomVar = variable['ModelVariable'].get_name()
340 dictVariables[ nomVar ] = variable['Distribution']
343 sortedVarNames = dictVariables.keys()
344 sortedVarNames.sort()
345 for variable in sortedVarNames:
346 conceptloi = dictVariables[ variable ]
347 loi = self.DictLois[ conceptloi ]
348 if loi.has_key( 'Kind' ):
349 marginale = "%s_%d" % (self.variable["marginal"], i)
350 txt += "# Definit la loi marginale de la composante %d\n" % i
351 txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) ))
352 txt += "%s.setName( '%s' )\n" % (marginale, conceptloi.get_name())
353 txt += "%s[ %d ] = '%s'\n" % (self.variable["description"], i, variable)
354 txt += "%s[ %d ] = Distribution( %s )\n" % (self.variable["collection"], i, marginale)
360 txt += "# Definit la loi jointe\n"
361 txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"])
362 txt += "%s.setDescription( %s )\n" % (self.variable["distribution"], self.variable["description"])
368 Cree la copule de la loi jointe
370 txt = "# Definit la copule de la loi jointe\n"
372 if ( not self.DictMCVal.has_key( 'Copula' ) ):
373 self.DictMCVal[ 'Copula' ] = 'Independent'
375 if ( self.DictMCVal[ 'Copula' ] in ( 'Independent', ) ):
376 txt += "%s = IndependentCopula( %s )\n" % (self.variable["copula"], self.variable["n"])
377 elif ( self.DictMCVal[ 'Copula' ] in ( 'Normal', ) ):
378 varList = self.DictMCVal[ 'CorrelationMatrix' ][0]
379 dimension = len(varList)
380 txt += "%s = {}\n" % self.variable["correlation"]
381 for i in range( dimension ):
382 txt += "%s['%s'] = {}\n" % (self.variable["correlation"], varList[i])
383 for j in range ( dimension ):
384 txt += "%s['%s']['%s'] = %g\n" % (self.variable["correlation"], varList[i], varList[j], self.DictMCVal[ 'CorrelationMatrix' ][i+1][j])
385 txt += "%s = getCorrelationMatrixFromMap( %s.getVariableList(), %s )\n" % (self.variable["R"], self.variable["wrapperdata"], self.variable["correlation"])
386 txt += "%s = NormalCopula( %s )\n" % (self.variable["copula"], self.variable["R"])
391 def InputRandomVector (self):
393 Cree le vector aleatoire d entree
395 txt = "# Definit le vecteur aleatoire d'entree\n"
396 txt += "%s = RandomVector( %s )\n" % (self.variable["inputRandomVector"], self.variable["distribution"])
400 def OutputRandomVector (self):
402 Cree le vector aleatoire de sortie
405 for variable in self.ListeVariablesOut:
406 nomVar = variable['ModelVariable'].get_name()
408 txt = "# Definit le vecteur aleatoire de sortie\n"
409 txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"])
410 txt += "%s.setName( '%s' )\n" % (self.variable["outputRandomVector"], nomVar)
414 def ScaledVector (self):
416 Definit les coefficients multiplicateurs par composante du vecteur
419 if ( self.DictMCVal.has_key( 'UnitsPerDimension' ) ):
420 unitsPerDimension = self.DictMCVal[ 'UnitsPerDimension' ]
421 dimension = len( unitsPerDimension )
423 txt = "# Definit les facteurs d'echelle dans chaque direction\n"
424 txt += "%s = NumericalPoint( %s )\n" % (self.variable["scaledVector"], self.variable["n"])
425 for i in range(dimension):
426 txt += "%s[%d] = %g\n" % (self.variable["scaledVector"], i, unitsPerDimension[i])
427 txt += "%s.scale( %s )\n" % (self.variable["myExperimentPlane"], self.variable["scaledVector"])
431 def TranslationVector (self):
433 Definit le vecteur de translation
436 if ( self.DictMCVal.has_key( 'Center' ) ):
437 center = self.DictMCVal[ 'Center' ]
438 dimension = len( center )
440 txt = "# Definit le vecteur de translation\n"
441 txt += "%s = NumericalPoint( %s )\n" % (self.variable["translationVector"], self.variable["n"])
442 for i in range(dimension):
443 txt += "%s[%d] = %g\n" % (self.variable["translationVector"], i, center[i])
444 txt += "%s.translate( %s )\n" % (self.variable["myExperimentPlane"], self.variable["translationVector"])
450 Definit les niveaux du plan d experience
453 if ( self.DictMCVal.has_key( 'Levels' ) ):
454 levels = self.DictMCVal[ 'Levels' ]
455 dimension = len( levels )
457 txt = "# Definit les niveaux de la structure de grille\n"
458 txt += "%s = NumericalPoint( %d )\n" % (self.variable["levels"], dimension)
459 for i in range(dimension):
460 txt += "%s[%d] = %g\n" % (self.variable["levels"], i, levels[i])
464 def CenteredReductedGrid (self):
466 Definit la grille reduite du plan d experience
469 if ( self.DictMCVal.has_key( 'ExperimentPlane' ) ):
470 plane = self.DictMCVal[ 'ExperimentPlane' ]
472 txt = "# Cree le plan d'experience centre reduit\n"
473 txt += "%s = %s(%s, %s)\n" % (self.variable["myCenteredReductedGrid"], plane, self.variable["n"], self.variable["levels"])
474 txt += "%s = %s.generate()\n" % (self.variable["myExperimentPlane"], self.variable["myCenteredReductedGrid"])
478 def MinMaxResult (self):
480 Produit les resultats de l etude
482 txt = "# Resultats\n"
483 txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"])
484 txt += "print '%s = ', %s\n" % ("minValue", self.variable["minValue"])
486 txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"])
487 txt += "print '%s = ', %s\n" % ("maxValue", self.variable["maxValue"])
491 def CentralUncertainty (self, subDict):
493 Produit le fichier study correspondant a une analyse d incertitude en valeur centrale
497 txt += self.InputDistribution()
498 txt += self.InputRandomVector()
499 txt += self.OutputRandomVector()
502 if ( self.DictMCVal.has_key( 'Method' ) ):
503 Methode = self.DictMCVal[ 'Method' ]
506 if ( subDict.has_key( Methode ) ):
507 Traitement = subDict[ Methode ]
509 if ( Traitement is not None ):
510 txt += "# Etude 'Central Uncertainty'\n"
511 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
517 def TaylorVarianceDecomposition (self):
519 Etude par decomposition de Taylor
521 txt = "# Cumul quadratique (decomposition de Taylor)\n"
522 txt += "%s = QuadraticCumul( %s )\n" % (self.variable["myQuadraticCumul"], self.variable["outputRandomVector"])
524 txt += "# Resultats\n"
526 if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ):
527 if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ):
528 txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"])
529 txt += "print '%s = ', %s\n" % ("mean First Order", self.variable["meanFirstOrder"])
532 if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ):
533 if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ):
534 txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"])
535 txt += "print '%s = ', %s\n" % ("mean Second Order", self.variable["meanSecondOrder"])
538 if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ):
539 if ( self.DictMCVal[ 'StandardDeviationFirstOrder' ] == "yes" ):
540 txt += "%s = %s.getCovariance()\n" % (self.variable["standardDeviationFirstOrder"], self.variable["myQuadraticCumul"])
541 txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"]
542 txt += "for i in range( dim ):\n"
543 txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"])
544 txt += " print '%s = ', %s[ i, i ]\n" % ("standard Deviation First Order", self.variable["standardDeviationFirstOrder"])
547 if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ):
548 if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ):
549 txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"])
550 txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"]
551 txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"])
553 txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"])
554 txt += "#Show( %s )\n" % self.variable["importanceFactorsGraph"]
555 txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ])
556 txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"])
557 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"]
558 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"]
559 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"]
565 def CentralUncertaintyRandomSampling (self):
567 Etude par echantillonage aleatoire
570 if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ):
571 size = self.DictMCVal[ 'SimulationsNumber' ]
573 txt = "# Echantillonnage aleatoire de la variable de sortie\n"
574 txt += "%s = %d\n" % (self.variable["inSize"], size)
575 txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"])
576 txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"])
579 if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ):
580 if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ):
581 txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"])
582 txt += "print '%s =', %s[0]\n" % ("empirical Mean", self.variable["empiricalMean"])
585 if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ):
586 if ( self.DictMCVal[ 'EmpiricalStandardDeviation' ] == "yes" ):
587 txt += "%s = %s.computeCovariance()\n" % (self.variable["empiricalStandardDeviation"], self.variable["outputSample"])
588 txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"]
589 txt += "for i in range( dim ):\n"
590 txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"])
591 txt += " print '%s = ', %s[ i, i ]\n" % ("empirical Standard Deviation", self.variable["empiricalStandardDeviation"])
594 if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ):
595 ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ]
596 txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre)
597 txt += "print '%s ( %s ) =', %s\n" % ("empirical Quantile", ordre, self.variable["empiricalQuantile"])
600 if ( self.DictMCVal.has_key( 'CorrelationAnalysis' ) ):
601 if ( self.DictMCVal[ 'CorrelationAnalysis' ] == "yes" ):
602 txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"]
603 txt += " %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
604 txt += " print 'PCC Coefficients:'\n"
605 txt += " for i in range( %s ):\n" % self.variable["n"]
606 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PCCcoefficient"])
608 txt += " %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
609 txt += " print 'PRCC Coefficients:'\n"
610 txt += " for i in range( %s ):\n" % self.variable["n"]
611 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PRCCcoefficient"])
613 txt += " %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
614 txt += " print 'SRC Coefficients:'\n"
615 txt += " for i in range( %s ):\n" % self.variable["n"]
616 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRCcoefficient"])
618 txt += " %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
619 txt += " print 'SRRC Coefficients:'\n"
620 txt += " for i in range( %s ):\n" % self.variable["n"]
621 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRRCcoefficient"])
624 if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ):
625 if ( self.DictMCVal[ 'KernelSmoothing' ] == "yes" ):
626 txt += "# Kernel Smoohing\n"
627 txt += "%s = KernelSmoothing()\n" % self.variable["kernel"]
628 txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"]
629 txt += " %s.setName( 'Output' )\n" % self.variable["outputSample"]
630 txt += " %s = %s.buildImplementation( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"])
631 txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedDist"])
632 txt += " #Show( %s )\n" % self.variable["kernelSmoothedGraph"]
633 txt += " %s = '%s'\n" % (self.variable["kernelSmoothedPDFDrawing"], self.DictMCVal[ 'KernelSmoothingDrawingFilename' ])
634 txt += " %s.draw( %s )\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedPDFDrawing"])
635 txt += " ViewImage( %s.getBitmap() )\n" % self.variable["kernelSmoothedGraph"]
636 txt += " print 'bitmap =', %s.getBitmap()\n" % self.variable["kernelSmoothedGraph"]
637 txt += " print 'postscript =', %s.getPostscript()\n" % self.variable["kernelSmoothedGraph"]
642 def ThresholdExceedence (self, subDict):
644 Produit le fichier study correspondant a une analyse de depassement de seuil
647 txt += "# Etude 'Threshold Exceedence'\n"
649 txt += self.RandomGenerator()
651 txt += self.InputDistribution()
652 txt += self.InputRandomVector()
653 txt += self.OutputRandomVector()
657 if ( self.DictMCVal.has_key( 'Method' ) ):
658 Methode = self.DictMCVal[ 'Method' ]
661 if ( subDict.has_key( Methode ) ):
662 Traitement = subDict[ Methode ]
664 if ( Traitement is not None ):
665 txt += apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) )
670 def Simulation (self, subDict):
672 Methodes de simulation
675 if ( self.DictMCVal.has_key( 'Algorithm' ) ):
676 Algorithme = self.DictMCVal[ 'Algorithm' ]
679 if ( subDict.has_key( Algorithme ) ):
680 Traitement = subDict[ Algorithme ]
682 if ( Traitement is not None ):
683 txt = apply( STDGenerateur.__dict__[ Traitement ], (self,) )
685 maxOuterSampling = None
686 if ( self.DictMCVal.has_key( 'MaximumOuterSampling' ) ):
687 maxOuterSampling = self.DictMCVal[ 'MaximumOuterSampling' ]
688 txt += "%s.setMaximumOuterSampling( %s )\n" % (self.variable["myAlgo"], maxOuterSampling)
691 if ( self.DictMCVal.has_key( 'BlockSize' ) ):
692 blockSize = self.DictMCVal[ 'BlockSize' ]
693 txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize)
695 maxCoefficientOfVariation = None
696 if ( self.DictMCVal.has_key( 'MaximumCoefficientOfVariation' ) ):
697 maxCoefficientOfVariation = self.DictMCVal[ 'MaximumCoefficientOfVariation' ]
698 txt += "%s.setMaximumCoefficientOfVariation( %s )\n" % (self.variable["myAlgo"], maxCoefficientOfVariation)
700 txt += "%s.run()\n" % self.variable["myAlgo"]
702 txt += "# Resultats de la simulation\n"
703 txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"])
706 if ( self.DictMCVal.has_key( 'Probability' ) ):
707 if ( self.DictMCVal[ 'Probability' ] == "yes" ):
708 txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"])
709 txt += "print '%s =', %s\n" % ("probability", self.variable["probability"])
712 if ( self.DictMCVal.has_key( 'StandardDeviation' ) ):
713 if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ):
714 txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"])
715 txt += "print '%s =', %s\n" % ("standard Deviation", self.variable["standardDeviation"])
718 if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ):
719 if ( ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) and ( self.DictMCVal[ 'Probability' ] == "yes" ) ):
720 level = self.DictMCVal[ 'Level' ]
721 txt += "%s = %s.getConfidenceLength( %s )\n" % (self.variable["length"], self.variable["myResult"], level)
722 txt += "print 'confidence interval at %s = [', %s-0.5*%s, ',', %s+0.5*%s, ']'\n" % (level, self.variable["probability"], self.variable["length"], self.variable["probability"], self.variable["length"])
725 if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ):
726 if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ):
727 txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"])
728 txt += "print '%s =', %s\n" % ("coefficient of Variation", self.variable["coefficientOfVariation"])
731 if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ):
732 if ( self.DictMCVal[ 'SimulationsNumber' ] == "yes" ):
733 txt += "%s = %s.getOuterSampling()\n" % (self.variable["simulationNumbers"], self.variable["myResult"])
734 txt += "print '%s =', %s\n" % ("simulation Numbers", self.variable["simulationNumbers"])
737 if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) and self.DictMCVal.has_key( 'ConfidenceInterval' ) ):
738 if ( ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ) and ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) ):
739 txt += "%s = %s\n" % (self.variable["alpha"], self.DictMCVal[ 'Level' ])
740 txt += "%s = %s.drawProbabilityConvergence( %s )\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"], self.variable["alpha"])
741 txt += "#Show( %s )\n" % self.variable["convergenceGraph"]
742 txt += "%s = '%s'\n" % (self.variable["convergenceDrawing"], self.DictMCVal[ 'ConvergenceDrawingFilename' ])
743 txt += "%s.draw( %s )\n" % (self.variable["convergenceGraph"], self.variable["convergenceDrawing"])
744 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["convergenceGraph"]
749 def Analytical (self, subDict):
755 OptimizationAlgo = None
756 if ( self.DictMCVal.has_key( 'OptimizationAlgorithm' ) ):
757 OptimizationAlgo = self.DictMCVal[ 'OptimizationAlgorithm' ]
760 if ( subDict.has_key( OptimizationAlgo ) ):
761 Traitement = subDict[ OptimizationAlgo ]
763 if ( Traitement is not None ):
764 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
766 txt += self.OptimizerSettings()
767 txt += self.PhysicalStartingPoint()
770 if ( self.DictMCVal.has_key( 'Approximation' ) ):
771 Approximation = self.DictMCVal[ 'Approximation' ]
774 if ( subDict.has_key( Approximation ) ):
775 Traitement = subDict[ Approximation ]
777 if ( Traitement is not None ):
778 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
780 txt += self.RunAlgorithm()
781 txt += self.AnalyticalResult()
785 def OptimizerSettings (self):
787 Parametrage de l optimiseur
791 simulationNumbers = None
792 if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ):
793 simulationNumbers = self.DictMCVal[ 'MaximumIterationsNumber' ]
794 txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], simulationNumbers)
797 if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ):
798 absoluteError = self.DictMCVal[ 'MaximumAbsoluteError' ]
799 txt += "%s.setMaximumAbsoluteError( %s )\n" % (self.variable["myOptimizer"], absoluteError)
802 if ( self.DictMCVal.has_key( 'MaximumRelativeError' ) ):
803 relativeError = self.DictMCVal[ 'MaximumRelativeError' ]
804 txt += "%s.setMaximumRelativeError( %s )\n" % (self.variable["myOptimizer"], relativeError)
807 if ( self.DictMCVal.has_key( 'MaximumResidualError' ) ):
808 residualError = self.DictMCVal[ 'MaximumResidualError' ]
809 txt += "%s.setMaximumResidualError( %s )\n" % (self.variable["myOptimizer"], residualError)
811 constraintError = None
812 if ( self.DictMCVal.has_key( 'MaximumConstraintError' ) ):
813 constraintError = self.DictMCVal[ 'MaximumConstraintError' ]
814 txt += "%s.setMaximumConstraintError( %s )\n" % (self.variable["myOptimizer"], constraintError)
820 def PhysicalStartingPoint (self):
822 Point physique de depart
824 txt = "# Point physique de depart\n"
826 if ( self.DictMCVal.has_key( 'PhysicalStartingPoint' ) ):
827 point = self.DictMCVal[ 'PhysicalStartingPoint' ]
828 dimension = len( point )
829 txt += "%s = NumericalPoint( %d )\n" % (self.variable["startingPoint"], dimension)
830 for i in range( dimension ):
831 txt += "%s[ %d ] = %g\n" % (self.variable["startingPoint"], i, point[i])
833 txt += "%s = %s.getMean()\n" % (self.variable["startingPoint"], self.variable["inputRandomVector"])
839 def AnalyticalResult (self):
841 Resultat des methodes analytiques
843 txt = "# Resultat des methodes analytiques\n"
844 txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"])
846 if ( self.DictMCVal.has_key( 'Probability' ) ):
847 if ( self.DictMCVal[ 'Probability' ] == "yes" ):
848 txt += "%s = %s.getEventProbability()\n" % (self.variable["probability"], self.variable["myResult"])
849 txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"])
852 if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ):
853 if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ):
854 txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"])
855 txt += "print '%s =', %s\n" % ("hasofer Reliability Index", self.variable["hasoferReliabilityIndex"])
858 if ( self.DictMCVal.has_key( 'DesignPoint' ) ):
859 if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ):
860 txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"])
861 txt += "print '%s =', %s\n" % ("standard Space Design Point", self.variable["standardSpaceDesignPoint"])
862 txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"])
863 txt += "print '%s =', %s\n" % ("physical Space Design Point", self.variable["physicalSpaceDesignPoint"])
866 if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ):
867 if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ):
868 txt += "print 'Importance Factors:'\n"
869 txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"])
870 txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"]
871 txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"])
873 txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"])
874 txt += "#Show( %s )\n" % self.variable["importanceFactorsGraph"]
875 txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ])
876 txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"])
877 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"]
878 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"]
879 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"]
882 if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivity' ) ):
883 if ( self.DictMCVal[ 'FORMEventProbabilitySensitivity' ] == "yes" ):
884 txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"])
885 txt += "print 'FORM Event Probability Sensitivity:'\n"
886 txt += "for i in range( %s ):\n" % self.variable["n"]
887 txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"]
888 txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["eventProbabilitySensitivity"]
889 txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"])
891 txt += "%s = %s.drawEventProbabilitySensitivity()[0]\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"])
892 txt += "#Show( %s )\n" % self.variable["eventProbabilitySensitivityGraph"]
893 txt += "%s = '%s'\n" % (self.variable["eventProbabilitySensitivityDrawing"], self.DictMCVal[ 'FORMEventProbabilitySensitivityDrawingFilename' ])
894 txt += "%s.draw( %s )\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["eventProbabilitySensitivityDrawing"])
895 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["eventProbabilitySensitivityGraph"]
896 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["eventProbabilitySensitivityGraph"]
897 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["eventProbabilitySensitivityGraph"]
900 if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivity' ) ):
901 if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivity' ] == "yes" ):
902 txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"])
903 txt += "print 'Hasofer Reliability Index Sensitivity:'\n"
904 txt += "for i in range( %s ):\n" % self.variable["n"]
905 txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"]
906 txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["hasoferReliabilityIndexSensitivity"]
907 txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"])
909 txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()[0]\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"])
910 txt += "#Show( %s )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
911 txt += "%s = '%s'\n" % (self.variable["hasoferReliabilityIndexSensitivityDrawing"], self.DictMCVal[ 'HasoferReliabilityIndexSensitivityDrawingFilename' ])
912 txt += "%s.draw( %s )\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["hasoferReliabilityIndexSensitivityDrawing"])
913 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
914 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
915 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
918 if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ):
919 if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ):
920 txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"])
921 txt += "print '%s =', %s\n" % ("Tvedt Approximation", self.variable["tvedtApproximation"])
924 if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ):
925 if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ):
926 txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"])
927 txt += "print '%s =', %s\n" % ("HohenBichler Approximation", self.variable["tvedtApproximation"])
930 if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ):
931 if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ):
932 txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"])
933 txt += "print '%s =', %s\n" % ("Breitung Approximation", self.variable["breitungApproximation"])
939 def RandomGenerator (self):
946 if ( self.DictMCVal.has_key( 'RandomGeneratorSeed' ) ):
947 seed = self.DictMCVal[ 'RandomGeneratorSeed' ]
948 txt += "# Initialise le generateur aleatoire\n"
949 txt += "RandomGenerator.SetSeed( %s )\n" % seed
956 Definition de l evenement de defaillance
959 if ( self.DictMCVal.has_key( 'ComparisonOperator' ) ):
960 operator = self.DictMCVal[ 'ComparisonOperator' ]
963 if ( self.DictMCVal.has_key( 'Threshold' ) ):
964 threshold = self.DictMCVal[ 'Threshold' ]
966 txt = "# Evenement de defaillance\n"
967 txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold)
968 txt += "%s.setName( '%s' )\n" % (self.variable["myEvent"], "myEvent")
972 def MonteCarlo (self):
974 Methode de MonteCarlo
976 txt = "# Simulation par MonteCarlo\n"
977 txt += "%s = MonteCarlo( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"])
986 txt = "# Simulation par LHS\n"
987 txt += "%s = LHS( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"])
992 def ImportanceSampling (self):
994 Methode de tirage d importance
997 if ( self.DictMCVal.has_key( 'MeanVector' ) ):
998 meanVector = self.DictMCVal[ 'MeanVector' ]
999 dimension = len( meanVector )
1001 txt = "# Simulation par Tirage d'importance\n"
1002 txt += "# Densite d'importance\n"
1003 txt += "%s = NumericalPoint( %s )\n" % (self.variable["meanVector"], self.variable["n"])
1004 for i in range(dimension):
1005 txt += "%s[%d] = %g\n" % (self.variable["meanVector"], i, meanVector[i])
1007 txt += "%s = Normal( %s, CovarianceMatrix( IdentityMatrix( %s ) ) )\n" % (self.variable["importanceDensity"], self.variable["meanVector"], self.variable["n"])
1008 txt += "%s = ImportanceSampling( %s, Distribution( %s ) )\n" % (self.variable["myAlgo"], self.variable["myEvent"], self.variable["importanceDensity"])
1017 txt = "# Algorithme FORM\n"
1018 txt += "%s = FORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"])
1027 txt = "# Algorithme SORM\n"
1028 txt += "%s = SORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"])
1033 def RunAlgorithm (self):
1038 if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ):
1039 if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ):
1040 txt += "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"])
1041 txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"])
1042 txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"])
1045 txt += "# Perform the computation\n"
1046 txt += "%s.run()\n" % self.variable["myAlgo"]
1050 if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ):
1051 if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ):
1052 txt += "%s = %s.getEvaluationCallsNumber() - %s\n" % (self.variable["modelEvaluationCalls"], self.variable["model"], self.variable["modelEvaluationCalls"])
1053 txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"])
1054 txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"])
1056 txt += "print '%s =', %s\n" % ("model Evaluation Calls", self.variable["modelEvaluationCalls"])
1057 txt += "print '%s =', %s\n" % ("model Gradient Calls", self.variable["modelGradientCalls"])
1058 txt += "print '%s =', %s\n" % ("model Hessian Calls", self.variable["modelHessianCalls"])
1067 txt = "# Optimisation par Cobyla\n"
1068 txt += "%s = Cobyla()\n" % self.variable["myOptimizer"]
1069 txt += "#%s = CobylaSpecificParameters()\n" % self.variable["specificParameters"]
1070 txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"])
1075 def AbdoRackwitz (self):
1077 Methode AbdoRackwitz
1079 txt = "# Optimisation par AbdoRackwitz\n"
1080 txt += "%s = AbdoRackwitz()\n" % self.variable["myOptimizer"]
1081 txt += "#%s = AbdoRackwitzSpecificParameters()\n" % self.variable["specificParameters"]
1082 txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"])
1086 def Beta (self, loi):
1088 Definition de la loi Beta
1092 "MuSigma" : "Beta.MUSIGMA",
1094 if loi[ 'Settings' ] == 'RT' :
1099 arg2 = loi[ 'Sigma' ]
1103 txt = "Beta( %g, %g, %g, %g, %s )" % (arg1, arg2, arg3, arg4, settings[ loi[ 'Settings' ] ])
1106 def Exponential (self, loi):
1108 Definition de la loi Exponential
1110 arg1 = loi[ 'Lambda' ]
1111 arg2 = loi[ 'Gamma' ]
1112 txt = "Exponential( %g, %g )" % (arg1, arg2)
1115 def Gamma (self, loi):
1117 Definition de la loi Gamma
1120 "KLambda" : "Gamma.KLAMBDA",
1121 "MuSigma" : "Gamma.MUSIGMA",
1123 if loi[ 'Settings' ] == 'KLambda' :
1125 arg2 = loi[ 'Lambda' ]
1128 arg2 = loi[ 'Sigma' ]
1130 arg3 = loi[ 'Gamma' ]
1131 txt = "Gamma( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1134 def Geometric (self, loi):
1136 Definition de la loi Geometric
1138 txt = "Geometric( %g )" % loi[ 'P' ]
1141 def Gumbel (self, loi):
1143 Definition de la loi Gumbel
1146 "AlphaBeta" : "Gumbel.ALPHABETA",
1147 "MuSigma" : "Gumbel.MUSIGMA",
1149 if loi[ 'Settings' ] == 'AlphaBeta' :
1150 arg1 = loi[ 'Alpha' ]
1151 arg2 = loi[ 'Beta' ]
1154 arg2 = loi[ 'Sigma' ]
1156 txt = "Gumbel( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ])
1159 def Histogram (self, loi):
1161 Definition de la loi Histogram
1163 arg1 = loi[ 'First' ]
1164 arg2 = loi[ 'Values' ]
1165 txt = "Histogram( %g, %s )" % (arg1, arg2)
1168 def Laplace (self, loi):
1170 Definition de la loi Laplace
1172 arg1 = loi[ 'Lambda' ]
1174 txt = "Laplace( %g, %g )" % (arg1, arg2)
1177 def Logistic (self, loi):
1179 Definition de la loi Logistic
1181 arg1 = loi[ 'Alpha' ]
1182 arg2 = loi[ 'Beta' ]
1183 txt = "Logistic( %g, %g )" % (arg1, arg2)
1186 def LogNormal (self, loi):
1188 Definition de la loi LogNormal
1191 "MuSigmaLog" : "LogNormal.MUSIGMA_LOG",
1192 "MuSigma" : "LogNormal.MUSIGMA",
1193 "MuSigmaOverMu" : "LogNormal.MU_SIGMAOVERMU",
1195 if loi[ 'Settings' ] == 'MuSigmaLog' :
1196 arg1 = loi[ 'MuLog' ]
1197 arg2 = loi[ 'SigmaLog' ]
1198 elif loi[ 'Settings' ] == 'MuSigmaOverMu' :
1200 arg2 = loi[ 'SigmaOverMu' ]
1203 arg2 = loi[ 'Sigma' ]
1205 arg3 = loi[ 'Gamma' ]
1206 txt = "LogNormal( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1209 def MultiNomial (self, loi):
1211 Definition de la loi MultiNomial
1213 arg1 = loi[ 'Values' ]
1215 txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2)
1218 def NonCentralStudent (self, loi):
1220 Definition de la loi NonCentralStudent
1223 arg2 = loi[ 'Delta' ]
1224 arg3 = loi[ 'Gamma' ]
1225 txt = "NonCentralStudent( %g, %g )" % (arg1, arg2, arg3)
1228 def Normal (self, loi):
1230 Definition de la loi Normal
1233 arg2 = loi[ 'Sigma' ]
1234 txt = "Normal( %g, %g )" % (arg1, arg2)
1237 def TruncatedNormal (self, loi):
1239 Definition de la loi TruncatedNormal
1242 arg2 = loi[ 'SigmaN' ]
1245 txt = "TruncatedNormal( %g, %g, %g, %g )" % (arg1, arg2, arg3, arg4)
1248 def Poisson (self, loi):
1250 Definition de la loi Poisson
1252 txt = "Poisson( %g )" % loi[ 'Lambda' ]
1255 def Rayleigh (self, loi):
1257 Definition de la loi Rayleigh
1259 arg1 = loi[ 'Sigma' ]
1260 arg2 = loi[ 'Gamma' ]
1261 txt = "Rayleigh( %g, %g )" % (arg1, arg2)
1264 def Student (self, loi):
1266 Definition de la loi Student
1270 arg3 = loi[ 'Sigma' ]
1271 txt = "Student( %g, %g, %g )" % (arg1, arg2, arg3)
1274 def Triangular (self, loi):
1276 Definition de la loi Triangular
1281 txt = "Triangular( %g, %g, %g )" % (arg1, arg2, arg3)
1284 def Uniform (self, loi):
1286 Definition de la loi Uniform
1290 txt = "Uniform( %g, %g )" % (arg1, arg2)
1293 def UserDefined (self, loi):
1295 Definition de la loi UserDefined
1297 txt = "** UserDefined not defined yet **"
1300 def Weibull (self, loi):
1302 Definition de la loi Weibull
1305 "AlphaBeta" : "Weibull.ALPHABETA",
1306 "MuSigma" : "Weibull.MUSIGMA",
1308 if loi[ 'Settings' ] == 'AlphaBeta' :
1309 arg1 = loi[ 'Alpha' ]
1310 arg2 = loi[ 'Beta' ]
1313 arg2 = loi[ 'Sigma' ]
1315 arg3 = loi[ 'Gamma' ]
1316 txt = "Weibull( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1321 def GraphiquePDF (self, loi, fichier):
1323 Produit une image PNG representant la PDF de la loi
1325 txt = headerSTD % self.OpenTURNS_path
1326 txt += "dist = %s\n" % apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) )
1327 txt += "graph = dist.drawPDF()\n"
1328 txt += "graph.draw( '%s' )\n" % fichier