1 #@ AJOUT OpenturnsSolver Macro
2 # -*- coding: iso-8859-1 -*-
6 Ce module contient le generateur Etude pour Openturns
13 defaultSTD = """#! /usr/bin/env python
15 class StudyFileGenerationError:
16 def __init__ (self, st):
19 return "'%s'" % self.st
21 raise StudyFileGenerationError, "The study file was not generated. Check analysis type."
24 headerSTD = """#! /usr/bin/env python
26 # Chargement du module systeme
30 # Chargement du module math
33 # Chargement du module Open TURNS
34 from openturns import *
41 from openturns.viewer import ViewImage,StopViewer,WaitForViewer
46 # Flush des messages en attente
49 # Terminaison du fichier
53 #=============================================
54 # La classe de creation du fichier STD
55 #=============================================
60 Generation du fichier python
62 def __init__ (self, appli, DictMCVal, ListeVariablesIn, ListeVariablesOut, DictLois ) :
63 self.DictMCVal = DictMCVal
64 self.ListeVariablesIn = ListeVariablesIn
65 self.ListeVariablesOut = ListeVariablesOut
66 self.DictLois = DictLois
67 #print "DictMCVal=", DictMCVal
68 print "ListeVariablesIn=", ListeVariablesIn
69 print "ListeVariablesOut=", ListeVariablesOut
70 #print "DictLois=", DictLois
71 self.texteSTD = defaultSTD
72 self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path
74 # Ce dictionnaire fait la correspondance entre le mot lu dans le dictionnaire des mots-clefs et la methode a appeler
78 { "Experiment Plane" : "ExperimentPlane",
79 "Random Sampling" : "MinMaxRandomSampling",
82 "Central Uncertainty" :
83 ( "CentralUncertainty",
84 { "Taylor Variance Decomposition" : "TaylorVarianceDecomposition",
85 "Random Sampling" : "CentralUncertaintyRandomSampling",
88 "Threshold Exceedence" :
89 ( "ThresholdExceedence",
90 { "Simulation" : "Simulation",
91 "FORM_SORM" : "Analytical",
92 "MonteCarlo" : "MonteCarlo",
94 "ImportanceSampling" : "ImportanceSampling",
95 "FirstOrder" : "FORM",
96 "SecondOrder" : "SORM",
98 "AbdoRackwitz" : "AbdoRackwitz",
103 # Ce dictionnaire liste le nom des variables utilisees dans le script
104 # La clef est le nom attendu par les methodes, la valeur est le nom produit dans le fichier de sortie
105 # Le fait de passer par un dictionnaire permet de controler que les variables existent et sont correctement nommees
106 # meme si clef == valeur
110 "wrapper" : "wrapper",
111 "wrapperdata" : "wrapperdata",
112 "frameworkdata" : "frameworkdata",
113 "framework" : "framework",
114 "studyid" : "studyid",
115 "studycase" : "studycase",
116 "componentname" : "componentname",
118 "scaledVector" : "scaledVector",
119 "translationVector" : "translationVector",
121 "myCenteredReductedGrid" : "myCenteredReductedGrid",
122 "myExperimentPlane" : "myExperimentPlane",
123 "inputSample" : "inputSample",
124 "outputSample" : "outputSample",
125 "minValue" : 'results["minValue"]',
126 "maxValue" : 'results["maxValue"]',
129 "distribution" : "distribution",
130 "marginal" : "marginal",
131 "collection" : "collection",
133 "correlation" : "correlation",
136 "description" : "description",
137 "inputRandomVector" : "inputRandomVector",
138 "outputRandomVector" : "outputRandomVector",
139 "myQuadraticCumul" : "myQuadraticCumul",
140 "meanFirstOrder" : 'results["meanFirstOrder"]',
141 "meanSecondOrder" : 'results["meanSecondOrder"]',
142 "standardDeviationFirstOrder" : 'results["standardDeviationFirstOrder"]',
143 "importanceFactors" : 'results["importanceFactors"]',
144 "importanceFactorsGraph" : "importanceFactorsGraph",
145 "importanceFactorsDrawing" : "importanceFactorsDrawing",
146 "empiricalMean" : 'results["empiricalMean"]',
147 "empiricalStandardDeviation" : 'results["empiricalStandardDeviation"]',
148 "empiricalQuantile" : 'results["empiricalQuantile"]',
151 "PCCcoefficient" : 'results["PCCcoefficient"]',
152 "PRCCcoefficient" : 'results["PRCCcoefficient"]',
153 "SRCcoefficient" : 'results["SRCcoefficient"]',
154 "SRRCcoefficient" : 'results["SRRCcoefficient"]',
156 "kernelSmoothedDist" : "kernelSmoothedDist",
157 "kernelSmoothedPDFDrawing" : "kernelSmoothedPDFDrawing",
158 "kernelSmoothedGraph" : "kernelSmoothedGraph",
159 "meanVector" : "meanVector",
160 "importanceDensity" : "importanceDensity",
161 "myEvent" : "myEvent",
163 "myResult" : "myResult",
164 "probability" : 'results["probability"]',
165 "standardDeviation" : 'results["standardDeviation"]',
168 "coefficientOfVariation" : 'results["coefficientOfVariation"]',
169 "convergenceGraph" : "convergenceGraph",
170 "convergenceDrawing" : "convergenceDrawing",
171 "simulationNumbers" : 'results["simulationNumbers"]',
172 "myOptimizer" : "myOptimizer",
173 "specificParameters" : "specificParameters",
174 "startingPoint" : "startingPoint",
175 "hasoferReliabilityIndex" : 'results["hasoferReliabilityIndex"]',
176 "standardSpaceDesignPoint" : 'results["standardSpaceDesignPoint"]',
177 "physicalSpaceDesignPoint" : 'results["physicalSpaceDesignPoint"]',
178 "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]',
179 "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]',
180 "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph",
181 "eventProbabilitySensitivityDrawing" : "eventProbabilitySensitivityDrawing",
182 "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph",
183 "hasoferReliabilityIndexSensitivityDrawing" : "hasoferReliabilityIndexSensitivityDrawing",
184 "modelEvaluationCalls" : 'results["modelEvaluationCalls"]',
185 "modelGradientCalls" : 'results["modelGradientCalls"]',
186 "modelHessianCalls" : 'results["modelHessianCalls"]',
187 "tvedtApproximation" : 'results["tvedtApproximation"]',
188 "hohenBichlerApproximation" : 'results["hohenBichlerApproximation"]',
189 "breitungApproximation" : 'results["breitungApproximation"]',
192 # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque
194 "DebugMessages" : "Log.DBG",
195 "WrapperMessages" : "Log.WRAPPER",
196 "UserMessages" : "Log.USER",
197 "InfoMessages" : "Log.INFO",
198 "WarningMessages" : "Log.WARN",
199 "ErrorMessages" : "Log.ERROR",
204 Pilotage de la creation du fichier python
207 if ( self.DictMCVal.has_key( 'Type' ) ):
208 TypeAnalyse = self.DictMCVal[ 'Type' ]
212 if ( self.traitement.has_key( TypeAnalyse ) ):
213 (Traitement, subDict) = self.traitement[ TypeAnalyse ]
215 if ( Traitement is not None ):
216 self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) )
222 Imprime l entete commun a tous les fichiers
224 txt = headerSTD % self.OpenTURNS_path
226 txt += "# Definit le niveau d'affichage de la log\n"
227 txt += "%s = Log.NONE\n" % self.variable["flags"]
228 for flag in self.logFlags.keys():
229 if ( self.DictMCVal.has_key( flag ) ):
230 val = self.DictMCVal[ flag ]
234 txt += "%s = %s %s %s\n" % (self.variable["flags"], self.variable["flags"], op, self.logFlags[ flag ])
235 txt += "Log.Show( %s )\n" % self.variable["flags"]
241 Imprime le pied de page commun a tous les fichiers
245 def MinMax (self, subDict):
247 Produit le fichier study correspondant a une analyse Min/Max
253 if ( self.DictMCVal.has_key( 'Method' ) ):
254 Methode = self.DictMCVal[ 'Method' ]
257 if ( subDict.has_key( Methode ) ):
258 Traitement = subDict[ Methode ]
260 if ( Traitement is not None ):
261 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
263 txt += self.MinMaxResult()
270 Importe le modele physique
273 if ( self.DictMCVal.has_key( 'FileName' ) ):
274 name = self.DictMCVal[ 'FileName' ]
275 #fonction = name[name.rfind('/')+1:name.rfind('.xml')]
277 txt = "# Charge le modele physique\n"
278 txt = "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name)
279 txt += "%s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"])
281 txt += "# Ces lignes sont utiles pour le fonctionnement du script sous Salome\n"
282 txt += "if globals().has_key('%s'):\n" % self.variable["framework"]
283 txt += " %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"])
284 txt += " %s.studyid_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studyid"])
285 txt += " %s.studycase_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studycase"])
286 txt += " %s.componentname_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"])
287 txt += " %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"])
288 txt += " %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"])
289 txt += "# Fin des lignes pour Salome\n"
291 txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],)
292 txt += "%s = %s.getInputNumericalPointDimension()\n" % (self.variable["n"], self.variable["model"])
296 def ExperimentPlane (self):
298 Etude par plan d experience
300 txt = "# Etude par plan d'experience\n"
302 txt += self.CenteredReductedGrid()
303 txt += self.ScaledVector()
304 txt += self.TranslationVector()
305 txt += "%s = %s\n" % (self.variable["inputSample"], self.variable["myExperimentPlane"])
307 txt += "# Etude 'Min/Max'\n"
309 txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"])
313 def MinMaxRandomSampling (self):
315 Etude par echantillonage aleatoire
318 if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ):
319 size = self.DictMCVal[ 'SimulationsNumber' ]
321 txt = "# Etude par echantillonage aleatoire\n"
322 txt += self.InputDistribution()
323 txt += self.InputRandomVector()
325 txt += "# Etude 'Min/Max'\n"
327 txt += "%s = %d\n" % (self.variable["inSize"], size)
328 txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"])
329 txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"])
332 def InputDistribution (self):
334 Cree la loi jointe des variables d entree
336 txt = "# Definit la loi jointe des variables d'entree\n"
337 txt += "%s = DistributionCollection( %s )\n" % (self.variable["collection"], self.variable["n"])
338 txt += "%s = Description( %s )\n" % (self.variable["description"], self.variable["n"])
342 for variable in self.ListeVariablesIn:
343 nomVar = variable['ModelVariable'].get_name()
344 dictVariables[ nomVar ] = variable['Distribution']
347 sortedVarNames = dictVariables.keys()
348 sortedVarNames.sort()
349 for variable in sortedVarNames:
350 conceptloi = dictVariables[ variable ]
351 loi = self.DictLois[ conceptloi ]
352 if loi.has_key( 'Kind' ):
353 marginale = "%s_%d" % (self.variable["marginal"], i)
354 txt += "# Definit la loi marginale de la composante %d\n" % i
355 txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) ))
356 txt += "%s.setName( '%s' )\n" % (marginale, conceptloi.get_name())
357 txt += "%s[ %d ] = '%s'\n" % (self.variable["description"], i, variable)
358 txt += "%s[ %d ] = Distribution( %s )\n" % (self.variable["collection"], i, marginale)
364 txt += "# Definit la loi jointe\n"
365 txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"])
366 txt += "%s.setDescription( %s )\n" % (self.variable["distribution"], self.variable["description"])
372 Cree la copule de la loi jointe
374 txt = "# Definit la copule de la loi jointe\n"
376 if ( not self.DictMCVal.has_key( 'Copula' ) ):
377 self.DictMCVal[ 'Copula' ] = 'Independent'
379 if ( self.DictMCVal[ 'Copula' ] in ( 'Independent', ) ):
380 txt += "%s = IndependentCopula( %s )\n" % (self.variable["copula"], self.variable["n"])
381 elif ( self.DictMCVal[ 'Copula' ] in ( 'Normal', ) ):
382 varList = self.DictMCVal[ 'CorrelationMatrix' ][0]
383 dimension = len(varList)
384 txt += "%s = {}\n" % self.variable["correlation"]
385 for i in range( dimension ):
386 txt += "%s['%s'] = {}\n" % (self.variable["correlation"], varList[i])
387 for j in range ( dimension ):
388 txt += "%s['%s']['%s'] = %g\n" % (self.variable["correlation"], varList[i], varList[j], self.DictMCVal[ 'CorrelationMatrix' ][i+1][j])
389 txt += "%s = getCorrelationMatrixFromMap( %s.getVariableList(), %s )\n" % (self.variable["R"], self.variable["wrapperdata"], self.variable["correlation"])
390 txt += "%s = NormalCopula( %s )\n" % (self.variable["copula"], self.variable["R"])
395 def InputRandomVector (self):
397 Cree le vector aleatoire d entree
399 txt = "# Definit le vecteur aleatoire d'entree\n"
400 txt += "%s = RandomVector( %s )\n" % (self.variable["inputRandomVector"], self.variable["distribution"])
404 def OutputRandomVector (self):
406 Cree le vector aleatoire de sortie
409 for variable in self.ListeVariablesOut:
410 nomVar = variable['ModelVariable'].get_name()
412 txt = "# Definit le vecteur aleatoire de sortie\n"
413 txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"])
414 txt += "%s.setName( '%s' )\n" % (self.variable["outputRandomVector"], nomVar)
418 def ScaledVector (self):
420 Definit les coefficients multiplicateurs par composante du vecteur
423 if ( self.DictMCVal.has_key( 'UnitsPerDimension' ) ):
424 unitsPerDimension = self.DictMCVal[ 'UnitsPerDimension' ]
425 dimension = len( unitsPerDimension )
427 txt = "# Definit les facteurs d'echelle dans chaque direction\n"
428 txt += "%s = NumericalPoint( %s )\n" % (self.variable["scaledVector"], self.variable["n"])
429 for i in range(dimension):
430 txt += "%s[%d] = %g\n" % (self.variable["scaledVector"], i, unitsPerDimension[i])
431 txt += "%s.scale( %s )\n" % (self.variable["myExperimentPlane"], self.variable["scaledVector"])
435 def TranslationVector (self):
437 Definit le vecteur de translation
440 if ( self.DictMCVal.has_key( 'Center' ) ):
441 center = self.DictMCVal[ 'Center' ]
442 dimension = len( center )
444 txt = "# Definit le vecteur de translation\n"
445 txt += "%s = NumericalPoint( %s )\n" % (self.variable["translationVector"], self.variable["n"])
446 for i in range(dimension):
447 txt += "%s[%d] = %g\n" % (self.variable["translationVector"], i, center[i])
448 txt += "%s.translate( %s )\n" % (self.variable["myExperimentPlane"], self.variable["translationVector"])
454 Definit les niveaux du plan d experience
457 if ( self.DictMCVal.has_key( 'Levels' ) ):
458 levels = self.DictMCVal[ 'Levels' ]
459 dimension = len( levels )
461 txt = "# Definit les niveaux de la structure de grille\n"
462 txt += "%s = NumericalPoint( %d )\n" % (self.variable["levels"], dimension)
463 for i in range(dimension):
464 txt += "%s[%d] = %g\n" % (self.variable["levels"], i, levels[i])
468 def CenteredReductedGrid (self):
470 Definit la grille reduite du plan d experience
473 if ( self.DictMCVal.has_key( 'ExperimentPlane' ) ):
474 plane = self.DictMCVal[ 'ExperimentPlane' ]
476 txt = "# Cree le plan d'experience centre reduit\n"
477 txt += "%s = %s(%s, %s)\n" % (self.variable["myCenteredReductedGrid"], plane, self.variable["n"], self.variable["levels"])
478 txt += "%s = %s.generate()\n" % (self.variable["myExperimentPlane"], self.variable["myCenteredReductedGrid"])
482 def MinMaxResult (self):
484 Produit les resultats de l etude
486 txt = "# Resultats\n"
487 txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"])
488 txt += "print '%s = ', %s\n" % ("minValue", self.variable["minValue"])
490 txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"])
491 txt += "print '%s = ', %s\n" % ("maxValue", self.variable["maxValue"])
495 def CentralUncertainty (self, subDict):
497 Produit le fichier study correspondant a une analyse d incertitude en valeur centrale
501 txt += self.InputDistribution()
502 txt += self.InputRandomVector()
503 txt += self.OutputRandomVector()
506 if ( self.DictMCVal.has_key( 'Method' ) ):
507 Methode = self.DictMCVal[ 'Method' ]
510 if ( subDict.has_key( Methode ) ):
511 Traitement = subDict[ Methode ]
513 if ( Traitement is not None ):
514 txt += "# Etude 'Central Uncertainty'\n"
515 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
521 def TaylorVarianceDecomposition (self):
523 Etude par decomposition de Taylor
525 txt = "# Cumul quadratique (decomposition de Taylor)\n"
526 txt += "%s = QuadraticCumul( %s )\n" % (self.variable["myQuadraticCumul"], self.variable["outputRandomVector"])
528 txt += "# Resultats\n"
530 if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ):
531 if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ):
532 txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"])
533 txt += "print '%s = ', %s\n" % ("mean First Order", self.variable["meanFirstOrder"])
536 if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ):
537 if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ):
538 txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"])
539 txt += "print '%s = ', %s\n" % ("mean Second Order", self.variable["meanSecondOrder"])
542 if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ):
543 if ( self.DictMCVal[ 'StandardDeviationFirstOrder' ] == "yes" ):
544 txt += "%s = %s.getCovariance()\n" % (self.variable["standardDeviationFirstOrder"], self.variable["myQuadraticCumul"])
545 txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"]
546 txt += "for i in range( dim ):\n"
547 txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"])
548 txt += " print '%s = ', %s[ i, i ]\n" % ("standard Deviation First Order", self.variable["standardDeviationFirstOrder"])
551 if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ):
552 if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ):
553 txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"])
554 txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"]
555 txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"])
557 txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"])
558 txt += "#Show( %s )\n" % self.variable["importanceFactorsGraph"]
559 txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ])
560 txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"])
561 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"]
562 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"]
563 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"]
569 def CentralUncertaintyRandomSampling (self):
571 Etude par echantillonage aleatoire
574 if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ):
575 size = self.DictMCVal[ 'SimulationsNumber' ]
577 txt = "# Echantillonnage aleatoire de la variable de sortie\n"
578 txt += "%s = %d\n" % (self.variable["inSize"], size)
579 txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"])
580 txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"])
583 if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ):
584 if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ):
585 txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"])
586 txt += "print '%s =', %s[0]\n" % ("empirical Mean", self.variable["empiricalMean"])
589 if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ):
590 if ( self.DictMCVal[ 'EmpiricalStandardDeviation' ] == "yes" ):
591 txt += "%s = %s.computeCovariance()\n" % (self.variable["empiricalStandardDeviation"], self.variable["outputSample"])
592 txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"]
593 txt += "for i in range( dim ):\n"
594 txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"])
595 txt += " print '%s = ', %s[ i, i ]\n" % ("empirical Standard Deviation", self.variable["empiricalStandardDeviation"])
598 if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ):
599 ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ]
600 txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre)
601 txt += "print '%s ( %s ) =', %s\n" % ("empirical Quantile", ordre, self.variable["empiricalQuantile"])
604 if ( self.DictMCVal.has_key( 'CorrelationAnalysis' ) ):
605 if ( self.DictMCVal[ 'CorrelationAnalysis' ] == "yes" ):
606 txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"]
607 txt += " %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
608 txt += " print 'PCC Coefficients:'\n"
609 txt += " for i in range( %s ):\n" % self.variable["n"]
610 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PCCcoefficient"])
612 txt += " %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
613 txt += " print 'PRCC Coefficients:'\n"
614 txt += " for i in range( %s ):\n" % self.variable["n"]
615 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PRCCcoefficient"])
617 txt += " %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
618 txt += " print 'SRC Coefficients:'\n"
619 txt += " for i in range( %s ):\n" % self.variable["n"]
620 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRCcoefficient"])
622 txt += " %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
623 txt += " print 'SRRC Coefficients:'\n"
624 txt += " for i in range( %s ):\n" % self.variable["n"]
625 txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRRCcoefficient"])
628 if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ):
629 if ( self.DictMCVal[ 'KernelSmoothing' ] == "yes" ):
630 txt += "# Kernel Smoohing\n"
631 txt += "%s = KernelSmoothing()\n" % self.variable["kernel"]
632 txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"]
633 txt += " %s.setName( 'Output' )\n" % self.variable["outputSample"]
634 txt += " %s = %s.buildImplementation( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"])
635 txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedDist"])
636 txt += " #Show( %s )\n" % self.variable["kernelSmoothedGraph"]
637 txt += " %s = '%s'\n" % (self.variable["kernelSmoothedPDFDrawing"], self.DictMCVal[ 'KernelSmoothingDrawingFilename' ])
638 txt += " %s.draw( %s )\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedPDFDrawing"])
639 txt += " ViewImage( %s.getBitmap() )\n" % self.variable["kernelSmoothedGraph"]
640 txt += " print 'bitmap =', %s.getBitmap()\n" % self.variable["kernelSmoothedGraph"]
641 txt += " print 'postscript =', %s.getPostscript()\n" % self.variable["kernelSmoothedGraph"]
646 def ThresholdExceedence (self, subDict):
648 Produit le fichier study correspondant a une analyse de depassement de seuil
651 txt += "# Etude 'Threshold Exceedence'\n"
653 txt += self.RandomGenerator()
655 txt += self.InputDistribution()
656 txt += self.InputRandomVector()
657 txt += self.OutputRandomVector()
661 if ( self.DictMCVal.has_key( 'Method' ) ):
662 Methode = self.DictMCVal[ 'Method' ]
665 if ( subDict.has_key( Methode ) ):
666 Traitement = subDict[ Methode ]
668 if ( Traitement is not None ):
669 txt += apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) )
674 def Simulation (self, subDict):
676 Methodes de simulation
679 if ( self.DictMCVal.has_key( 'Algorithm' ) ):
680 Algorithme = self.DictMCVal[ 'Algorithm' ]
683 if ( subDict.has_key( Algorithme ) ):
684 Traitement = subDict[ Algorithme ]
686 if ( Traitement is not None ):
687 txt = apply( STDGenerateur.__dict__[ Traitement ], (self,) )
689 maxOuterSampling = None
690 if ( self.DictMCVal.has_key( 'MaximumOuterSampling' ) ):
691 maxOuterSampling = self.DictMCVal[ 'MaximumOuterSampling' ]
692 txt += "%s.setMaximumOuterSampling( %s )\n" % (self.variable["myAlgo"], maxOuterSampling)
695 if ( self.DictMCVal.has_key( 'BlockSize' ) ):
696 blockSize = self.DictMCVal[ 'BlockSize' ]
697 txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize)
699 maxCoefficientOfVariation = None
700 if ( self.DictMCVal.has_key( 'MaximumCoefficientOfVariation' ) ):
701 maxCoefficientOfVariation = self.DictMCVal[ 'MaximumCoefficientOfVariation' ]
702 txt += "%s.setMaximumCoefficientOfVariation( %s )\n" % (self.variable["myAlgo"], maxCoefficientOfVariation)
704 txt += "%s.run()\n" % self.variable["myAlgo"]
706 txt += "# Resultats de la simulation\n"
707 txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"])
710 if ( self.DictMCVal.has_key( 'Probability' ) ):
711 if ( self.DictMCVal[ 'Probability' ] == "yes" ):
712 txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"])
713 txt += "print '%s =', %s\n" % ("probability", self.variable["probability"])
716 if ( self.DictMCVal.has_key( 'StandardDeviation' ) ):
717 if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ):
718 txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"])
719 txt += "print '%s =', %s\n" % ("standard Deviation", self.variable["standardDeviation"])
722 if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ):
723 if ( ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) and ( self.DictMCVal[ 'Probability' ] == "yes" ) ):
724 level = self.DictMCVal[ 'Level' ]
725 txt += "%s = %s.getConfidenceLength( %s )\n" % (self.variable["length"], self.variable["myResult"], level)
726 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"])
729 if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ):
730 if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ):
731 txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"])
732 txt += "print '%s =', %s\n" % ("coefficient of Variation", self.variable["coefficientOfVariation"])
735 if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ):
736 if ( self.DictMCVal[ 'SimulationsNumber' ] == "yes" ):
737 txt += "%s = %s.getOuterSampling()\n" % (self.variable["simulationNumbers"], self.variable["myResult"])
738 txt += "print '%s =', %s\n" % ("simulation Numbers", self.variable["simulationNumbers"])
741 if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) and self.DictMCVal.has_key( 'ConfidenceInterval' ) ):
742 if ( ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ) and ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) ):
743 txt += "%s = %s\n" % (self.variable["alpha"], self.DictMCVal[ 'Level' ])
744 txt += "%s = %s.drawProbabilityConvergence( %s )\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"], self.variable["alpha"])
745 txt += "#Show( %s )\n" % self.variable["convergenceGraph"]
746 txt += "%s = '%s'\n" % (self.variable["convergenceDrawing"], self.DictMCVal[ 'ConvergenceDrawingFilename' ])
747 txt += "%s.draw( %s )\n" % (self.variable["convergenceGraph"], self.variable["convergenceDrawing"])
748 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["convergenceGraph"]
753 def Analytical (self, subDict):
759 OptimizationAlgo = None
760 if ( self.DictMCVal.has_key( 'OptimizationAlgorithm' ) ):
761 OptimizationAlgo = self.DictMCVal[ 'OptimizationAlgorithm' ]
764 if ( subDict.has_key( OptimizationAlgo ) ):
765 Traitement = subDict[ OptimizationAlgo ]
767 if ( Traitement is not None ):
768 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
770 txt += self.OptimizerSettings()
771 txt += self.PhysicalStartingPoint()
774 if ( self.DictMCVal.has_key( 'Approximation' ) ):
775 Approximation = self.DictMCVal[ 'Approximation' ]
778 if ( subDict.has_key( Approximation ) ):
779 Traitement = subDict[ Approximation ]
781 if ( Traitement is not None ):
782 txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
784 txt += self.RunAlgorithm()
785 txt += self.AnalyticalResult()
789 def OptimizerSettings (self):
791 Parametrage de l optimiseur
795 simulationNumbers = None
796 if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ):
797 simulationNumbers = self.DictMCVal[ 'MaximumIterationsNumber' ]
798 txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], simulationNumbers)
801 if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ):
802 absoluteError = self.DictMCVal[ 'MaximumAbsoluteError' ]
803 txt += "%s.setMaximumAbsoluteError( %s )\n" % (self.variable["myOptimizer"], absoluteError)
806 if ( self.DictMCVal.has_key( 'MaximumRelativeError' ) ):
807 relativeError = self.DictMCVal[ 'MaximumRelativeError' ]
808 txt += "%s.setMaximumRelativeError( %s )\n" % (self.variable["myOptimizer"], relativeError)
811 if ( self.DictMCVal.has_key( 'MaximumResidualError' ) ):
812 residualError = self.DictMCVal[ 'MaximumResidualError' ]
813 txt += "%s.setMaximumResidualError( %s )\n" % (self.variable["myOptimizer"], residualError)
815 constraintError = None
816 if ( self.DictMCVal.has_key( 'MaximumConstraintError' ) ):
817 constraintError = self.DictMCVal[ 'MaximumConstraintError' ]
818 txt += "%s.setMaximumConstraintError( %s )\n" % (self.variable["myOptimizer"], constraintError)
824 def PhysicalStartingPoint (self):
826 Point physique de depart
828 txt = "# Point physique de depart\n"
830 if ( self.DictMCVal.has_key( 'PhysicalStartingPoint' ) ):
831 point = self.DictMCVal[ 'PhysicalStartingPoint' ]
832 dimension = len( point )
833 txt += "%s = NumericalPoint( %d )\n" % (self.variable["startingPoint"], dimension)
834 for i in range( dimension ):
835 txt += "%s[ %d ] = %g\n" % (self.variable["startingPoint"], i, point[i])
837 txt += "%s = %s.getMean()\n" % (self.variable["startingPoint"], self.variable["inputRandomVector"])
843 def AnalyticalResult (self):
845 Resultat des methodes analytiques
847 txt = "# Resultat des methodes analytiques\n"
848 txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"])
850 if ( self.DictMCVal.has_key( 'Probability' ) ):
851 if ( self.DictMCVal[ 'Probability' ] == "yes" ):
852 txt += "%s = %s.getEventProbability()\n" % (self.variable["probability"], self.variable["myResult"])
853 txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"])
856 if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ):
857 if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ):
858 txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"])
859 txt += "print '%s =', %s\n" % ("hasofer Reliability Index", self.variable["hasoferReliabilityIndex"])
862 if ( self.DictMCVal.has_key( 'DesignPoint' ) ):
863 if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ):
864 txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"])
865 txt += "print '%s =', %s\n" % ("standard Space Design Point", self.variable["standardSpaceDesignPoint"])
866 txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"])
867 txt += "print '%s =', %s\n" % ("physical Space Design Point", self.variable["physicalSpaceDesignPoint"])
870 if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ):
871 if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ):
872 txt += "print 'Importance Factors:'\n"
873 txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"])
874 txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"]
875 txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"])
877 txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"])
878 txt += "#Show( %s )\n" % self.variable["importanceFactorsGraph"]
879 txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ])
880 txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"])
881 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"]
882 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"]
883 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"]
886 if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivity' ) ):
887 if ( self.DictMCVal[ 'FORMEventProbabilitySensitivity' ] == "yes" ):
888 txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"])
889 txt += "print 'FORM Event Probability Sensitivity:'\n"
890 txt += "for i in range( %s ):\n" % self.variable["n"]
891 txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"]
892 txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["eventProbabilitySensitivity"]
893 txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"])
895 txt += "%s = %s.drawEventProbabilitySensitivity()[0]\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"])
896 txt += "#Show( %s )\n" % self.variable["eventProbabilitySensitivityGraph"]
897 txt += "%s = '%s'\n" % (self.variable["eventProbabilitySensitivityDrawing"], self.DictMCVal[ 'FORMEventProbabilitySensitivityDrawingFilename' ])
898 txt += "%s.draw( %s )\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["eventProbabilitySensitivityDrawing"])
899 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["eventProbabilitySensitivityGraph"]
900 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["eventProbabilitySensitivityGraph"]
901 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["eventProbabilitySensitivityGraph"]
904 if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivity' ) ):
905 if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivity' ] == "yes" ):
906 txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"])
907 txt += "print 'Hasofer Reliability Index Sensitivity:'\n"
908 txt += "for i in range( %s ):\n" % self.variable["n"]
909 txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"]
910 txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["hasoferReliabilityIndexSensitivity"]
911 txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"])
913 txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()[0]\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"])
914 txt += "#Show( %s )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
915 txt += "%s = '%s'\n" % (self.variable["hasoferReliabilityIndexSensitivityDrawing"], self.DictMCVal[ 'HasoferReliabilityIndexSensitivityDrawingFilename' ])
916 txt += "%s.draw( %s )\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["hasoferReliabilityIndexSensitivityDrawing"])
917 txt += "ViewImage( %s.getBitmap() )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
918 txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
919 txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
922 if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ):
923 if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ):
924 txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"])
925 txt += "print '%s =', %s\n" % ("Tvedt Approximation", self.variable["tvedtApproximation"])
928 if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ):
929 if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ):
930 txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"])
931 txt += "print '%s =', %s\n" % ("HohenBichler Approximation", self.variable["tvedtApproximation"])
934 if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ):
935 if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ):
936 txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"])
937 txt += "print '%s =', %s\n" % ("Breitung Approximation", self.variable["breitungApproximation"])
943 def RandomGenerator (self):
950 if ( self.DictMCVal.has_key( 'RandomGeneratorSeed' ) ):
951 seed = self.DictMCVal[ 'RandomGeneratorSeed' ]
952 txt += "# Initialise le generateur aleatoire\n"
953 txt += "RandomGenerator.SetSeed( %s )\n" % seed
960 Definition de l evenement de defaillance
963 if ( self.DictMCVal.has_key( 'ComparisonOperator' ) ):
964 operator = self.DictMCVal[ 'ComparisonOperator' ]
967 if ( self.DictMCVal.has_key( 'Threshold' ) ):
968 threshold = self.DictMCVal[ 'Threshold' ]
970 txt = "# Evenement de defaillance\n"
971 txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold)
972 txt += "%s.setName( '%s' )\n" % (self.variable["myEvent"], "myEvent")
976 def MonteCarlo (self):
978 Methode de MonteCarlo
980 txt = "# Simulation par MonteCarlo\n"
981 txt += "%s = MonteCarlo( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"])
990 txt = "# Simulation par LHS\n"
991 txt += "%s = LHS( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"])
996 def ImportanceSampling (self):
998 Methode de tirage d importance
1001 if ( self.DictMCVal.has_key( 'MeanVector' ) ):
1002 meanVector = self.DictMCVal[ 'MeanVector' ]
1003 dimension = len( meanVector )
1005 txt = "# Simulation par Tirage d'importance\n"
1006 txt += "# Densite d'importance\n"
1007 txt += "%s = NumericalPoint( %s )\n" % (self.variable["meanVector"], self.variable["n"])
1008 for i in range(dimension):
1009 txt += "%s[%d] = %g\n" % (self.variable["meanVector"], i, meanVector[i])
1011 txt += "%s = Normal( %s, CovarianceMatrix( IdentityMatrix( %s ) ) )\n" % (self.variable["importanceDensity"], self.variable["meanVector"], self.variable["n"])
1012 txt += "%s = ImportanceSampling( %s, Distribution( %s ) )\n" % (self.variable["myAlgo"], self.variable["myEvent"], self.variable["importanceDensity"])
1021 txt = "# Algorithme FORM\n"
1022 txt += "%s = FORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"])
1031 txt = "# Algorithme SORM\n"
1032 txt += "%s = SORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"])
1037 def RunAlgorithm (self):
1042 if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ):
1043 if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ):
1044 txt += "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"])
1045 txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"])
1046 txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"])
1049 txt += "# Perform the computation\n"
1050 txt += "%s.run()\n" % self.variable["myAlgo"]
1054 if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ):
1055 if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ):
1056 txt += "%s = %s.getEvaluationCallsNumber() - %s\n" % (self.variable["modelEvaluationCalls"], self.variable["model"], self.variable["modelEvaluationCalls"])
1057 txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"])
1058 txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"])
1060 txt += "print '%s =', %s\n" % ("model Evaluation Calls", self.variable["modelEvaluationCalls"])
1061 txt += "print '%s =', %s\n" % ("model Gradient Calls", self.variable["modelGradientCalls"])
1062 txt += "print '%s =', %s\n" % ("model Hessian Calls", self.variable["modelHessianCalls"])
1071 txt = "# Optimisation par Cobyla\n"
1072 txt += "%s = Cobyla()\n" % self.variable["myOptimizer"]
1073 txt += "#%s = CobylaSpecificParameters()\n" % self.variable["specificParameters"]
1074 txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"])
1079 def AbdoRackwitz (self):
1081 Methode AbdoRackwitz
1083 txt = "# Optimisation par AbdoRackwitz\n"
1084 txt += "%s = AbdoRackwitz()\n" % self.variable["myOptimizer"]
1085 txt += "#%s = AbdoRackwitzSpecificParameters()\n" % self.variable["specificParameters"]
1086 txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"])
1090 def Beta (self, loi):
1092 Definition de la loi Beta
1096 "MuSigma" : "Beta.MUSIGMA",
1098 if loi[ 'Settings' ] == 'RT' :
1103 arg2 = loi[ 'Sigma' ]
1107 txt = "Beta( %g, %g, %g, %g, %s )" % (arg1, arg2, arg3, arg4, settings[ loi[ 'Settings' ] ])
1110 def Exponential (self, loi):
1112 Definition de la loi Exponential
1114 arg1 = loi[ 'Lambda' ]
1115 arg2 = loi[ 'Gamma' ]
1116 txt = "Exponential( %g, %g )" % (arg1, arg2)
1119 def Gamma (self, loi):
1121 Definition de la loi Gamma
1124 "KLambda" : "Gamma.KLAMBDA",
1125 "MuSigma" : "Gamma.MUSIGMA",
1127 if loi[ 'Settings' ] == 'KLambda' :
1129 arg2 = loi[ 'Lambda' ]
1132 arg2 = loi[ 'Sigma' ]
1134 arg3 = loi[ 'Gamma' ]
1135 txt = "Gamma( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1138 def Geometric (self, loi):
1140 Definition de la loi Geometric
1142 txt = "Geometric( %g )" % loi[ 'P' ]
1145 def Gumbel (self, loi):
1147 Definition de la loi Gumbel
1150 "AlphaBeta" : "Gumbel.ALPHABETA",
1151 "MuSigma" : "Gumbel.MUSIGMA",
1153 if loi[ 'Settings' ] == 'AlphaBeta' :
1154 arg1 = loi[ 'Alpha' ]
1155 arg2 = loi[ 'Beta' ]
1158 arg2 = loi[ 'Sigma' ]
1160 txt = "Gumbel( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ])
1163 def Histogram (self, loi):
1165 Definition de la loi Histogram
1167 arg1 = loi[ 'First' ]
1168 arg2 = loi[ 'Values' ]
1169 txt = "Histogram( %g, %s )" % (arg1, arg2)
1172 def Laplace (self, loi):
1174 Definition de la loi Laplace
1176 arg1 = loi[ 'Lambda' ]
1178 txt = "Laplace( %g, %g )" % (arg1, arg2)
1181 def Logistic (self, loi):
1183 Definition de la loi Logistic
1185 arg1 = loi[ 'Alpha' ]
1186 arg2 = loi[ 'Beta' ]
1187 txt = "Logistic( %g, %g )" % (arg1, arg2)
1190 def LogNormal (self, loi):
1192 Definition de la loi LogNormal
1195 "MuSigmaLog" : "LogNormal.MUSIGMA_LOG",
1196 "MuSigma" : "LogNormal.MUSIGMA",
1197 "MuSigmaOverMu" : "LogNormal.MU_SIGMAOVERMU",
1199 if loi[ 'Settings' ] == 'MuSigmaLog' :
1200 arg1 = loi[ 'MuLog' ]
1201 arg2 = loi[ 'SigmaLog' ]
1202 elif loi[ 'Settings' ] == 'MuSigmaOverMu' :
1204 arg2 = loi[ 'SigmaOverMu' ]
1207 arg2 = loi[ 'Sigma' ]
1209 arg3 = loi[ 'Gamma' ]
1210 txt = "LogNormal( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1213 def MultiNomial (self, loi):
1215 Definition de la loi MultiNomial
1217 arg1 = loi[ 'Values' ]
1219 txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2)
1222 def NonCentralStudent (self, loi):
1224 Definition de la loi NonCentralStudent
1227 arg2 = loi[ 'Delta' ]
1228 arg3 = loi[ 'Gamma' ]
1229 txt = "NonCentralStudent( %g, %g )" % (arg1, arg2, arg3)
1232 def Normal (self, loi):
1234 Definition de la loi Normal
1237 arg2 = loi[ 'Sigma' ]
1238 txt = "Normal( %g, %g )" % (arg1, arg2)
1241 def TruncatedNormal (self, loi):
1243 Definition de la loi TruncatedNormal
1246 arg2 = loi[ 'SigmaN' ]
1249 txt = "TruncatedNormal( %g, %g, %g, %g )" % (arg1, arg2, arg3, arg4)
1252 def Poisson (self, loi):
1254 Definition de la loi Poisson
1256 txt = "Poisson( %g )" % loi[ 'Lambda' ]
1259 def Rayleigh (self, loi):
1261 Definition de la loi Rayleigh
1263 arg1 = loi[ 'Sigma' ]
1264 arg2 = loi[ 'Gamma' ]
1265 txt = "Rayleigh( %g, %g )" % (arg1, arg2)
1268 def Student (self, loi):
1270 Definition de la loi Student
1274 arg3 = loi[ 'Sigma' ]
1275 txt = "Student( %g, %g, %g )" % (arg1, arg2, arg3)
1278 def Triangular (self, loi):
1280 Definition de la loi Triangular
1285 txt = "Triangular( %g, %g, %g )" % (arg1, arg2, arg3)
1288 def Uniform (self, loi):
1290 Definition de la loi Uniform
1294 txt = "Uniform( %g, %g )" % (arg1, arg2)
1297 def UserDefined (self, loi):
1299 Definition de la loi UserDefined
1301 txt = "** UserDefined not defined yet **"
1304 def Weibull (self, loi):
1306 Definition de la loi Weibull
1309 "AlphaBeta" : "Weibull.ALPHABETA",
1310 "MuSigma" : "Weibull.MUSIGMA",
1312 if loi[ 'Settings' ] == 'AlphaBeta' :
1313 arg1 = loi[ 'Alpha' ]
1314 arg2 = loi[ 'Beta' ]
1317 arg2 = loi[ 'Sigma' ]
1319 arg3 = loi[ 'Gamma' ]
1320 txt = "Weibull( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1325 def GraphiquePDF (self, loi, fichier):
1327 Produit une image PNG representant la PDF de la loi
1329 txt = headerSTD % self.OpenTURNS_path
1330 txt += "dist = %s\n" % apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) )
1331 txt += "graph = dist.drawPDF()\n"
1332 txt += "graph.draw( '%s' )\n" % fichier