From 26b012c03fcf1769e07d3283f8bcef82fd795836 Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Fri, 9 Jan 2009 09:57:55 +0000 Subject: [PATCH] *** empty log message *** --- Openturns_Study/OpenTURNS_Cata_Study_V3.py | 1598 ++++++++++++++++++++ Openturns_Study/catalogues_openturns.ini | 2 +- Openturns_Study/ops.py | 5 +- generator/OpenturnsBase.py | 5 +- generator/OpenturnsSTD.py | 671 +++++++- generator/OpenturnsXML.py | 17 +- generator/generator_openturns_study.py | 44 +- generator/generator_openturns_wrapper.py | 2 +- 8 files changed, 2290 insertions(+), 54 deletions(-) create mode 100644 Openturns_Study/OpenTURNS_Cata_Study_V3.py diff --git a/Openturns_Study/OpenTURNS_Cata_Study_V3.py b/Openturns_Study/OpenTURNS_Cata_Study_V3.py new file mode 100644 index 00000000..80dbe832 --- /dev/null +++ b/Openturns_Study/OpenTURNS_Cata_Study_V3.py @@ -0,0 +1,1598 @@ +# -*- coding: utf-8 -*- + +# -------------------------------------------------- +# debut entete +# -------------------------------------------------- + +from Accas import ASSD, JDC_CATA, AU_MOINS_UN, PROC, SIMP, FACT, OPER, MACRO, BLOC + +class loi ( ASSD ) : pass +class variable ( ASSD ) : pass + + +#CONTEXT.debug = 1 +JdC = JDC_CATA ( code = 'OPENTURNS_STUDY', + execmodul = None, + regles = ( AU_MOINS_UN ( 'CRITERIA' ), AU_MOINS_UN ( 'MODEL' ), ), + ) # Fin JDC_CATA + +# -------------------------------------------------- +# fin entete +# -------------------------------------------------- + +LOG = PROC ( nom = "LOG", + op = None, + docu = "", + + DebugMessages = SIMP ( statut = "o", + typ = "TXM", + into = ( 'yes', 'no' ), + defaut = 'no', + fr = "Affichage du niveau de debug de la bibliotheque Open TURNS", + ang = "Open TURNS library debug level print", + ), + + WrapperMessages = SIMP ( statut = "o", + typ = "TXM", + into = ( 'yes', 'no' ), + defaut = 'no', + fr = "Affichage du niveau de wrapper de la bibliotheque Open TURNS", + ang = "Open TURNS library debug level print", + ), + + UserMessages = SIMP ( statut = "o", + typ = "TXM", + into = ( 'yes', 'no' ), + defaut = 'no', + fr = "Affichage du niveau de user de la bibliotheque Open TURNS", + ang = "Open TURNS library user level print", + ), + + InfoMessages = SIMP ( statut = "o", + typ = "TXM", + into = ( 'yes', 'no' ), + defaut = 'yes', + fr = "Affichage du niveau de info de la bibliotheque Open TURNS", + ang = "Open TURNS library info level print", + ), + + WarningMessages = SIMP ( statut = "o", + typ = "TXM", + into = ( 'yes', 'no' ), + defaut = 'yes', + fr = "Affichage du niveau de warning de la bibliotheque Open TURNS", + ang = "Open TURNS library warning level print", + ), + + ErrorMessages = SIMP ( statut = "o", + typ = "TXM", + into = ( 'yes', 'no' ), + defaut = 'yes', + fr = "Affichage du niveau de error de la bibliotheque Open TURNS", + ang = "Open TURNS library error level print", + ), + +) # Fin PROC LOG + + + + +#================================ +# 0. Definition du modele physique +#================================ + + +DETERMINISTICVARIABLE = OPER ( nom = "DETERMINISTICVARIABLE", + sd_prod = variable, + op = None, + fr = "Variable deterministe", + ang = "Deterministic variable", + + N = SIMP ( statut = 'o', + typ = "TXM", + fr = "Nom", + ang = "Name", + ), + + T = SIMP ( statut = 'o', + defaut = "in", + into = ( "in" , "out", ), + typ = "TXM", + fr = "Type", + ang = "Type", + ), + + R = SIMP ( statut = 'o', + defaut = 0, + typ = "I", + fr = "Rang", + ang = "Rank", + ), + +) # Fin OPER DETERMINISTICVARIABLE + + + +import ops +MODEL = MACRO ( nom = "MODEL", + op = None, + UIinfo = { "groupes" : ( "Gestion du travail", ) }, + fr = "Chargement du wrapper du modele physique", + ang = "Physical model wrapper load", + sd_prod = ops.INCLUDE, + op_init = ops.INCLUDE_context, + fichier_ini = 1, + + FileName = SIMP ( statut = "o", + typ = "TXM", + fr = "Nom du modele physique", + ang = "Physical model identifier", + ), + +) # Fin PROC MODEL + + + + +VARIABLE = PROC ( nom = "VARIABLE", + op = None, + docu = "", + fr = "Variable probabiliste", + ang = "Probabilistic variable", + + ModelVariable = SIMP ( statut = "o", + typ = ( variable, ), + ), + + Distribution = SIMP ( statut = "o", + typ = ( loi, ), + ), + +) # Fin PROC VARIABLE + + + + +#================================ +# 1. Definition des LOIS +#================================ + +# Nota : les variables de type OPER doivent etre en majuscules ! +# Nota : les variables de type OPER doivent etre de premier niveau (pas imbriquees dans un autre type) +DISTRIBUTION = OPER ( nom = "DISTRIBUTION", + sd_prod = loi, + op = 68, + fr = "Definitions des lois marginales utilisees par les variables d'entree", + + +#==== +# Type de distribution +#==== + + Kind = SIMP ( statut = "o", typ = "TXM", + into = ( "Beta", + "Exponential", + "Gamma", + "Geometric", + "Gumbel", + "Histogram", + "Logistic", + "LogNormal", + "MultiNomial", + "Normal", + "TruncatedNormal", + "Poisson", + "Student", + "Triangular", + "Uniform", + "UserDefined", + "Weibull", + ), + fr = "Choix du type de la loi marginale", + ang = "1D marginal distribution", + ), + +#==== +# Definition des parametres selon le type de la loi +#==== + + BETA = BLOC ( condition = " Kind in ( 'Beta', ) ", + + Settings = SIMP ( statut = "o", + typ = "TXM", + max = 1, + into = ( "RT", "MuSigma" ), + defaut = "RT", + fr = "Parametrage de la loi beta", + ang = "Beta distribution parameter set", + ), + + RT_Parameters = BLOC ( condition = " Settings in ( 'RT', ) ", + + R = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre R de la loi", + ang = "R parameter", + ), + + # T > R + T = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre T de la loi | T > R", + ang = "T parameter | T > R", + ), + + ), # Fin BLOC RT_Parameters + + + MuSigma_Parameters = BLOC ( condition = " Settings in ( 'MuSigma', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + Sigma = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Sigma de la loi | Sigma > 0", + ang = "Sigma parameter | Sigma > 0", + ), + + ), # Fin BLOC MuSigma_Parameters + + + A = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre A de la loi", + ang = "A parameter", + ), + + # B > A + B = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre B de la loi | B > A", + ang = "B parameter | B > A", + ), + + ), # Fin BLOC BETA + + + + EXPONENTIAL = BLOC ( condition = " Kind in ( 'Exponential', ) ", + + Lambda = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Lambda | Lambda > 0", + ang = "Lambda parameter | Lambda > 0", + ), + + Gamma = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Gamma", + ang = "Gamma parameter", + ), + + ), # Fin BLOC EXPONENTIAL + + + + GAMMA = BLOC ( condition = " Kind in ( 'Gamma', ) ", + + Settings = SIMP ( statut = "o", + typ = "TXM", + max = 1, + into = ( "KLambda", "MuSigma" ), + defaut = "KLambda", + fr = "Parametrage de la loi gamma", + ang = "Gamma distribution parameter set", + ), + + KLambda_Parameters = BLOC ( condition = " Settings in ( 'KLambda', ) ", + + K = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre K de la loi | K > 0", + ang = "K parameter | K > 0", + ), + + Lambda = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Lambda de la loi | Lambda > 0", + ang = "Lambda parameter | Lambda > 0", + ), + + ), # Fin BLOC KLambda_Parameters + + + MuSigma_Parameters = BLOC ( condition = " Settings in ( 'MuSigma', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + defaut = 0.0, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + Sigma = SIMP ( statut = "o", + typ = "R", + max = 1, + defaut = 1.0, + val_min = 0., + fr = "Parametre Sigma de la loi | Sigma > 0", + ang = "Sigma parameter | Sigma > 0", + ), + + ), # Fin BLOC MuSigma_Parameters + + Gamma = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Gamma", + ang = "Gamma parameter", + ), + + + ), # Fin BLOC GAMMA + + + + GEOMETRIC = BLOC ( condition = " Kind in ( 'Geometric', ) ", + + P = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + val_max = 1., + fr = "Parametre P | 0 < P < 1", + ang = "P parameter | 0 < P < 1", + ), + + ), # Fin BLOC GEOMETRIC + + + + GUMBEL = BLOC ( condition = " Kind in ( 'Gumbel', ) ", + + Settings = SIMP ( statut = "o", + typ = "TXM", + max = 1, + into = ( "AlphaBeta", "MuSigma" ), + defaut = "AlphaBeta", + fr = "Parametrage de la loi gumbel", + ang = "Gumbel distribution parameter set", + ), + + AlphaBeta_Parameters = BLOC ( condition = " Settings in ( 'AlphaBeta', ) ", + + Alpha = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Alpha de la loi | Alpha > 0", + ang = "Alpha parameter | Alpha > 0", + ), + + Beta = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Beta de la loi", + ang = "Beta parameter", + ), + + ), # Fin BLOC AlphaBeta_Parameters + + + MuSigma_Parameters = BLOC ( condition = " Settings in ( 'MuSigma', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + Sigma = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Sigma de la loi | Sigma > 0", + ang = "Sigma parameter | Sigma > 0", + ), + + ), # Fin BLOC MuSigma_Parameters + + ), # Fin BLOC GUMBEL + + + + HISTOGRAM = BLOC ( condition = " Kind in ( 'Histogram', ) ", + + Sup = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne superieure de la distribution", + ang = "Upper bound", + ), + + # Il faut definir une collection de couples ( x,p ) + Values = SIMP ( statut = 'o', + typ = 'R', + max = '**', + ), + + ), # Fin BLOC HISTOGRAM + + + + LOGNORMAL = BLOC ( condition = " Kind in ( 'LogNormal', ) ", + + Settings = SIMP ( statut = "o", + typ = "TXM", + max = 1, + into = ( "MuSigmaLog", "MuSigma", "MuSigmaOverMu" ), + defaut = "MuSigmaLog", + fr = "Parametrage de la loi lognormale", + ang = "Lognormal distribution parameter set", + ), + + MuSigma_Parameters = BLOC ( condition = " Settings in ( 'MuSigma', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi | Mu > Gamma", + ang = "Mu parameter | Mu > Gamma", + ), + + Sigma = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Sigma de la loi | Sigma > 0", + ang = "Sigma parameter | Sigma > 0", + ), + + ), # Fin BLOC MuSigma_Parameters + + MuSigmaOverMu_Parameters = BLOC ( condition = " Settings in ( 'MuSigmaOverMu', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi | Mu > Gamma", + ang = "Mu parameter | Mu > Gamma", + ), + + SigmaOverMu = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre SigmaOverMu de la loi | SigmaOverMu > 0", + ang = "SigmaOverMu parameter | SigmaOverMu > 0", + ), + + ), # Fin BLOC MuSigmaOverMu_Parameters + + MuSigmaLog_Parameters = BLOC ( condition = " Settings in ( 'MuSigmaLog', ) ", + + MuLog = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu log de la loi", + ang = "Mu log parameter", + ), + + SigmaLog = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Sigma log de la loi | SigmaLog > 0", + ang = "Sigma log parameter | SigmaLog > 0", + ), + + ), # Fin BLOC MuSigmaLog_Parameters + + Gamma = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Gamma", + ang = "Gamma parameter", + ), + + ), # Fin BLOC LOGNORMAL + + + + LOGISTIC = BLOC ( condition = " Kind in ( 'Logistic', ) ", + + Alpha = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Alpha de la loi", + ang = "Alpha parameter", + ), + + Beta = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Beta de la loi | Beta > = 0", + ang = "Beta parameter | Beta > = 0", + ), + + ), # Fin BLOC LOGISTIC + + + + MULTINOMIAL = BLOC ( condition = " Kind in ( 'MultiNomial', ) ", + + N = SIMP ( statut = "o", + typ = "I", + max = 1, + fr = "Dimension de la loi", + ang = "Distribution dimension", + ), + + # Il faut un vecteur P de taille N + Values = SIMP ( statut = 'o', + typ = 'R', + max = '**', + ), + + ), # Fin BLOC MULTINOMIAL + + + + NORMAL = BLOC ( condition = " Kind in ( 'Normal', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + Sigma = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Sigma de la loi | Sigma > 0", + ang = "Sigma parameter | Sigma > 0", + ), + + ), # Fin BLOC NORMAL + + + + POISSON = BLOC ( condition = " Kind in ( 'Poisson', ) ", + + Lambda = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Lambda de la loi | Lambda > 0", + ang = "Lambda parameter | Lambda > 0", + ), + + ), # Fin BLOC POISSON + + + + STUDENT = BLOC ( condition = " Kind in ( 'Student', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + Nu = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 2., + fr = "Parametre Nu de la loi | V > = 2", + ang = "Nu parameter | V > = 2", + ), + + ), # Fin BLOC STUDENT + + + + TRIANGULAR = BLOC ( condition = " Kind in ( 'Triangular', ) ", + + A = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne inferieure de la loi | A < = M < = B", + ang = "Lower bound | A < = M < = B", + ), + + M = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Mode de la loi | A < = M < = B", + ang = "Mode | A < = M < = B", + ), + + B = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne superieure de la loi | A < = M < = B", + ang = "Upper bound | A < = M < = B", + ), + + ), # Fin BLOC TRIANGULAR + + + + TRUNCATEDNORMAL = BLOC ( condition = " Kind in ( 'TruncatedNormal', ) ", + + MuN = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + SigmaN = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre SigmaN de la loi | SigmaN > 0", + ang = "SigmaN parameter | SigmaN> 0", + ), + + A = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne inferieure de la loi | A < = B", + ang = "Lower bound | A < = B", + ), + + B = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne superieure de la loi | A < = B", + ang = "Upper bound | A < = B", + ), + + ), # Fin BLOC TRUNCATEDNORMAL + + + + UNIFORM = BLOC ( condition = " Kind in ( 'Uniform', ) ", + + A = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne inferieure de la loi | A < = B", + ang = "Lower bound | A < = B", + ), + + B = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Borne superieure de la loi | A < = B", + ang = "Upper bound | A < = B", + ), + + ), # Fin BLOC UNIFORM + + + + USERDEFINED = BLOC ( condition = " Kind in ( 'UserDefined', ) ", + + # Il faut definir une collection de couples ( x,p ) + Values = SIMP ( statut = 'o', + typ = 'R', + max = '**', + ), + + ), # Fin BLOC USERDEFINED + + + + WEIBULL = BLOC ( condition = " Kind in ( 'Weibull', ) ", + + Settings = SIMP ( statut = "o", + typ = "TXM", + max = 1, + into = ( "AlphaBeta", "MuSigma" ), + defaut = "AlphaBeta", + fr = "Parametrage de la loi weibull", + ang = "Weibull distribution parameter set", + ), + + AlphaBeta_Parameters = BLOC ( condition = " Settings in ( 'AlphaBeta', ) ", + + Alpha = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Alpha de la loi | Alpha > 0", + ang = "Alpha parameter | Alpha > 0", + ), + + Beta = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Beta de la loi | Beta > 0", + ang = "Beta parameter | Beta > 0", + ), + + ), # Fin BLOC AlphaBeta_Parameters + + + MuSigma_Parameters = BLOC ( condition = " Settings in ( 'MuSigma', ) ", + + Mu = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Mu de la loi", + ang = "Mu parameter", + ), + + Sigma = SIMP ( statut = "o", + typ = "R", + max = 1, + val_min = 0., + fr = "Parametre Sigma de la loi | Sigma > 0", + ang = "Sigma parameter | Sigma > 0", + ), + + ), # Fin BLOC MuSigma_Parameters + + Gamma = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Parametre Gamma", + ang = "Gamma parameter", + ), + + ), # Fin BLOC WEIBULL + +) # Fin OPER DISTRIBUTION + + + + + + + +#================================ +# 3. Definition de l'etude +#================================ + +# Nota : les variables de type PROC doivent etre en majuscules ! +CRITERIA = PROC ( nom = "CRITERIA", + op = None, + docu = "", + fr = "Mise en donnee pour le fichier de configuration de OPENTURNS.", + ang = "Writes the configuration file for OPENTURNS.", + + + + Type = SIMP ( statut = "o", + typ = "TXM", + into = ( "Min/Max", "Central Uncertainty", "Threshold Exceedence" ), + fr = "Type d'Analyse", + ang = "Analysis", + ), + + + + + + + + MinMax = BLOC ( condition = " Type in ( 'Min/Max', ) ", + + Method = SIMP ( statut = "o", + typ = "TXM", + into = ( "Experiment Plane", "Random Sampling" ), + fr = "Methode", + ang = "Method", + ), + # UC 3.1.1 + ExperimentPlaneSettings = BLOC ( condition = " Method in ( 'Experiment Plane', ) ", + + ExperimentPlane = SIMP ( statut = "o", + typ = "TXM", + into = ( "Axial", "Factorial", "Composite", ), + fr = "Methode", + ang = "Method", + ), + + Levels = SIMP ( statut = "o", + typ = "R", + val_min = 0.0, + max = '**', + fr = "Nombre de niveaux dans chaque direction", + ang = "Levels in each direction", + ), + + # Scaled Vector + UnitsPerDimension = SIMP ( statut = "o", + typ = "R", + max = '**', + fr = "Unite par dimension (autant que de variables declarees)", + ang = "Units per dimension (as much as declared variables)", + ), + + # Translation Vector + Center = SIMP ( statut = "o", + typ = "R", + max = '**', + fr = "Unite par dimension", + ang = "Units per dimension", + ), + + ), # Fin BLOC ExperimentPlaneSettings + + + + RandomSamplingSettings = BLOC ( condition = " Method in ( 'Random Sampling', ) ", + + PointsNumber = SIMP ( statut = "o", + typ = "I", + val_min = 1, + fr = "Nombre de points", + ang = "Points number", + ), + + ), # Fin BLOC RandomSamplingSettings + + Result = SIMP ( statut = "o", + typ = "TXM", + into = ( "Min/Max", ), + defaut = "Min/Max", + fr = "Le minimum et le maximum", + ang = "The min and max values", + ), + + + ), # Fin BLOC MinMax + + + + + CentralUncertainty = BLOC ( condition = " Type in ( 'Central Uncertainty', ) ", + + Method = SIMP ( statut = "o", + typ = "TXM", + into = ( "Taylor Variance Decomposition", "Random Sampling" ), + fr = "Methode", + ang = "Method", + ), + + # UC 3.2. + TaylorVarianceDecompositionSettings = BLOC ( condition = " Method in ( 'Taylor Variance Decomposition', ) ", + + Result = FACT ( statut = "o", + min = 1, + max = "**", + + MeanFirstOrder = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Moyenne au premier ordre", + ang = "MeanFirstOrder", + ), + + StandardDeviationFirstOrder = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Ecart-type au premier ordre", + ang = "StandardDeviationFirstOrder", + ), + + MeanSecondOrder = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Moyenne au second ordre", + ang = "MeanSecondOrder", + ), + + ImportanceFactor = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Facteur d'importance pour variable de sortie scalaire", + ang = "ImportanceFactor", + ), + + ImportanceFactorSettings = BLOC ( condition = " ImportanceFactor in ( 'yes', ) ", + + NumericalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Resultats numeriques", + ang = "NumericalResults", + ), + + GraphicalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Resultats graphiques", + ang = "GraphicalResults", + ), + + ), # Fin BLOC ImportanceFactorSettings + + ), # Fin FACT Result + + ), # Fin BLOC TaylorVarianceDecompositionSettings + + + + RandomSamplingSettings = BLOC ( condition = " Method in ( 'Random Sampling', ) ", + + PointsNumber = SIMP ( statut = "o", + typ = "I", + val_min = 1, + fr = "Nombre de points", + ang = "Points number", + ), + + Result = FACT ( statut = "o", + min = 1, + max = "**", + + EmpiricalMean = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Moyenne empirique", + ang = "Empirical mean", + ), + + EmpiricalStandardDeviation = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Ecart-type empirique", + ang = "Empirical standard deviation", + ), + + EmpiricalQuantile = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Quantile empirique", + ang = "Empirical quantile", + ), + + EmpiricalQuantileSettings = BLOC ( condition = " EmpiricalQuantile in ( 'yes', ) ", + + EmpiricalQuantile_Order = SIMP ( statut = "o", + typ = 'R', + defaut = 0.95, + max = 1, + val_min = 0.0, + val_max = 1.0, + fr = "Ordre du quantile empirique", + ang = "Empirical quantile order", + ), + + ), # Fin BLOC EmpiricalQuantileSettings + + AnalysedCorrelations = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Correlations analysees", + ang = "Analysed correlations", + ), + + KernelSmoothing = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Kernel smoothing de l'echantillon", + ang = "Kernel smoothing of the sample", + ), + + ), # Fin FACT Result + + ), # Fin BLOC RandomSamplingSettings + + ), # Fin BLOC CentralUncertainty + + + + + ThresholdExceedence = BLOC ( condition = " Type in ( 'Threshold Exceedence', ) ", + + Event = FACT ( statut = "o", + min = 1, + max = 1, + + Threshold = SIMP ( statut = "o", + typ = "R", + max = 1, + fr = "Le seuil de defaillance", + ang = "Failure threshold", + ), + + ComparisonOperator = SIMP ( statut = "o", + typ = "TXM", + max = 1, + into = ( "Less", "LessOrEqual", "Equal", "GreaterOrEqual", "Greater" ), + fr = "Que faut-il ne pas depasser : un maximum ou un minimum", + ang = "What is the failure threshold : maximum or minimum", + ), + ), # Fin FACT Event + + + Method = SIMP ( statut = "o", + typ = "TXM", + into = ( "Simulation", "Analytical" ), + fr = "Methode", + ang = "Method", + ), + + SimulationSettings = BLOC ( condition = " Method in ( 'Simulation', ) ", + + Algorithm = SIMP ( statut = "o", + typ = "TXM", + into = ( "MonteCarlo", "LHS", "ImportanceSampling" ), + fr = "Algorithme de simulation", + ang = "Simulation algorithm", + ), + + + RandomGenerator = FACT ( statut = "o", + min = 1, + max = 1, + + SeedToBeSet = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "La racine du generateur aleatoire doit-elle etre positionnee ?", + ang = "Does the random generator seed need to be set ?", + ), + + SeedSettings = BLOC ( condition = " SeedToBeSet in ( 'yes', ) ", + + RandomGeneratorSeed = SIMP ( statut = "o", + typ = "I", + max = 1, + fr = "Racine du generateur aleatoire", + ang = "Random generator seed", + ), + + ), # Fin BLOC SeedSettings + + ), # Fin FACT RandomGenerator + + + BlockSize = SIMP ( statut = "f", + typ = "I", + max = 1, + val_min = 1, + defaut = 1, + fr = "Nombre de calculs realises en bloc", + ang = "Number of computations as a block", + ), + + MaximumOuterSampling = SIMP ( statut = "o", + typ = "I", + max = 1, + val_min = 1, + fr = "Maximum d'iterations externes", + ang = "Maximum outer Sampling value", + ), + + MaximumCoefficientOfVariation = SIMP ( statut = "f", + typ = "R", + max = 1, + defaut = 0.1, + val_min = 0.0, + fr = " maximum ...", + ang = "Absolute maximum ...." + ), + + ImportanceSamplingSettings = BLOC ( condition = " Algorithm in ( 'ImportanceSampling', ) ", + + MeanVector = SIMP ( statut = "o", + typ = "R", + max = "**", + fr = "Moyenne", + ang = "Mean vector", + ), + + Correlation = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'Independent', 'Linear' ), + defaut = 'Linear', + max = 1, + fr = "Le type de correlation entre les variables", + ang = "Correlation between variables", + ), + + ), # Fin BLOC ImportanceSamplingSettings + + Result = FACT ( statut = "o", + min = 1, + max = "**", + + Probability = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', ), + defaut = 'yes', + max = 1, + fr = "Probabiblite", + ang = "Probability", + ), + + StandardDeviation = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', ), + defaut = 'yes', + max = 1, + fr = "Ecart type", + ang = "Standard deviation", + ), + + ConfidenceInterval = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Ecart-type empirique", + ang = "Empirical standard deviation", + ), + + ConfidenceIntervalSettings = BLOC ( condition = " ConfidenceInterval in ( 'yes', ) ", + + Level = SIMP ( statut = "o", + typ = 'R', + defaut = 0.9, + max = 1, + val_min = 0.0, + val_max = 1.0, + fr = "Niveau de confiance", + ang = "Confidence level", + ), + + ), # Fin BLOC ConfidenceIntervalSettings + + VariationCoefficient = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Coefficient de variation", + ang = "VariationCoefficient", + ), + + IterationNumber = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Nombre d'iterations", + ang = "Iteration number", + ), + + ConvergenceGraph = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Graphe de convergence", + ang = "Convergence graph", + ), + + ), # Fin FACT Result + + + + ), # Fin BLOC SimulationSettings + + + + AnalyticalSettings = BLOC ( condition = " Method in ( 'Analytical', ) ", + + Approximation = SIMP ( statut = "o", + typ = "TXM", + defaut = "FirstOrder", + into = ( "FirstOrder", "SecondOrder" ), + max = 1, + fr = "Approximation", + ang = "Approximation", + ), + + OptimizationAlgorithm = SIMP ( statut = "o", + typ = "TXM", + defaut = "Cobyla", + into = ( "Cobyla", "AbdoRackwitz" ), + max = 1, + fr = "Methode d'optimisation", + ang = "Optimisation method", + ), + + + PhysicalStartingPoint = SIMP ( statut = "f", + typ = "R", + max = "**", + fr = "Point de demarrage de l'algorithme iteratif", + ang = "Initial point for iterative process", + ), + + MaximumIterationsNumber = SIMP ( statut = "f", + typ = "I", + max = 1, + val_min = 1, + fr = "Nombre maximum d iterations", + ang = "Maximum number of iterations", + ), + + + MaximumAbsoluteError = SIMP ( statut = "f", + typ = "R", + max = 1, + defaut = 1E-4, + val_min = 0.0, + fr = "Distance maximum absolue entre 2 iterations successifs", + ang = "Absolute maximum distance between 2 successive iterates", + ), + + MaximumRelativeError = SIMP ( statut = "f", + typ = "R", + max = 1, + defaut = 1E-4, + val_min = 0.0, + fr = "Distance maximum relative entre 2 iterations successives", + ang = "Relative maximum distance between 2 successive iterates", + ), + + MaximumConstraintError = SIMP ( statut = "f", + typ = "R", + max = 1, + defaut = 1E-4, + val_min = 0.0, + fr = "Valeur maximum absolue de la fonction moins la valeur du niveau", + ang = "Maximum absolute value of the constraint function minus the level value", + ), + + ImportanceSampling = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Tirage d'importance au point de conception", + ang = "Importance sampling at design point", + ), + + FirstOrder = BLOC ( condition = " Approximation in ( 'FirstOrder', ) ", + + Probability = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', ), + defaut = 'yes', + max = 1, + fr = "Probabiblite", + ang = "Probability", + ), + + DesignPoint = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Point de conception", + ang = "Design point", + ), + + HasoferReliabilityIndex = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Indice de fiabilite", + ang = "Reliability index", + ), + + ImportanceFactor = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Facteur d'importance pour variable de sortie scalaire", + ang = "ImportanceFactor", + ), + + ImportanceFactorSettings = BLOC ( condition = " ImportanceFactor in ( 'yes', ) ", + + ImportanceFactorNumericalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Resultats numeriques", + ang = "NumericalResults", + ), + + ImportanceFactorGraphicalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Resultats graphiques", + ang = "GraphicalResults", + ), + + ), # Fin BLOC ImportanceFactorSettings + + + SensitivityAnalysis = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Analyse de sensibilite", + ang = "Sensitivity analysis", + ), + + SensitivityAnalysisSettings = BLOC ( condition = " SensitivityAnalysis in ( 'yes', ) ", + + FORMEventProbabilitySensitivity = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Indice de fiabilite de Hasofer", + ang = "Hasofer reliability index", + ), + + FORMEventProbabilitySensitivitySettings = BLOC ( condition = " FORMEventProbabilitySensitivity in ( 'yes', ) ", + + FORMEventProbabilitySensitivityNumericalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Resultats numeriques", + ang = "NumericalResults", + ), + + FORMEventProbabilitySensitivityGraphicalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Resultats graphiques", + ang = "GraphicalResults", + ), + + ), # Fin BLOC FORMEventProbabilitySensitivitySettings + + HasoferReliabilityIndexSensitivity = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Indice de fiabilite de Hasofer", + ang = "Hasofer reliability index", + ), + + HasoferReliabilityIndexSensitivitySettings = BLOC ( condition = " HasoferReliabilityIndexSensitivity in ( 'yes', ) ", + + HasoferReliabilityIndexSensitivityNumericalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Resultats numeriques", + ang = "NumericalResults", + ), + + HasoferReliabilityIndexSensitivityGraphicalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Resultats graphiques", + ang = "GraphicalResults", + ), + + ), # Fin BLOC HasoferReliabilityIndexSettings + + ), # Fin BLOC SensitivityAnalysisSettings + + FunctionCallsNumber = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Nombre d'appels a la fonction", + ang = "Function calls number", + ), + + + ), # Fin BLOC FirstOrder + + + SecondOrder = BLOC ( condition = " Approximation in ( 'SecondOrder', ) ", + + + TvedtApproximation = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Approximation de Tvedt", + ang = "Tvedt approximation", + ), + + HohenBichlerApproximation = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Approximation de HohenBichler", + ang = "HohenBichler approximation", + ), + + BreitungApproximation = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Approximation de Breitung", + ang = "Breitung approximation", + ), + + DesignPoint = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Point de conception", + ang = "Design point", + ), + + ImportanceFactor = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Facteur d'importance pour variable de sortie scalaire", + ang = "ImportanceFactor", + ), + + ImportanceFactorSettings = BLOC ( condition = " ImportanceFactor in ( 'yes', ) ", + + ImportanceFactorNumericalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Resultats numeriques", + ang = "NumericalResults", + ), + + ImportanceFactorGraphicalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Resultats graphiques", + ang = "GraphicalResults", + ), + + ), # Fin BLOC ImportanceFactorSettings + + SensitivityAnalysis = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Analyse de sensibilite", + ang = "Sensitivity analysis", + ), + + SensitivityAnalysisSettings = BLOC ( condition = " SensitivityAnalysis in ( 'yes', ) ", + + HasoferReliabilityIndexSensitivity = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Indice de fiabilite de Hasofer", + ang = "Hasofer reliability index", + ), + + HasoferReliabilityIndexSensitivitySettings = BLOC ( condition = " HasoferReliabilityIndexSensitivity in ( 'yes', ) ", + + HasoferReliabilityIndexSensitivityNumericalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'yes', + max = 1, + fr = "Resultats numeriques", + ang = "NumericalResults", + ), + + HasoferReliabilityIndexSensitivityGraphicalResults = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Resultats graphiques", + ang = "GraphicalResults", + ), + + ), # Fin BLOC HasoferReliabilityIndexSettings + + ), # Fin BLOC SensitivityAnalysisSettings + + FunctionCallsNumber = SIMP ( statut = "o", + typ = 'TXM', + into = ( 'yes', 'no' ), + defaut = 'no', + max = 1, + fr = "Nombre d'appels a la fonction", + ang = "Function calls number", + ), + + + ), # Fin BLOC SecondOrder + + + + ), # Fin BLOC AnalyticalSettings + + + + ), # Fin BLOC ThresholdExceedence + + + +) # Fin PROC CRITERIA + + + + + + + diff --git a/Openturns_Study/catalogues_openturns.ini b/Openturns_Study/catalogues_openturns.ini index 511e50a2..7cd5b3c1 100644 --- a/Openturns_Study/catalogues_openturns.ini +++ b/Openturns_Study/catalogues_openturns.ini @@ -6,7 +6,7 @@ rep_cata=os.getcwd() catalogues = ( # (code,version,catalogue,formatIn,formatOut) #('OPENTURNS_WRAPPER','V1',os.path.join(rep_cata,'OpenTURNS_Cata_Wrapper_V1.py'),'openturns_wrapper','wrapper'), - ('OPENTURNS_STUDY','V2',os.path.join(rep_cata,'OpenTURNS_Cata_Study_V2.py'),'openturns_study','wrapper'), + ('OPENTURNS_STUDY','V3',os.path.join(rep_cata,'OpenTURNS_Cata_Study_V3.py'),'openturns_study','wrapper'), #('OPENTURNS','Wrapper',os.path.join(rep_cata,'OpenTURNS_Cata_Wrapper_V1.py'),'openturns'), ) diff --git a/Openturns_Study/ops.py b/Openturns_Study/ops.py index a470d99e..28db9a95 100644 --- a/Openturns_Study/ops.py +++ b/Openturns_Study/ops.py @@ -1,6 +1,6 @@ # -*- coding: iso-8859-1 -*- -def INCLUDE(self,FICHIER,**args): +def INCLUDE(self,FileName,**args): """ Fonction sd_prod pour la macro INCLUDE """ @@ -8,13 +8,14 @@ def INCLUDE(self,FICHIER,**args): delattr(self,'change_fichier') delattr(self,'fichier_ini') - self.make_include2(fichier=FICHIER) + self.make_include2(fichier=FileName) def INCLUDE_context(self,d): """ Fonction op_init pour macro INCLUDE """ for k,v in self.g_context.items(): + print "IDM: ops.py k=%s v=%s" % (k,v) d[k]=v diff --git a/generator/OpenturnsBase.py b/generator/OpenturnsBase.py index da8da81f..2b9d900c 100644 --- a/generator/OpenturnsBase.py +++ b/generator/OpenturnsBase.py @@ -30,11 +30,12 @@ class Generateur : ListeVariables : chaque variable est decrite par un dictionnaire ; cette liste les regroupe DictLois : dictionnaires des lois ''' - def __init__ (self, appli, DictMCVal, ListeVariables, DictLois ) : + def __init__ (self, appli, DictMCVal = {}, ListeVariables = [], DictLois = {}, DictVariables = {} ) : #---------------------------------------------------------# self.ListeVariables = ListeVariables self.ListeVariablesIn = [] self.DictLois = DictLois + self.DictVariables = DictVariables self.DictMCVal = DictMCVal self.DictTypeVar = {} self.nbVarIn = 0 @@ -72,7 +73,7 @@ class Generateur : monXMLGenerateur=gener( self.DictMCVal, self.ListeVariables, self.DictLois ) except : from OpenturnsXML import XMLGenerateur - monXMLGenerateur = XMLGenerateur( self.appli, self.DictMCVal, self.ListeVariables, self.DictLois ) + monXMLGenerateur = XMLGenerateur( self.appli, self.DictMCVal, self.DictVariables ) return monXMLGenerateur def creeInfoVar (self) : diff --git a/generator/OpenturnsSTD.py b/generator/OpenturnsSTD.py index dba6a227..09f6945c 100644 --- a/generator/OpenturnsSTD.py +++ b/generator/OpenturnsSTD.py @@ -27,15 +27,19 @@ headerSTD = """#! /usr/bin/env python import sys sys.path.append( '%s' ) +# Chargement du module math +import math + # Chargement du module Open TURNS from openturns import * +from openturns_viewer import ViewImage,StopViewer,WaitForViewer """ footerSTD = """ # Terminaison du fichier -sys.exit( 0 ) +#sys.exit( 0 ) """ #============================================= @@ -59,11 +63,31 @@ class STDGenerateur : # Ce dictionnaire fait la correspondance entre le mot lu dans le dictionnaire des mots-clefs et la methode a appeler self.traitement = { - "Min/Max" : "MinMax", - "Central Uncertainty" : "CentralUncertainty", - "Threshold Exceedence" : "ThresholdExceedence", - "Experiment Plane" : "ExperimentPlane", - "Random Sampling" : "RandomSampling", + "Min/Max" : + ( "MinMax", + { "Experiment Plane" : "ExperimentPlane", + "Random Sampling" : "MinMaxRandomSampling", + }, + ), + "Central Uncertainty" : + ( "CentralUncertainty", + { "Taylor Variance Decomposition" : "TaylorVarianceDecomposition", + "Random Sampling" : "CentralUncertaintyRandomSampling", + }, + ), + "Threshold Exceedence" : + ( "ThresholdExceedence", + { "Simulation" : "Simulation", + "Analytical" : "Analytical", + "MonteCarlo" : "MonteCarlo", + "LHS" : "LHS", + "ImportanceSampling" : "ImportanceSampling", + "FirstOrder" : "FORM", + "SecondOrder" : "SORM", + "Cobyla" : "Cobyla", + "AbdoRackwitz" : "AbdoRackwitz", + }, + ), } # Ce dictionnaire liste le nom des variables utilisees dans le script @@ -91,6 +115,51 @@ class STDGenerateur : "copula" : "copula", "inputRandomVector" : "inputRandomVector", "outputRandomVector" : "outputRandomVector", + "myQuadraticCumul" : "myQuadraticCumul", + "meanFirstOrder" : "meanFirstOrder", + "meanSecondOrder" : "meanSecondOrder", + "standardDeviationFirstOrder" : "standardDeviationFirstOrder", + "importanceFactors" : "importanceFactors", + "importanceFactorsGraph" : "importanceFactorsGraph", + "importanceFactorsDrawing" : "importanceFactorsDrawing", + "empiricalMean" : "empiricalMean", + "empiricalStandardDeviation" : "empiricalStandardDeviation", + "empiricalQuantile" : "empiricalQuantile", + "alpha" : "alpha", + "beta" : "beta", + "PCCcoefficient" : "PCCcoefficient", + "PRCCcoefficient" : "PRCCcoefficient", + "SRCcoefficient" : "SRCcoefficient", + "SRRCcoefficient" : "SRRCcoefficient", + "kernel" : "kernel", + "kernelSmoothedDist" : "kernelSmoothedDist", + "kernelSmoothedPDF" : "kernelSmoothedPDF", + "myEvent" : "myEvent", + "myAlgo" : "myAlgo", + "myResult" : "myResult", + "probability" : "probability", + "standardDeviation" : "standardDeviation", + "level" : "level", + "length" : "length", + "coefficientOfVariation" : "coefficientOfVariation", + "convergenceGraph" : "convergenceGraph", + "iterations" : "iterations", + "myOptimizer" : "myOptimizer", + "specificParameters" : "specificParameters", + "startingPoint" : "startingPoint", + "hasoferReliabilityIndex" : "hasoferReliabilityIndex", + "standardSpaceDesignPoint" : "standardSpaceDesignPoint", + "physicalSpaceDesignPoint" : "physicalSpaceDesignPoint", + "eventProbabilitySensitivity" : "eventProbabilitySensitivity", + "hasoferReliabilityIndexSensitivity" : "hasoferReliabilityIndexSensitivity", + "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph", + "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph", + "modelEvaluationCalls" : "modelEvaluationCalls", + "modelGradientCalls" : "modelGradientCalls", + "modelHessianCalls" : "modelHessianCalls", + "tvedtApproximation" : "tvedtApproximation", + "hohenBichlerApproximation" : "hohenBichlerApproximation", + "breitungApproximation" : "breitungApproximation", } # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque @@ -112,11 +181,12 @@ class STDGenerateur : TypeAnalyse = self.DictMCVal[ 'Type' ] Traitement = None + subDict = {} if ( self.traitement.has_key( TypeAnalyse ) ): - Traitement = self.traitement[ TypeAnalyse ] + (Traitement, subDict) = self.traitement[ TypeAnalyse ] if ( Traitement is not None ): - self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + self.texteSTD = apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) ) return self.texteSTD @@ -144,7 +214,7 @@ class STDGenerateur : ''' return footerSTD - def MinMax (self): + def MinMax (self, subDict): ''' Produit le fichier study correspondant a une analyse Min/Max ''' @@ -158,8 +228,8 @@ class STDGenerateur : Methode = self.DictMCVal[ 'Method' ] Traitement = None - if ( self.traitement.has_key( Methode ) ): - Traitement = self.traitement[ Methode ] + if ( subDict.has_key( Methode ) ): + Traitement = subDict[ Methode ] if ( Traitement is not None ): txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) @@ -175,8 +245,9 @@ class STDGenerateur : Importe le modele physique ''' fonction = None - if ( self.DictMCVal.has_key( 'Name' ) ): - fonction = self.DictMCVal[ 'Name' ] + if ( self.DictMCVal.has_key( 'FileName' ) ): + name = self.DictMCVal[ 'FileName' ] + fonction = name[name.rfind('/')+1:name.rfind('.xml')] txt = "# Charge le modele physique\n" txt += "%s = NumericalMathFunction( '%s' )\n" % (self.variable["model"], fonction) @@ -197,7 +268,7 @@ class STDGenerateur : txt += "\n" return txt - def RandomSampling (self): + def MinMaxRandomSampling (self): ''' Etude par echantillonage aleatoire ''' @@ -218,11 +289,20 @@ class STDGenerateur : Cree la loi jointe des variables d entree ''' txt = "# Definit la loi jointe des variables d'entree\n" - txt += "%s = DistributionCollection( %d )\n" % (self.variable["collection"], len( self.DictLois )) + txt += "%s = DistributionCollection( %d )\n" % (self.variable["collection"], len( self.ListeVariables )) txt += "\n" + + dictVariables = {} + for variable in self.ListeVariables: + nomVar = variable['ModelVariable'].get_name() + dictVariables[ nomVar ] = variable['Distribution'] + i = 0 - for concept in self.DictLois.keys(): - loi = self.DictLois[ concept ] + sortedVarNames = dictVariables.keys() + sortedVarNames.sort() + for variable in sortedVarNames: + conceptloi = dictVariables[ variable ] + loi = self.DictLois[ conceptloi ] if loi.has_key( 'Kind' ): marginale = "%s_%d" % (self.variable["marginal"], i) txt += "# Definit la loi marginale de la composante %d\n" % i @@ -231,19 +311,19 @@ class STDGenerateur : txt += "\n" i += 1 - txt += self.Copula() + txt += self.Copula( len( self.ListeVariables ) ) txt += "# Definit la loi jointe\n" txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"]) txt += "\n" return txt - def Copula (self): + def Copula (self, dimension): ''' Cree la copule de la loi jointe ''' txt = "# Definit la copule de la loi jointe\n" - txt += "%s = IndependentCopula()\n" % self.variable["copula"] + txt += "%s = IndependentCopula( %d )\n" % (self.variable["copula"], dimension) txt += "\n" return txt @@ -256,6 +336,15 @@ class STDGenerateur : txt += "\n" return txt + def OutputRandomVector (self): + ''' + Cree le vector aleatoire de sortie + ''' + txt = "# Definit le vecteur aleatoire de sortie\n" + txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) + txt += "\n" + return txt + def ScaledVector (self): ''' Definit les coefficients multiplicateurs par composante du vecteur @@ -335,31 +424,561 @@ class STDGenerateur : ''' txt = "# Resultats\n" txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"]) - txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"]) - txt += "\n" txt += "print '%s = ', %s\n" % (self.variable["minValue"], self.variable["minValue"]) + txt += "\n" + txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"]) txt += "print '%s = ', %s\n" % (self.variable["maxValue"], self.variable["maxValue"]) txt += "\n" return txt - def CentralUncertainty (self): + def CentralUncertainty (self, subDict): ''' Produit le fichier study correspondant a une analyse d incertitude en valeur centrale ''' txt = self.Header() - txt += "# Etude 'Central Uncertainty'\n\n" + txt += "# Etude 'Central Uncertainty'\n" + + txt += self.Model() + txt += self.InputDistribution() + txt += self.InputRandomVector() + txt += self.OutputRandomVector() + + Methode = None + if ( self.DictMCVal.has_key( 'Method' ) ): + Methode = self.DictMCVal[ 'Method' ] + + Traitement = None + if ( subDict.has_key( Methode ) ): + Traitement = subDict[ Methode ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + txt += self.Footer() return txt - def ThresholdExceedence (self): + + def TaylorVarianceDecomposition (self): + ''' + Etude par decomposition de Taylor + ''' + txt = "# Cumul quadratique (decomposition de Taylor)\n" + txt += "%s = QuadraticCumul( %s )\n" % (self.variable["myQuadraticCumul"], self.variable["outputRandomVector"]) + txt += "\n" + txt += "# Resultats\n" + + if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ): + if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ): + txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"]) + txt += "print '%s = ', %s\n" % (self.variable["meanFirstOrder"], self.variable["meanFirstOrder"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ): + if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ): + txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"]) + txt += "print '%s = ', %s\n" % (self.variable["meanSecondOrder"], self.variable["meanSecondOrder"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ): + if ( self.DictMCVal[ 'StandardDeviationFirstOrder' ] == "yes" ): + txt += "%s = %s.getCovariance()\n" % (self.variable["standardDeviationFirstOrder"], self.variable["myQuadraticCumul"]) + txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"] + txt += "for i in range( dim ):\n" + txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"]) + txt += "print '%s = ', %s\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'NumericalResults' ) ): + if ( self.DictMCVal[ 'NumericalResults' ] == "yes" ): + txt += "if ( %s.getDimension() == 1):\n" % self.variable["outputRandomVector"] + txt += " %s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"]) + txt += " print '%s = ', %s\n" % (self.variable["importanceFactors"], self.variable["importanceFactors"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'GraphicalResults' ) ): + if ( self.DictMCVal[ 'GraphicalResults' ] == "yes" ): + txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"]) + txt += "Show( %s )\n" % self.variable["importanceFactorsGraph"] + txt += "%s.draw( '%s' )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) + txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] + txt += "\n" + + txt += "\n" + return txt + + def CentralUncertaintyRandomSampling (self): + ''' + Etude par echantillonage aleatoire + ''' + size = 0 + if ( self.DictMCVal.has_key( 'PointsNumber' ) ): + size = self.DictMCVal[ 'PointsNumber' ] + + txt = "# Echantillonnage aleatoire de la variable de sortie\n" + txt += "%s = %d\n" % (self.variable["inSize"], size) + txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ): + if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ): + txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"]) + txt += "print '%s =', %s\n" % (self.variable["empiricalMean"], self.variable["empiricalMean"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ): + if ( self.DictMCVal[ 'EmpiricalStandardDeviation' ] == "yes" ): + txt += "%s = %s.computeCovariance()\n" % (self.variable["empiricalStandardDeviation"], self.variable["outputSample"]) + txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"] + txt += "for i in range( dim ):\n" + txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"]) + txt += "print '%s = ', %s\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ): + ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ] + txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre) + txt += "print '%s =', %s\n" % (self.variable["empiricalQuantile"], self.variable["empiricalQuantile"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'AnalysedCorrelations' ) ): + if ( self.DictMCVal[ 'AnalysedCorrelations' ] == "yes" ): + txt += "# Ou est le %s ?\n" % self.variable["inputSample"] + txt += "#if ( ( %s.getDimension() == 1 ) and ( %s.getDimension() == 1 ) ):\n" % (self.variable["inputSample"], self.variable["outputSample"]) + txt += "# %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += "# print '%s = ', %s\n" % (self.variable["PCCcoefficient"], self.variable["PCCcoefficient"]) + txt += "# %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += "# print '%s = ', %s\n" % (self.variable["PRCCcoefficient"], self.variable["PRCCcoefficient"]) + txt += "# %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += "# print '%s = ', %s\n" % (self.variable["SRCcoefficient"], self.variable["SRCcoefficient"]) + txt += "# %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += "# print '%s = ', %s\n" % (self.variable["SRRCcoefficient"], self.variable["SRRCcoefficient"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ): + if ( self.DictMCVal[ 'KernelSmoothing' ] == "yes" ): + txt += "# Kernel Smoohing\n" + txt += "%s = KernelSmoothing()\n" % self.variable["kernel"] + txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] + txt += " %s = %s.buildImplementation( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"]) + txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedPDF"], self.variable["kernelSmoothedDist"]) + txt += " Show( %s )\n" % self.variable["kernelSmoothedPDF"] + txt += "\n" + + return txt + + def ThresholdExceedence (self, subDict): ''' Produit le fichier study correspondant a une analyse de depassement de seuil ''' txt = self.Header() - txt += "# Etude 'Threshold Exceedence'\n\n" + txt += "# Etude 'Threshold Exceedence'\n" + + txt += self.RandomGenerator() + txt += self.Model() + txt += self.InputDistribution() + txt += self.InputRandomVector() + txt += self.OutputRandomVector() + txt += self.Event() + + Methode = None + if ( self.DictMCVal.has_key( 'Method' ) ): + Methode = self.DictMCVal[ 'Method' ] + + Traitement = None + if ( subDict.has_key( Methode ) ): + Traitement = subDict[ Methode ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self, subDict) ) + txt += self.Footer() return txt + def Simulation (self, subDict): + ''' + Methodes de simulation + ''' + Algorithme = None + if ( self.DictMCVal.has_key( 'Algorithm' ) ): + Algorithme = self.DictMCVal[ 'Algorithm' ] + + Traitement = None + if ( subDict.has_key( Algorithme ) ): + Traitement = subDict[ Algorithme ] + + if ( Traitement is not None ): + txt = apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + maxOuterSampling = None + if ( self.DictMCVal.has_key( 'MaximumOuterSampling' ) ): + maxOuterSampling = self.DictMCVal[ 'MaximumOuterSampling' ] + txt += "%s.setMaximumOuterSampling( %s )\n" % (self.variable["myAlgo"], maxOuterSampling) + + blockSize = None + if ( self.DictMCVal.has_key( 'BlockSize' ) ): + maxOuterSampling = self.DictMCVal[ 'BlockSize' ] + txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize) + + maxCoefficientOfVariation = None + if ( self.DictMCVal.has_key( 'MaximumCoefficientOfVariation' ) ): + maxCoefficientOfVariation = self.DictMCVal[ 'MaximumCoefficientOfVariation' ] + txt += "%s.setMaximumCoefficientOfVariation( %s )\n" % (self.variable["myAlgo"], maxCoefficientOfVariation) + + txt += "%s.run()\n" % self.variable["myAlgo"] + txt += "\n" + txt += "# Resultats de la simulation\n" + txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'Probability' ) ): + if ( self.DictMCVal[ 'Probability' ] == "yes" ): + txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'StandardDeviation' ) ): + if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ): + txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["standardDeviation"], self.variable["standardDeviation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ): + if ( ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) and ( self.DictMCVal[ 'Probability' ] == "yes" ) ): + level = self.DictMCVal[ 'Level' ] + txt += "%s = %s.getConfidenceLength( %s )\n" % (self.variable["length"], self.variable["myResult"], level) + 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"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ): + if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ): + txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["coefficientOfVariation"], self.variable["coefficientOfVariation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'IterationNumber' ) ): + if ( self.DictMCVal[ 'IterationNumber' ] == "yes" ): + txt += "%s = %s.getOuterSampling()\n" % (self.variable["iterations"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["iterations"], self.variable["iterations"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) ): + if ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ): + txt += "%s = %s.drawProbabilityConvergence()\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"]) + txt += "Show( %s )\n" % self.variable["convergenceGraph"] + txt += "\n" + + return txt + + def Analytical (self, subDict): + ''' + Methodes analytiques + ''' + txt = "" + + OptimizationAlgo = None + if ( self.DictMCVal.has_key( 'OptimizationAlgorithm' ) ): + OptimizationAlgo = self.DictMCVal[ 'OptimizationAlgorithm' ] + + Traitement = None + if ( subDict.has_key( OptimizationAlgo ) ): + Traitement = subDict[ OptimizationAlgo ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + txt += self.OptimizerSettings() + txt += self.PhysicalStartingPoint() + + Approximation = None + if ( self.DictMCVal.has_key( 'Approximation' ) ): + Approximation = self.DictMCVal[ 'Approximation' ] + + Traitement = None + if ( subDict.has_key( Approximation ) ): + Traitement = subDict[ Approximation ] + + if ( Traitement is not None ): + txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) + + txt += self.RunAlgorithm() + txt += self.AnalyticalResult() + + return txt + + def OptimizerSettings (self): + ''' + Parametrage de l optimiseur + ''' + txt = "" + + iterations = None + if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ): + iterations = self.DictMCVal[ 'MaximumIterationsNumber' ] + txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], iterations) + + absoluteError = None + if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ): + absoluteError = self.DictMCVal[ 'MaximumAbsoluteError' ] + txt += "%s.setMaximumAbsoluteError( %s )\n" % (self.variable["myOptimizer"], absoluteError) + + relativeError = None + if ( self.DictMCVal.has_key( 'MaximumRelativeError' ) ): + relativeError = self.DictMCVal[ 'MaximumRelativeError' ] + txt += "%s.setMaximumRelativeError( %s )\n" % (self.variable["myOptimizer"], relativeError) + + residualError = None + if ( self.DictMCVal.has_key( 'MaximumResidualError' ) ): + residualError = self.DictMCVal[ 'MaximumResidualError' ] + txt += "%s.setMaximumResidualError( %s )\n" % (self.variable["myOptimizer"], residualError) + + constraintError = None + if ( self.DictMCVal.has_key( 'MaximumConstraintError' ) ): + constraintError = self.DictMCVal[ 'MaximumConstraintError' ] + txt += "%s.setMaximumConstraintError( %s )\n" % (self.variable["myOptimizer"], constraintError) + + txt += "\n" + + return txt + + def PhysicalStartingPoint (self): + ''' + Point physique de depart + ''' + txt = "# Point physique de depart\n" + + if ( self.DictMCVal.has_key( 'PhysicalStartingPoint' ) ): + point = self.DictMCVal[ 'PhysicalStartingPoint' ] + dimension = len( point ) + txt += "%s = NumericalPoint( %d )\n" % (self.variable["startingPoint"], dimension) + for i in range( dimension ): + txt += "%s[ %d ] = %g\n" % (self.variable["startingPoint"], i, point[i]) + else: + txt += "%s = %s.getMean()\n" % (self.variable["startingPoint"], self.variable["inputRandomVector"]) + + txt += "\n" + + return txt + + def AnalyticalResult (self): + ''' + Resultat des methodes analytiques + ''' + txt = "# Resultat des methodes analytiques\n" + txt += "%s = %s.getResult()\n" % (self.variable["myResult"], self.variable["myAlgo"]) + + if ( self.DictMCVal.has_key( 'Probability' ) ): + if ( self.DictMCVal[ 'Probability' ] == "yes" ): + txt += "%s = %s.getEventProbability()\n" % (self.variable["probability"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ): + if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ): + txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["hasoferReliabilityIndex"], self.variable["hasoferReliabilityIndex"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'DesignPoint' ) ): + if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ): + txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["standardSpaceDesignPoint"], self.variable["standardSpaceDesignPoint"]) + txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["physicalSpaceDesignPoint"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ImportanceFactorNumericalResults' ) ): + if ( self.DictMCVal[ 'ImportanceFactorNumericalResults' ] == "yes" ): + txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["importanceFactors"], self.variable["importanceFactors"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'ImportanceFactorGraphicalResults' ) ): + if ( self.DictMCVal[ 'ImportanceFactorGraphicalResults' ] == "yes" ): + txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"]) + txt += "Show( %s )\n" % self.variable["importanceFactorsGraph"] + txt += "\n" + + if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivityNumericalResults' ) ): + if ( self.DictMCVal[ 'FORMEventProbabilitySensitivityNumericalResults' ] == "yes" ): + txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivityGraphicalResults' ) ): + if ( self.DictMCVal[ 'FORMEventProbabilitySensitivityGraphicalResults' ] == "yes" ): + txt += "%s = %s.drawEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"]) + txt += "Show( %s[0] )\n" % self.variable["eventProbabilitySensitivityGraph"] + txt += "\n" + + if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivityNumericalResults' ) ): + if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivityNumericalResults' ] == "yes" ): + txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivityGraphicalResults' ) ): + if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivityGraphicalResults' ] == "yes" ): + txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"]) + txt += "Show( %s[0] )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "\n" + + if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ): + if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ): + txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["tvedtApproximation"], self.variable["tvedtApproximation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ): + if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ): + txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["hohenBichlerApproximation"], self.variable["tvedtApproximation"]) + txt += "\n" + + if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ): + if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ): + txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % (self.variable["breitungApproximation"], self.variable["breitungApproximation"]) + txt += "\n" + + + return txt + + def RandomGenerator (self): + ''' + Generateur Aleatoire + ''' + txt = "" + + seed = None + if ( self.DictMCVal.has_key( 'RandomGeneratorSeed' ) ): + seed = self.DictMCVal[ 'RandomGeneratorSeed' ] + txt += "# Initialise le generateur aleatoire\n" + txt += "RandomGenerator.SetSeed( %s )\n" % seed + txt += "\n" + + return txt + + def Event (self): + ''' + Definition de l evenement de defaillance + ''' + operator = None + if ( self.DictMCVal.has_key( 'ComparisonOperator' ) ): + operator = self.DictMCVal[ 'ComparisonOperator' ] + + threshold = None + if ( self.DictMCVal.has_key( 'Threshold' ) ): + threshold = self.DictMCVal[ 'Threshold' ] + + txt = "# Evenement de defaillance\n" + txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold) + txt += "\n" + return txt + + def MonteCarlo (self): + ''' + Methode de MonteCarlo + ''' + txt = "# Simulation par MonteCarlo\n" + txt += "%s = MonteCarlo( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) + txt += "\n" + + return txt + + def LHS (self): + ''' + Methode LHS + ''' + txt = "# Simulation par LHS\n" + txt += "%s = LHS( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) + txt += "\n" + + return txt + + def ImportanceSampling (self): + ''' + Methode de tirage d importance + ''' + txt = "# Simulation par Tirage d'importance\n" + txt += "%s = ImportanceSampling( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) + txt += "\n" + + return txt + + def FORM (self): + ''' + Methode FORM + ''' + txt = "# Algorithme FORM\n" + txt += "%s = FORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"]) + txt += "\n" + + return txt + + def SORM (self): + ''' + Methode SORM + ''' + txt = "# Algorithme SORM\n" + txt += "%s = SORM ( NearestPointAlgorithm( %s ), %s, %s )\n" % (self.variable["myAlgo"], self.variable["myOptimizer"], self.variable["myEvent"], self.variable["startingPoint"]) + txt += "\n" + + return txt + + def RunAlgorithm (self): + ''' + Do the computation + ''' + if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): + if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): + txt = "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"]) + txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"]) + txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"]) + txt += "\n" + + txt += "# Perform the computation\n" + txt += "%s.run()\n" % self.variable["myAlgo"] + txt += "\n" + + + if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): + if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): + txt += "%s = %s.getEvaluationCallsNumber() - %s\n" % (self.variable["modelEvaluationCalls"], self.variable["model"], self.variable["modelEvaluationCalls"]) + txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"]) + txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"]) + txt += "\n" + txt += "print '%s =', %s\n" % (self.variable["modelEvaluationCalls"], self.variable["modelEvaluationCalls"]) + txt += "print '%s =', %s\n" % (self.variable["modelGradientCalls"], self.variable["modelGradientCalls"]) + txt += "print '%s =', %s\n" % (self.variable["modelHessianCalls"], self.variable["modelHessianCalls"]) + txt += "\n" + + return txt + + def Cobyla (self): + ''' + Methode Cobyla + ''' + txt = "# Optimisation par Cobyla\n" + txt += "%s = Cobyla()\n" % self.variable["myOptimizer"] + txt += "#%s = CobylaSpecificParameters()\n" % self.variable["specificParameters"] + txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"]) + txt += "\n" + + return txt + + def AbdoRackwitz (self): + ''' + Methode AbdoRackwitz + ''' + txt = "# Optimisation par AbdoRackwitz\n" + txt += "%s = AbdoRackwitz()\n" % self.variable["myOptimizer"] + txt += "#%s = AbdoRackwitzSpecificParameters()\n" % self.variable["specificParameters"] + txt += "#%s.setSpecificParameters( %s )\n" % (self.variable["myOptimizer"], self.variable["specificParameters"]) + txt += "\n" + return txt + def Beta (self, loi, i, collection): ''' Definition de la loi Beta diff --git a/generator/OpenturnsXML.py b/generator/OpenturnsXML.py index 0c12acb3..7972a4bf 100644 --- a/generator/OpenturnsXML.py +++ b/generator/OpenturnsXML.py @@ -5,6 +5,8 @@ """ Ce module contient le generateur XML pour Openturns """ +import sys +print sys.path import openturns # Dictionnaires de conversion des valeurs lues dans EFICAS @@ -60,10 +62,9 @@ class XMLGenerateur : ''' Generation du fichier XML ''' - def __init__ (self, appli, DictMCVal, ListeVariables, DictLois ) : + def __init__ (self, appli, DictMCVal, DictVariables ) : self.DictMCVal = DictMCVal - self.ListeVariables = ListeVariables - self.DictLois = DictLois + self.DictVariables = DictVariables self.appli = appli def CreeXML (self) : @@ -90,16 +91,16 @@ class XMLGenerateur : Ecrit la liste des variables ''' varList = openturns.WrapperDataVariableList() - for dictVar in self.ListeVariables : - varList.add( self.Variable( dictVar ) ) + for var in self.DictVariables.keys() : + varList.add( self.Variable( var, self.DictVariables[var] ) ) return varList - def Variable (self, dictVar) : + def Variable (self, var, dictVar) : ''' Ecrit le parametrage d une variable ''' variable = openturns.WrapperDataVariable() - variable.id_ = dictVar[ 'Name' ] + variable.id_ = var if dictVar[ 'Type' ] in VariableTypeByName.keys() : variable.type_ = VariableTypeByName[ dictVar[ 'Type' ] ] if dictVar.has_key('Comment') : variable.comment_ = dictVar[ 'Comment' ] @@ -158,7 +159,7 @@ class XMLGenerateur : if dictFile.has_key('Path') : fich.path_ = dictFile[ 'Path' ] if dictFile.has_key('Subst') : import string - fich.subst_ = string.join( dictFile[ 'Name' ], ',' ) + fich.subst_ = string.join( dictFile[ 'Subst' ], ',' ) return fich def Parameters (self) : diff --git a/generator/generator_openturns_study.py b/generator/generator_openturns_study.py index 7aad619d..8a76087b 100644 --- a/generator/generator_openturns_study.py +++ b/generator/generator_openturns_study.py @@ -87,22 +87,24 @@ class OpenturnsGenerator(PythonGenerator): self.dictTempo[obj.nom]=obj.valeur return s - def generMCFACT(self,obj): - # Il n est pas possible d utiliser obj.valeur qui n est pas - # a jour pour les nouvelles variables ou les modifications - if obj.nom in ( "Variables", "Files", ) : - self.TraiteMCSIMP=0 - self.dictTempo={} - s=PythonGenerator.generMCFACT(self,obj) - if obj.nom in ( "Variables", ) : - self.listeVariables.append(self.dictTempo) - self.dictTempo={} - else : - self.listeFichiers.append(self.dictTempo) - self.TraiteMCSIMP=1 - return s +# def generMCFACT(self,obj): +# # Il n est pas possible d utiliser obj.valeur qui n est pas +# # a jour pour les nouvelles variables ou les modifications +# if obj.nom in ( "Variables", "Files", ) : +# self.TraiteMCSIMP=0 +# self.dictTempo={} +# s=PythonGenerator.generMCFACT(self,obj) +# if obj.nom in ( "Variables", ) : +# self.listeVariables.append(self.dictTempo) +# self.dictTempo={} +# else : +# self.listeFichiers.append(self.dictTempo) +# self.TraiteMCSIMP=1 +# return s def generETAPE(self,obj): + print "IDM: generETAPE dans generator_openturns_study.py" + print "IDM: obj.nom=", obj.nom if obj.nom in ( "DISTRIBUTION", ) : self.TraiteMCSIMP=0 self.dictTempo={} @@ -113,8 +115,22 @@ class OpenturnsGenerator(PythonGenerator): self.TraiteMCSIMP=1 return s + def generPROC_ETAPE(self,obj): + print "IDM: generPROC_ETAPE dans generator_openturns_study.py" + print "IDM: obj.nom=", obj.nom + if obj.nom in ( "VARIABLE", ) : + self.TraiteMCSIMP=0 + self.dictTempo={} + s=PythonGenerator.generPROC_ETAPE(self,obj) + if obj.nom in ( "VARIABLE", ) : + self.listeVariables.append(self.dictTempo) + self.dictTempo={} + self.TraiteMCSIMP=1 + return s + def genereSTD(self): print "IDM: genereSTD dans generator_openturns_study.py" + print "IDM: self.listeVariables=", self.listeVariables MonBaseGenerateur=Generateur(self.appli,self.dictMCVal, self.listeVariables, self.dictMCLois) MonGenerateur=MonBaseGenerateur.getSTDGenerateur() #try : diff --git a/generator/generator_openturns_wrapper.py b/generator/generator_openturns_wrapper.py index 2b91eab3..5720bfb4 100644 --- a/generator/generator_openturns_wrapper.py +++ b/generator/generator_openturns_wrapper.py @@ -124,7 +124,7 @@ class OpenturnsGenerator(PythonGenerator): if self.listeFichiers != [] : self.dictMCVal["Files"]=self.listeFichiers print "dictMCVal", self.dictMCVal, "dictVariables", self.dictVariables - MonBaseGenerateur=Generateur(self.appli,self.dictMCVal, {} ,self.dictVariables) + MonBaseGenerateur=Generateur(self.appli,self.dictMCVal, [], {} ,self.dictVariables) MonGenerateur=MonBaseGenerateur.getXMLGenerateur() #try : if 1== 1 : -- 2.39.2