]> SALOME platform Git repositories - tools/eficas.git/blob - generator/OpenturnsSTD.py
Salome HOME
*** empty log message ***
[tools/eficas.git] / generator / OpenturnsSTD.py
1 #@ AJOUT OpenturnsSolver Macro
2 # -*- coding: iso-8859-1 -*-
3 # RESPONSABLE
4
5 """
6 Ce module contient le generateur Etude pour Openturns
7 """
8
9 __revision__ = "V1.0"
10
11 import os
12
13 defaultSTD = """#! /usr/bin/env python
14
15 class StudyFileGenerationError:
16   def __init__ (self, st):
17     self.st = st
18   def __str__(self):
19     return "'%s'" % self.st
20
21 raise StudyFileGenerationError, "The study file was not generated. Check analysis type."
22 """
23
24 headerSTD = """#! /usr/bin/env python
25
26 # Chargement du module systeme
27 import sys
28 sys.path.append( '%s' )
29
30 # Chargement du module math
31 import math
32
33 # Chargement du module Open TURNS
34 from openturns import *
35 from openturns.viewer import ViewImage,StopViewer,WaitForViewer
36
37 results = {}
38
39 """
40
41 footerSTD = """
42
43 # Flush des messages en attente
44 Log.Flush()
45
46 # Terminaison du fichier
47 #sys.exit( 0 )
48 """
49
50 #=============================================
51 #  La classe de creation du fichier STD
52 #=============================================
53
54 class STDGenerateur :
55
56   '''
57   Generation du fichier python
58   '''
59   def __init__ (self, appli, DictMCVal, ListeVariables, DictLois ) :
60     self.DictMCVal = DictMCVal
61     self.ListeVariables = ListeVariables
62     self.DictLois = DictLois
63     #print "DictMCVal=", DictMCVal
64     #print "ListeVariables=", ListeVariables
65     #print "DictLois=", DictLois
66     self.texteSTD = defaultSTD
67     self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path
68
69     # Ce dictionnaire fait la correspondance entre le mot lu dans le dictionnaire des mots-clefs et la methode a appeler
70     self.traitement = {
71       "Min/Max" :
72       ( "MinMax",
73         { "Experiment Plane" : "ExperimentPlane",
74           "Random Sampling" : "MinMaxRandomSampling",
75           },
76         ),
77       "Central Uncertainty" :
78       ( "CentralUncertainty",
79         { "Taylor Variance Decomposition" : "TaylorVarianceDecomposition",
80           "Random Sampling" : "CentralUncertaintyRandomSampling",
81          },
82         ),
83       "Threshold Exceedence" :
84       ( "ThresholdExceedence",
85         { "Simulation" : "Simulation",
86           "Analytical" : "Analytical",
87           "MonteCarlo" : "MonteCarlo",
88           "LHS" : "LHS",
89           "ImportanceSampling" : "ImportanceSampling",
90           "FirstOrder" : "FORM",
91           "SecondOrder" : "SORM",
92           "Cobyla" : "Cobyla",
93           "AbdoRackwitz" : "AbdoRackwitz",
94           },
95         ),
96       }
97
98     # Ce dictionnaire liste le nom des variables utilisees dans le script
99     # La clef est le nom attendu par les methodes, la valeur est le nom produit dans le fichier de sortie
100     # Le fait de passer par un dictionnaire permet de controler que les variables existent et sont correctement nommees
101     # meme si clef == valeur
102     self.variable = {
103       "n" : "n",
104       "p" : "p",
105       "wrapper" : "wrapper",
106       "wrapperdata" : "wrapperdata",
107       "frameworkdata" : "frameworkdata",
108       "framework" : "framework",
109       "studyid" : "studyid",
110       "studycase" : "studycase",
111       "componentname" : "componentname",
112       "model" : "model",
113       "scaledVector" : "scaledVector",
114       "translationVector" : "translationVector",
115       "levels" : "levels",
116       "myCenteredReductedGrid" : "myCenteredReductedGrid",
117       "myExperimentPlane" : "myExperimentPlane",
118       "inputSample" : "inputSample",
119       "outputSample" : "outputSample",
120       "minValue" : 'results["minValue"]',
121       "maxValue" : 'results["maxValue"]',
122       "flags" : "flags",
123       "inSize" : "inSize",
124       "distribution" : "distribution",
125       "marginal" : "marginal",
126       "collection" : "collection",
127       "copula" : "copula",
128       "inputRandomVector" : "inputRandomVector",
129       "outputRandomVector" : "outputRandomVector",
130       "myQuadraticCumul" : "myQuadraticCumul",
131       "meanFirstOrder" : 'results["meanFirstOrder"]',
132       "meanSecondOrder" : 'results["meanSecondOrder"]',
133       "standardDeviationFirstOrder" : 'results["standardDeviationFirstOrder"]',
134       "importanceFactors" : 'results["importanceFactors"]',
135       "importanceFactorsGraph" : "importanceFactorsGraph",
136       "importanceFactorsDrawing" : "importanceFactorsDrawing",
137       "empiricalMean" : 'results["empiricalMean"]',
138       "empiricalStandardDeviation" : 'results["empiricalStandardDeviation"]',
139       "empiricalQuantile" : 'results["empiricalQuantile"]',
140       "alpha" : "alpha",
141       "beta" : "beta",
142       "PCCcoefficient" : 'results["PCCcoefficient"]',
143       "PRCCcoefficient" : 'results["PRCCcoefficient"]',
144       "SRCcoefficient" : 'results["SRCcoefficient"]',
145       "SRRCcoefficient" : 'results["SRRCcoefficient"]',
146       "kernel" : "kernel",
147       "kernelSmoothedDist" : "kernelSmoothedDist",
148       "kernelSmoothedPDF" : "kernelSmoothedPDF",
149       "myEvent" : "myEvent",
150       "myAlgo" : "myAlgo",
151       "myResult" : "myResult",
152       "probability" : 'results["probability"]',
153       "standardDeviation" : 'results["standardDeviation"]',
154       "level" : "level",
155       "length" : "length",
156       "coefficientOfVariation" : 'results["coefficientOfVariation"]',
157       "convergenceGraph" : "convergenceGraph",
158       "iterations" : 'results["iterations"]',
159       "myOptimizer" : "myOptimizer",
160       "specificParameters" : "specificParameters",
161       "startingPoint" : "startingPoint",
162       "hasoferReliabilityIndex" : 'results["hasoferReliabilityIndex"]',
163       "standardSpaceDesignPoint" : 'results["standardSpaceDesignPoint"]',
164       "physicalSpaceDesignPoint" : 'results["physicalSpaceDesignPoint"]',
165       "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]',
166       "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]',
167       "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph",
168       "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph",
169       "modelEvaluationCalls" : 'results["modelEvaluationCalls"]',
170       "modelGradientCalls" : 'results["modelGradientCalls"]',
171       "modelHessianCalls" : 'results["modelHessianCalls"]',
172       "tvedtApproximation" : 'results["tvedtApproximation"]',
173       "hohenBichlerApproximation" : 'results["hohenBichlerApproximation"]',
174       "breitungApproximation" : 'results["breitungApproximation"]',
175       }
176
177     # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque
178     self.logFlags = {
179       "DebugMessages"   : "Log.DBG",
180       "WrapperMessages" : "Log.WRAPPER",
181       "UserMessages"    : "Log.USER",
182       "InfoMessages"    : "Log.INFO",
183       "WarningMessages" : "Log.WARN",
184       "ErrorMessages"   : "Log.ERROR",
185       }
186     
187   def CreeSTD (self) :
188     '''
189     Pilotage de la creation du fichier python
190     '''
191     TypeAnalyse = None
192     if ( self.DictMCVal.has_key( 'Type' ) ):
193       TypeAnalyse =  self.DictMCVal[ 'Type' ]
194
195     Traitement = None
196     subDict = {}
197     if ( self.traitement.has_key( TypeAnalyse ) ):
198       (Traitement, subDict) =  self.traitement[ TypeAnalyse ]
199
200     if ( Traitement is not None ):
201       self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) )
202     
203     return self.texteSTD
204
205   def Header (self) :
206     '''
207     Imprime l entete commun a tous les fichiers
208     '''
209     txt  = headerSTD % self.OpenTURNS_path
210     txt += "# Definit le niveau d'affichage de la log\n"
211     txt += "%s = Log.NONE\n" % self.variable["flags"]
212     for flag in self.logFlags.keys():
213       if ( self.DictMCVal.has_key( flag ) ):
214         val =  self.DictMCVal[ flag ]
215         op = "-"
216         if val == 'yes' :
217           op = "+"
218         txt += "%s = %s %s %s\n" % (self.variable["flags"], self.variable["flags"], op, self.logFlags[ flag ])
219     txt += "Log.Show( %s )\n" % self.variable["flags"]
220     txt += "\n"
221     return txt
222
223   def Footer (self) :
224     '''
225     Imprime le pied de page commun a tous les fichiers
226     '''
227     return footerSTD
228
229   def MinMax (self, subDict):
230     '''
231     Produit le fichier study correspondant a une analyse Min/Max
232     '''
233     txt  = self.Header()
234     txt += "# Etude 'Min/Max'\n"
235
236     txt += self.Model()
237     
238     Methode = None
239     if ( self.DictMCVal.has_key( 'Method' ) ):
240       Methode =  self.DictMCVal[ 'Method' ]
241
242     Traitement = None
243     if ( subDict.has_key( Methode ) ):
244       Traitement =  subDict[ Methode ]
245
246     if ( Traitement is not None ):
247       txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
248
249     txt += self.MinMaxComputation()
250     txt += self.MinMaxResult()
251     
252     txt += self.Footer()
253     return txt
254
255   def Model (self):
256     '''
257     Importe le modele physique
258     '''
259     fonction = None
260     if ( self.DictMCVal.has_key( 'FileName' ) ):
261       name =  self.DictMCVal[ 'FileName' ]
262       #fonction = name[name.rfind('/')+1:name.rfind('.xml')]
263       
264     txt  = "# Charge le modele physique\n"
265     txt  = "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name)
266
267     txt += "if globals().has_key('%s'):\n" % self.variable["framework"]
268     txt += "  %s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"])
269     txt += "  %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"])
270     txt += "  %s.studyid_ = %s['%s']\n"  % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studyid"])
271     txt += "  %s.studycase_ = %s['%s']\n"  % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studycase"])
272     txt += "  %s.componentname_ = %s['%s']\n"  % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"])
273     txt += "  %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"])
274     txt += "  %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"])
275     
276     txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],)
277     txt += "%s = %s.getInputNumericalPointDimension()\n" % (self.variable["n"], self.variable["model"])
278     txt += "\n"
279     return txt
280
281   def ExperimentPlane (self):
282     '''
283     Etude par plan d experience
284     '''
285     txt  = "# Etude par plan d'experience\n"
286     txt += self.Levels()
287     txt += self.CenteredReductedGrid()
288     txt += self.ScaledVector()
289     txt += self.TranslationVector()
290     txt += "%s = %s\n" % (self.variable["inputSample"], self.variable["myExperimentPlane"])
291     txt += "\n"
292     return txt
293
294   def MinMaxRandomSampling (self):
295     '''
296     Etude par echantillonage aleatoire
297     '''
298     size = 0
299     if ( self.DictMCVal.has_key( 'PointsNumber' ) ):
300       size =  self.DictMCVal[ 'PointsNumber' ]
301
302     txt  = "# Etude par echantillonage aleatoire\n"
303     txt += self.InputDistribution()
304     txt += self.InputRandomVector()
305     txt += "%s = %d\n" % (self.variable["inSize"], size)
306     txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"])
307     txt += "\n"
308     return txt
309
310   def InputDistribution (self):
311     '''
312     Cree la loi jointe des variables d entree
313     '''
314     txt  = "# Definit la loi jointe des variables d'entree\n"
315     txt += "%s = DistributionCollection( %d )\n" % (self.variable["collection"], len( self.ListeVariables ))
316     txt += "\n"
317
318     dictVariables = {}
319     for variable in self.ListeVariables:
320       nomVar = variable['ModelVariable'].get_name()
321       dictVariables[ nomVar ] = variable['Distribution']
322
323     i = 0
324     sortedVarNames = dictVariables.keys()
325     sortedVarNames.sort()
326     for variable in sortedVarNames:
327       conceptloi = dictVariables[ variable ]
328       loi = self.DictLois[ conceptloi ]
329       if loi.has_key( 'Kind' ):
330         marginale = "%s_%d" % (self.variable["marginal"], i)
331         txt += "# Definit la loi marginale de la composante %d\n" % i
332         txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi, i, self.variable["collection"]) ))
333         txt += "%s[ %d ] = Distribution( %s )\n" % (self.variable["collection"], i, marginale)
334         txt += "\n"
335         i += 1
336
337     txt += self.Copula( len( self.ListeVariables ) )
338
339     txt += "# Definit la loi jointe\n"
340     txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"])
341     txt += "\n"
342     return txt
343
344   def Copula (self, dimension):
345     '''
346     Cree la copule de la loi jointe
347     '''
348     txt  = "# Definit la copule de la loi jointe\n"
349     txt += "%s = IndependentCopula( %d )\n" % (self.variable["copula"], dimension)
350     txt += "\n"
351     return txt
352
353   def InputRandomVector (self):
354     '''
355     Cree le vector aleatoire d entree
356     '''
357     txt  = "# Definit le vecteur aleatoire d'entree\n"
358     txt += "%s = RandomVector( %s )\n" % (self.variable["inputRandomVector"], self.variable["distribution"])
359     txt += "\n"
360     return txt
361
362   def OutputRandomVector (self):
363     '''
364     Cree le vector aleatoire de sortie
365     '''
366     txt  = "# Definit le vecteur aleatoire de sortie\n"
367     txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"])
368     txt += "\n"
369     return txt
370
371   def ScaledVector (self):
372     '''
373     Definit les coefficients multiplicateurs par composante du vecteur
374     '''
375     dimension = 0
376     if ( self.DictMCVal.has_key( 'UnitsPerDimension' ) ):
377       unitsPerDimension =  self.DictMCVal[ 'UnitsPerDimension' ]
378       dimension = len( unitsPerDimension )
379     
380     txt  = "# Definit les facteurs d'echelle dans chaque direction\n"
381     txt += "%s = NumericalPoint( %s )\n" % (self.variable["scaledVector"], self.variable["n"])
382     for i in range(dimension):
383       txt += "%s[%d] = %g\n" % (self.variable["scaledVector"], i, unitsPerDimension[i])
384     txt += "%s.scale( %s )\n" % (self.variable["myExperimentPlane"], self.variable["scaledVector"])
385     txt += "\n"
386     return txt
387
388   def TranslationVector (self):
389     '''
390     Definit le vecteur de translation
391     '''
392     dimension = 0
393     if ( self.DictMCVal.has_key( 'Center' ) ):
394       center =  self.DictMCVal[ 'Center' ]
395       dimension = len( center )
396     
397     txt  = "# Definit le vecteur de translation\n"
398     txt += "%s = NumericalPoint( %s )\n" % (self.variable["translationVector"], self.variable["n"])
399     for i in range(dimension):
400       txt += "%s[%d] = %g\n" % (self.variable["translationVector"], i, center[i])
401     txt += "%s.translate( %s )\n" % (self.variable["myExperimentPlane"], self.variable["translationVector"])
402     txt += "\n"
403     return txt
404
405   def Levels (self):
406     '''
407     Definit les niveaux du plan d experience
408     '''
409     dimension = 0
410     if ( self.DictMCVal.has_key( 'Levels' ) ):
411       levels =  self.DictMCVal[ 'Levels' ]
412       dimension = len( levels )
413     
414     txt  = "# Definit les niveaux de la structure de grille\n"
415     txt += "%s = NumericalPoint( %d )\n" % (self.variable["levels"], dimension)
416     for i in range(dimension):
417       txt += "%s[%d] = %g\n" % (self.variable["levels"], i, levels[i])
418     txt += "\n"
419     return txt
420
421   def CenteredReductedGrid (self):
422     '''
423     Definit la grille reduite du plan d experience
424     '''
425     plane = None
426     if ( self.DictMCVal.has_key( 'ExperimentPlane' ) ):
427       plane =  self.DictMCVal[ 'ExperimentPlane' ]
428
429     txt  = "# Cree le plan d'experience centre reduit\n"
430     txt += "%s = %s(%s, %s)\n" % (self.variable["myCenteredReductedGrid"], plane, self.variable["n"], self.variable["levels"])
431     txt += "%s = %s.generate()\n" % (self.variable["myExperimentPlane"], self.variable["myCenteredReductedGrid"])
432     txt += "\n"
433     return txt
434
435   def MinMaxComputation (self):
436     '''
437     Realise le calcul deterministe
438     '''
439     txt  = "# Calcul\n"
440     txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"])
441     txt += "\n"
442     return txt
443
444   def MinMaxResult (self):
445     '''
446     Produit les resultats de l etude
447     '''
448     txt  = "# Resultats\n"
449     txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"])
450     txt += "print '%s = ', %s\n" % (self.variable["minValue"], self.variable["minValue"])
451     txt += "\n"
452     txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"])
453     txt += "print '%s = ', %s\n" % (self.variable["maxValue"], self.variable["maxValue"])
454     txt += "\n"
455     return txt
456
457   def CentralUncertainty (self, subDict):
458     '''
459     Produit le fichier study correspondant a une analyse d incertitude en valeur centrale
460     '''
461     txt  = self.Header()
462     txt += "# Etude 'Central Uncertainty'\n"
463
464     txt += self.Model()
465     txt += self.InputDistribution()
466     txt += self.InputRandomVector()
467     txt += self.OutputRandomVector()
468    
469     Methode = None
470     if ( self.DictMCVal.has_key( 'Method' ) ):
471       Methode =  self.DictMCVal[ 'Method' ]
472
473     Traitement = None
474     if ( subDict.has_key( Methode ) ):
475       Traitement =  subDict[ Methode ]
476
477     if ( Traitement is not None ):
478       txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
479
480     txt += self.Footer()
481     return txt
482
483
484   def TaylorVarianceDecomposition (self):
485     '''
486     Etude par decomposition de Taylor
487     '''
488     txt  = "# Cumul quadratique (decomposition de Taylor)\n"
489     txt += "%s = QuadraticCumul( %s )\n" % (self.variable["myQuadraticCumul"], self.variable["outputRandomVector"])
490     txt += "\n"
491     txt += "# Resultats\n"
492     
493     if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ):
494       if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ):
495         txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"])
496         txt += "print '%s = ', %s\n" % (self.variable["meanFirstOrder"], self.variable["meanFirstOrder"])
497         txt += "\n"
498        
499     if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ):
500       if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ):
501         txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"])
502         txt += "print '%s = ', %s\n" % (self.variable["meanSecondOrder"], self.variable["meanSecondOrder"])
503         txt += "\n"
504
505     if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ):
506       if ( self.DictMCVal[ 'StandardDeviationFirstOrder' ] == "yes" ):
507         txt += "%s = %s.getCovariance()\n" % (self.variable["standardDeviationFirstOrder"], self.variable["myQuadraticCumul"])
508         txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"]
509         txt += "for i in range( dim ):\n"
510         txt += "  %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"])
511         txt += "print '%s = ', %s\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"])
512         txt += "\n"
513
514     if ( self.DictMCVal.has_key( 'NumericalResults' ) ):
515       if ( self.DictMCVal[ 'NumericalResults' ] == "yes" ):
516         txt += "if ( %s.getDimension() == 1):\n" % self.variable["outputRandomVector"]
517         txt += "  %s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"])
518         txt += "  print '%s = ', %s\n" % (self.variable["importanceFactors"], self.variable["importanceFactors"])
519         txt += "\n"
520
521     if ( self.DictMCVal.has_key( 'GraphicalResults' ) ):
522       if ( self.DictMCVal[ 'GraphicalResults' ] == "yes" ):
523         txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"])
524         txt += "Show( %s )\n"  % self.variable["importanceFactorsGraph"]
525         txt += "%s.draw( '%s' )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"])
526         txt += "ViewImage( %s.getBitmap() )\n"  % self.variable["importanceFactorsGraph"]
527         txt += "print 'bitmap =', %s.getBitmap()\n"  % self.variable["importanceFactorsGraph"]
528         txt += "print 'postscript =', %s.getPostscript()\n"  % self.variable["importanceFactorsGraph"]
529         txt += "\n"
530         
531     txt += "\n"
532     return txt
533
534   def CentralUncertaintyRandomSampling (self):
535     '''
536     Etude par echantillonage aleatoire
537     '''
538     size = 0
539     if ( self.DictMCVal.has_key( 'PointsNumber' ) ):
540       size =  self.DictMCVal[ 'PointsNumber' ]
541
542     txt  = "# Echantillonnage aleatoire de la variable de sortie\n"
543     txt += "%s = %d\n" % (self.variable["inSize"], size)
544     txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"])
545     txt += "\n"
546
547     if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ):
548       if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ):
549         txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"])
550         txt += "print '%s =', %s\n" % (self.variable["empiricalMean"], self.variable["empiricalMean"])
551         txt += "\n"
552
553     if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ):
554       if ( self.DictMCVal[ 'EmpiricalStandardDeviation' ] == "yes" ):
555         txt += "%s = %s.computeCovariance()\n" % (self.variable["empiricalStandardDeviation"], self.variable["outputSample"])
556         txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"]
557         txt += "for i in range( dim ):\n"
558         txt += "  %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"])
559         txt += "print '%s = ', %s\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"])
560         txt += "\n"
561
562     if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ):
563       ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ]
564       txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre)
565       txt += "print '%s =', %s\n" % (self.variable["empiricalQuantile"], self.variable["empiricalQuantile"])
566       txt += "\n"
567    
568     if ( self.DictMCVal.has_key( 'AnalysedCorrelations' ) ):
569       if ( self.DictMCVal[ 'AnalysedCorrelations' ] == "yes" ):
570         txt += "# Ou est le %s ?\n" % self.variable["inputSample"]
571         txt += "#if ( ( %s.getDimension() == 1 ) and ( %s.getDimension() == 1 ) ):\n" % (self.variable["inputSample"], self.variable["outputSample"])
572         txt += "#  %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
573         txt += "#  print '%s = ', %s\n" % (self.variable["PCCcoefficient"], self.variable["PCCcoefficient"])
574         txt += "#  %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
575         txt += "#  print '%s = ', %s\n" % (self.variable["PRCCcoefficient"], self.variable["PRCCcoefficient"])
576         txt += "#  %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
577         txt += "#  print '%s = ', %s\n" % (self.variable["SRCcoefficient"], self.variable["SRCcoefficient"])
578         txt += "#  %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"])
579         txt += "#  print '%s = ', %s\n" % (self.variable["SRRCcoefficient"], self.variable["SRRCcoefficient"])
580         txt += "\n"
581    
582     if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ):
583       if ( self.DictMCVal[ 'KernelSmoothing' ] == "yes" ):
584         txt += "# Kernel Smoohing\n"
585         txt += "%s = KernelSmoothing()\n" % self.variable["kernel"]
586         txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"]
587         txt += "  %s = %s.buildImplementation( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"])
588         txt += "  %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedPDF"], self.variable["kernelSmoothedDist"])
589         txt += "  Show( %s )\n" % self.variable["kernelSmoothedPDF"]
590         txt += "\n"
591    
592     return txt
593
594   def ThresholdExceedence (self, subDict):
595     '''
596     Produit le fichier study correspondant a une analyse de depassement de seuil
597     '''
598     txt  = self.Header()
599     txt += "# Etude 'Threshold Exceedence'\n"
600
601     txt += self.RandomGenerator()
602     txt += self.Model()
603     txt += self.InputDistribution()
604     txt += self.InputRandomVector()
605     txt += self.OutputRandomVector()
606     txt += self.Event()
607    
608     Methode = None
609     if ( self.DictMCVal.has_key( 'Method' ) ):
610       Methode =  self.DictMCVal[ 'Method' ]
611
612     Traitement = None
613     if ( subDict.has_key( Methode ) ):
614       Traitement =  subDict[ Methode ]
615
616     if ( Traitement is not None ):
617       txt += apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) )
618
619     txt += self.Footer()
620     return txt
621
622   def Simulation (self, subDict):
623     '''
624     Methodes de simulation
625     '''
626     Algorithme = None
627     if ( self.DictMCVal.has_key( 'Algorithm' ) ):
628       Algorithme =  self.DictMCVal[ 'Algorithm' ]
629
630     Traitement = None
631     if ( subDict.has_key( Algorithme ) ):
632       Traitement =  subDict[ Algorithme ]
633
634     if ( Traitement is not None ):
635       txt = apply( STDGenerateur.__dict__[ Traitement ], (self,) )
636
637     maxOuterSampling = None
638     if ( self.DictMCVal.has_key( 'MaximumOuterSampling' ) ):
639       maxOuterSampling = self.DictMCVal[ 'MaximumOuterSampling' ]
640       txt += "%s.setMaximumOuterSampling( %s )\n" % (self.variable["myAlgo"], maxOuterSampling)
641
642     blockSize = None
643     if ( self.DictMCVal.has_key( 'BlockSize' ) ):
644       maxOuterSampling = self.DictMCVal[ 'BlockSize' ]
645       txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize)
646
647     maxCoefficientOfVariation = None
648     if ( self.DictMCVal.has_key( 'MaximumCoefficientOfVariation' ) ):
649       maxCoefficientOfVariation = self.DictMCVal[ 'MaximumCoefficientOfVariation' ]
650       txt += "%s.setMaximumCoefficientOfVariation( %s )\n" % (self.variable["myAlgo"], maxCoefficientOfVariation)
651
652     txt += "%s.run()\n"  % self.variable["myAlgo"]
653     txt += "\n"
654     txt += "# Resultats de la simulation\n"
655     txt += "%s = %s.getResult()\n"  % (self.variable["myResult"], self.variable["myAlgo"])
656     txt += "\n"
657
658     if ( self.DictMCVal.has_key( 'Probability' ) ):
659       if ( self.DictMCVal[ 'Probability' ] == "yes" ):
660         txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"])
661         txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"])
662         txt += "\n"
663
664     if ( self.DictMCVal.has_key( 'StandardDeviation' ) ):
665       if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ):
666         txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"])
667         txt += "print '%s =', %s\n" % (self.variable["standardDeviation"], self.variable["standardDeviation"])
668         txt += "\n"
669
670     if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ):
671       if ( ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) and ( self.DictMCVal[ 'Probability' ] == "yes" ) ):
672         level = self.DictMCVal[ 'Level' ]
673         txt += "%s = %s.getConfidenceLength( %s )\n" % (self.variable["length"], self.variable["myResult"], level)
674         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"])
675         txt += "\n"
676
677     if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ):
678       if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ):
679         txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"])
680         txt += "print '%s =', %s\n" % (self.variable["coefficientOfVariation"], self.variable["coefficientOfVariation"])
681         txt += "\n"
682
683     if ( self.DictMCVal.has_key( 'IterationNumber' ) ):
684       if ( self.DictMCVal[ 'IterationNumber' ] == "yes" ):
685         txt += "%s = %s.getOuterSampling()\n" % (self.variable["iterations"], self.variable["myResult"])
686         txt += "print '%s =', %s\n" % (self.variable["iterations"], self.variable["iterations"])
687         txt += "\n"
688
689     if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) ):
690       if ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ):
691         txt += "%s = %s.drawProbabilityConvergence()\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"])
692         txt += "Show( %s )\n" % self.variable["convergenceGraph"]
693         txt += "\n"
694
695     return txt
696
697   def Analytical (self, subDict):
698     '''
699     Methodes analytiques
700     '''
701     txt = ""
702     
703     OptimizationAlgo = None
704     if ( self.DictMCVal.has_key( 'OptimizationAlgorithm' ) ):
705       OptimizationAlgo =  self.DictMCVal[ 'OptimizationAlgorithm' ]
706
707     Traitement = None
708     if ( subDict.has_key( OptimizationAlgo ) ):
709       Traitement =  subDict[ OptimizationAlgo ]
710
711     if ( Traitement is not None ):
712       txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
713
714     txt += self.OptimizerSettings()
715     txt += self.PhysicalStartingPoint()
716
717     Approximation = None
718     if ( self.DictMCVal.has_key( 'Approximation' ) ):
719       Approximation =  self.DictMCVal[ 'Approximation' ]
720
721     Traitement = None
722     if ( subDict.has_key( Approximation ) ):
723       Traitement =  subDict[ Approximation ]
724
725     if ( Traitement is not None ):
726       txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) )
727
728     txt += self.RunAlgorithm()
729     txt += self.AnalyticalResult()
730
731     return txt
732
733   def OptimizerSettings (self):
734     '''
735     Parametrage de l optimiseur
736     '''
737     txt = ""
738     
739     iterations = None
740     if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ):
741       iterations = self.DictMCVal[ 'MaximumIterationsNumber' ]
742       txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], iterations)
743
744     absoluteError = None
745     if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ):
746       absoluteError = self.DictMCVal[ 'MaximumAbsoluteError' ]
747       txt += "%s.setMaximumAbsoluteError( %s )\n" % (self.variable["myOptimizer"], absoluteError)
748
749     relativeError = None
750     if ( self.DictMCVal.has_key( 'MaximumRelativeError' ) ):
751       relativeError = self.DictMCVal[ 'MaximumRelativeError' ]
752       txt += "%s.setMaximumRelativeError( %s )\n" % (self.variable["myOptimizer"], relativeError)
753
754     residualError = None
755     if ( self.DictMCVal.has_key( 'MaximumResidualError' ) ):
756       residualError = self.DictMCVal[ 'MaximumResidualError' ]
757       txt += "%s.setMaximumResidualError( %s )\n" % (self.variable["myOptimizer"], residualError)
758
759     constraintError = None
760     if ( self.DictMCVal.has_key( 'MaximumConstraintError' ) ):
761       constraintError = self.DictMCVal[ 'MaximumConstraintError' ]
762       txt += "%s.setMaximumConstraintError( %s )\n" % (self.variable["myOptimizer"], constraintError)
763
764     txt += "\n"
765
766     return txt
767
768   def PhysicalStartingPoint (self):
769     '''
770     Point physique de depart
771     '''
772     txt  = "# Point physique de depart\n"
773
774     if ( self.DictMCVal.has_key( 'PhysicalStartingPoint' ) ):
775       point = self.DictMCVal[ 'PhysicalStartingPoint' ]
776       dimension = len( point )
777       txt += "%s = NumericalPoint( %d )\n" % (self.variable["startingPoint"], dimension)
778       for i in range( dimension ):
779         txt += "%s[ %d ] = %g\n" % (self.variable["startingPoint"], i, point[i])
780     else:
781       txt += "%s = %s.getMean()\n" % (self.variable["startingPoint"], self.variable["inputRandomVector"])
782       
783     txt += "\n"
784
785     return txt
786
787   def AnalyticalResult (self):
788     '''
789     Resultat des methodes analytiques
790     '''
791     txt  = "# Resultat des methodes analytiques\n"
792     txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"])
793     
794     if ( self.DictMCVal.has_key( 'Probability' ) ):
795       if ( self.DictMCVal[ 'Probability' ] == "yes" ):
796         txt += "%s = %s.getEventProbability()\n" % (self.variable["probability"], self.variable["myResult"])
797         txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"])
798         txt += "\n"
799
800     if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ):
801       if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ):
802         txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"])
803         txt += "print '%s =', %s\n" % (self.variable["hasoferReliabilityIndex"], self.variable["hasoferReliabilityIndex"])
804         txt += "\n"
805
806     if ( self.DictMCVal.has_key( 'DesignPoint' ) ):
807       if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ):
808         txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"])
809         txt += "print '%s =', %s\n" % (self.variable["standardSpaceDesignPoint"], self.variable["standardSpaceDesignPoint"])
810         txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"])
811         txt += "print '%s =', %s\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["physicalSpaceDesignPoint"])
812         txt += "\n"
813
814     if ( self.DictMCVal.has_key( 'ImportanceFactorNumericalResults' ) ):
815       if ( self.DictMCVal[ 'ImportanceFactorNumericalResults' ] == "yes" ):
816         txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"])
817         txt += "print '%s =', %s\n" % (self.variable["importanceFactors"], self.variable["importanceFactors"])
818         txt += "\n"
819
820     if ( self.DictMCVal.has_key( 'ImportanceFactorGraphicalResults' ) ):
821       if ( self.DictMCVal[ 'ImportanceFactorGraphicalResults' ] == "yes" ):
822         txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"])
823         txt += "Show( %s )\n"  % self.variable["importanceFactorsGraph"]
824         txt += "\n"
825
826     if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivityNumericalResults' ) ):
827       if ( self.DictMCVal[ 'FORMEventProbabilitySensitivityNumericalResults' ] == "yes" ):
828         txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"])
829         txt += "print '%s =', %s\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"])
830         txt += "\n"
831
832     if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivityGraphicalResults' ) ):
833       if ( self.DictMCVal[ 'FORMEventProbabilitySensitivityGraphicalResults' ] == "yes" ):
834         txt += "%s = %s.drawEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"])
835         txt += "Show( %s[0] )\n" % self.variable["eventProbabilitySensitivityGraph"]
836         txt += "\n"
837
838     if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivityNumericalResults' ) ):
839       if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivityNumericalResults' ] == "yes" ):
840         txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"])
841         txt += "print '%s =', %s\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"])
842         txt += "\n"
843
844     if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivityGraphicalResults' ) ):
845       if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivityGraphicalResults' ] == "yes" ):
846         txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"])
847         txt += "Show( %s[0] )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"]
848         txt += "\n"
849
850     if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ):
851       if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ):
852         txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"])
853         txt += "print '%s =', %s\n" % (self.variable["tvedtApproximation"], self.variable["tvedtApproximation"])
854         txt += "\n"
855
856     if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ):
857       if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ):
858         txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"])
859         txt += "print '%s =', %s\n" % (self.variable["hohenBichlerApproximation"], self.variable["tvedtApproximation"])
860         txt += "\n"
861
862     if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ):
863       if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ):
864         txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"])
865         txt += "print '%s =', %s\n" % (self.variable["breitungApproximation"], self.variable["breitungApproximation"])
866         txt += "\n"
867
868
869     return txt
870
871   def RandomGenerator (self):
872     '''
873     Generateur Aleatoire
874     '''
875     txt = ""
876     
877     seed = None
878     if ( self.DictMCVal.has_key( 'RandomGeneratorSeed' ) ):
879       seed = self.DictMCVal[ 'RandomGeneratorSeed' ]
880       txt += "# Initialise le generateur aleatoire\n"
881       txt += "RandomGenerator.SetSeed( %s )\n" % seed
882       txt += "\n"
883     
884     return txt
885
886   def Event (self):
887     '''
888     Definition de l evenement de defaillance
889     '''
890     operator = None
891     if ( self.DictMCVal.has_key( 'ComparisonOperator' ) ):
892       operator = self.DictMCVal[ 'ComparisonOperator' ]
893
894     threshold = None
895     if ( self.DictMCVal.has_key( 'Threshold' ) ):
896       threshold = self.DictMCVal[ 'Threshold' ]
897     
898     txt  = "# Evenement de defaillance\n"
899     txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold)
900     txt += "\n"
901     return txt
902     
903   def MonteCarlo (self):
904     '''
905     Methode de MonteCarlo
906     '''
907     txt  = "# Simulation par MonteCarlo\n"
908     txt += "%s = MonteCarlo( %s )\n"  % (self.variable["myAlgo"], self.variable["myEvent"])
909     txt += "\n"
910    
911     return txt
912
913   def LHS (self):
914     '''
915     Methode LHS
916     '''
917     txt  = "# Simulation par LHS\n"
918     txt += "%s = LHS( %s )\n"  % (self.variable["myAlgo"], self.variable["myEvent"])
919     txt += "\n"
920    
921     return txt
922
923   def ImportanceSampling (self):
924     '''
925     Methode de tirage d importance
926     '''
927     txt  = "# Simulation par Tirage d'importance\n"
928     txt += "%s = ImportanceSampling( %s )\n"  % (self.variable["myAlgo"], self.variable["myEvent"])
929     txt += "\n"
930
931     return txt
932
933   def FORM (self):
934     '''
935     Methode FORM
936     '''
937     txt  = "# Algorithme FORM\n"
938     txt += "%s = FORM ( NearestPointAlgorithm( %s ), %s, %s )\n"  % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"])
939     txt += "\n"
940
941     return txt
942
943   def SORM (self):
944     '''
945     Methode SORM
946     '''
947     txt  = "# Algorithme SORM\n"
948     txt += "%s = SORM ( NearestPointAlgorithm( %s ), %s, %s )\n"  % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"])
949     txt += "\n"
950
951     return txt
952
953   def RunAlgorithm (self):
954     '''
955     Do the computation
956     '''
957     if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ):
958       if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ):
959         txt  = "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"])
960         txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"])
961         txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"])
962         txt += "\n"
963
964     txt += "# Perform the computation\n"
965     txt += "%s.run()\n" % self.variable["myAlgo"]
966     txt += "\n"
967     
968
969     if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ):
970       if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ):
971         txt += "%s = %s.getEvaluationCallsNumber() - %s\n" % (self.variable["modelEvaluationCalls"], self.variable["model"], self.variable["modelEvaluationCalls"])
972         txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"])
973         txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"])
974         txt += "\n"
975         txt += "print '%s =', %s\n" % (self.variable["modelEvaluationCalls"], self.variable["modelEvaluationCalls"])
976         txt += "print '%s =', %s\n" % (self.variable["modelGradientCalls"], self.variable["modelGradientCalls"])
977         txt += "print '%s =', %s\n" % (self.variable["modelHessianCalls"], self.variable["modelHessianCalls"])
978         txt += "\n"
979
980     return txt
981
982   def Cobyla (self):
983     '''
984     Methode Cobyla
985     '''
986     txt  = "# Optimisation par Cobyla\n"
987     txt += "%s = Cobyla()\n" % self.variable["myOptimizer"]
988     txt += "#%s = CobylaSpecificParameters()\n" % self.variable["specificParameters"]
989     txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"])
990     txt += "\n"
991         
992     return txt
993
994   def AbdoRackwitz (self):
995     '''
996     Methode AbdoRackwitz
997     '''
998     txt  = "# Optimisation par AbdoRackwitz\n"
999     txt += "%s = AbdoRackwitz()\n" % self.variable["myOptimizer"]
1000     txt += "#%s = AbdoRackwitzSpecificParameters()\n" % self.variable["specificParameters"]
1001     txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"])
1002     txt += "\n"
1003     return txt
1004
1005   def Beta (self, loi, i, collection):
1006     '''
1007     Definition de la loi Beta
1008     '''
1009     settings = {
1010       "RT" : "Beta.RT",
1011       "MuSigma" : "Beta.MUSIGMA",
1012       }
1013     if loi[ 'Settings' ] == 'RT' :
1014       arg1 = loi[ 'R' ]
1015       arg2 = loi[ 'T' ]
1016     else :
1017       arg1 = loi[ 'Mu'    ]
1018       arg2 = loi[ 'Sigma' ]
1019       
1020     arg3 = loi[ 'A' ]
1021     arg4 = loi[ 'B' ]
1022     txt = "Beta( %g, %g, %g, %g, %s )" % (arg1, arg2, arg3, arg4, settings[ loi[ 'Settings' ] ])
1023     return txt
1024   
1025   def Exponential (self, loi, i, collection):
1026     '''
1027     Definition de la loi Exponential
1028     '''
1029     arg1 = loi[ 'Lambda' ]
1030     arg2 = loi[ 'Gamma'  ]
1031     txt = "Exponential( %g, %g )" % (arg1, arg2)
1032     return txt
1033   
1034   def Gamma (self, loi, i, collection):
1035     '''
1036     Definition de la loi Gamma
1037     '''
1038     settings = {
1039       "KLambda" : "Gamma.KLAMBDA",
1040       "MuSigma" : "Gamma.MUSIGMA",
1041     }
1042     if loi[ 'Settings' ] == 'KLambda' :
1043       arg1 = loi[ 'K'      ]
1044       arg2 = loi[ 'Lambda' ]
1045     else :
1046       arg1 = loi[ 'Mu'    ]
1047       arg2 = loi[ 'Sigma' ]
1048       
1049     arg3 = loi[ 'Gamma' ]
1050     txt = "Gamma( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1051     return txt
1052
1053   def Geometric (self, loi, i, collection):
1054     '''
1055     Definition de la loi Geometric
1056     '''
1057     txt = "Geometric( %g )" % loi[ 'P' ]
1058     return txt
1059
1060   def Gumbel (self, loi, i, collection):
1061     '''
1062     Definition de la loi Gumbel
1063     '''
1064     settings = {
1065       "AlphaBeta" : "Gamma.ALPHABETA",
1066       "MuSigma" : "Gamma.MUSIGMA",
1067     }
1068     if loi[ 'Settings' ] == 'AlphaBeta' :
1069       arg1 = loi[ 'Alpha' ]
1070       arg2 = loi[ 'Beta'  ]
1071     else :
1072       arg1 = loi[ 'Mu'    ]
1073       arg2 = loi[ 'Sigma' ]
1074       
1075     txt = "Gamma( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ])
1076     return txt
1077
1078   def Histogram (self, loi, i, collection):
1079     '''
1080     Definition de la loi Histogram
1081     '''
1082     arg1 = loi[ 'First' ]
1083     arg2 = loi[ 'Values'  ]
1084     txt = "Histogram( %g, %s )" % (arg1, arg2)
1085     return txt
1086
1087   def Logistic (self, loi, i, collection):
1088     '''
1089     Definition de la loi Logistic
1090     '''
1091     arg1 = loi[ 'Alpha' ]
1092     arg2 = loi[ 'Beta'  ]
1093     txt = "Logistic( %g, %g )" % (arg1, arg2)
1094     return txt
1095
1096   def LogNormal (self, loi, i, collection):
1097     '''
1098     Definition de la loi LogNormal
1099     '''
1100     settings = {
1101       "MuSigmaLog" : "LogNormal.MUSIGMA_LOG",
1102       "MuSigma" : "LogNormal.MUSIGMA",
1103       "MuSigmaOverMu" : "LogNormal.MU_SIGMAOVERMU",
1104     }
1105     if loi[ 'Settings' ] == 'MuSigmaLog' :
1106       arg1 = loi[ 'MuLog' ]
1107       arg2 = loi[ 'SigmaLog' ]
1108     elif loi[ 'Settings' ] == 'MuSigmaOverMu' :
1109       arg1 = loi[ 'Mu' ]
1110       arg2 = loi[ 'SigmaOverMu' ]
1111     else :
1112       arg1 = loi[ 'Mu'    ]
1113       arg2 = loi[ 'Sigma' ]
1114       
1115     arg3 = loi[ 'Gamma' ]
1116     txt = "LogNormal( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1117     return txt
1118
1119   def MultiNomial (self, loi, i, collection):
1120     '''
1121     Definition de la loi MultiNomial
1122     '''
1123     arg1 = loi[ 'Values' ]
1124     arg2 = loi[ 'N' ]
1125     txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2)
1126     return txt
1127
1128   def Normal (self, loi, i, collection):
1129     '''
1130     Definition de la loi Normal
1131     '''
1132     arg1 = loi[ 'Mu'    ]
1133     arg2 = loi[ 'Sigma' ]
1134     txt = "Normal( %g, %g )" % (arg1, arg2)
1135     return txt
1136
1137   def TruncatedNormal (self, loi, i, collection):
1138     '''
1139     Definition de la loi TruncatedNormal
1140     '''
1141     arg1 = loi[ 'MuN' ]
1142     arg2 = loi[ 'SigmaN' ]
1143     arg3 = loi[ 'A' ]
1144     arg4 = loi[ 'B' ]
1145     txt = "TruncatedNormal( %g, %g, %g, %g )" % (arg1, arg2, arg3, arg4)
1146     return txt
1147
1148   def Poisson (self, loi, i, collection):
1149     '''
1150     Definition de la loi 
1151     '''
1152     txt = "Poisson( %g )" % loi[ 'Lambda' ]
1153     return txt
1154
1155   def Student (self, loi, i, collection):
1156     '''
1157     Definition de la loi Student
1158     '''
1159     arg1 = loi[ 'Mu' ]
1160     arg2 = loi[ 'Nu' ]
1161     txt = "Student( %g, %g )" % (arg1, arg2)
1162     return txt
1163
1164   def Triangular (self, loi, i, collection):
1165     '''
1166     Definition de la loi Triangular
1167     '''
1168     arg1 = loi[ 'A' ]
1169     arg2 = loi[ 'M' ]
1170     arg3 = loi[ 'B' ]
1171     txt = "Triangular( %g, %g, %g )" % (arg1, arg2, arg3)
1172     return txt
1173
1174   def Uniform (self, loi, i, collection):
1175     '''
1176     Definition de la loi Uniform
1177     '''
1178     arg1 = loi[ 'A' ]
1179     arg2 = loi[ 'B' ]
1180     txt = "Uniform( %g, %g )" % (arg1, arg2)
1181     return txt
1182
1183   def UserDefined (self, loi, i, collection):
1184     '''
1185     Definition de la loi UserDefined
1186     '''
1187     txt = "** UserDefined not defined yet **"
1188     return txt
1189
1190   def Weibull (self, loi, i, collection):
1191     '''
1192     Definition de la loi Weibull
1193     '''
1194     settings = {
1195       "AlphaBeta" : "Weibull.ALPHABETA",
1196       "MuSigma" : "Weibull.MUSIGMA",
1197     }
1198     if loi[ 'Settings' ] == 'AlphaBeta' :
1199       arg1 = loi[ 'Alpha' ]
1200       arg2 = loi[ 'Beta'  ]
1201     else :
1202       arg1 = loi[ 'Mu'    ]
1203       arg2 = loi[ 'Sigma' ]
1204       
1205     arg3 = loi[ 'Gamma' ]
1206     txt = "Weibull( %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ])
1207     return txt
1208