From f95c8d3caee5c1a375e8f2939af282e2f5bde0d8 Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Wed, 8 Apr 2009 13:28:04 +0000 Subject: [PATCH] *** empty log message *** --- generator/OpenturnsSTD.py | 89 ++++++++++++++++++++++++--------------- generator/OpenturnsXML.py | 21 +++++++-- 2 files changed, 74 insertions(+), 36 deletions(-) diff --git a/generator/OpenturnsSTD.py b/generator/OpenturnsSTD.py index ddd73e6a..5bd61e8c 100644 --- a/generator/OpenturnsSTD.py +++ b/generator/OpenturnsSTD.py @@ -34,10 +34,15 @@ import math from openturns import * from openturns.viewer import ViewImage,StopViewer,WaitForViewer +results = {} + """ footerSTD = """ +# Flush des messages en attente +Log.Flush() + # Terminaison du fichier #sys.exit( 0 ) """ @@ -55,9 +60,9 @@ class STDGenerateur : self.DictMCVal = DictMCVal self.ListeVariables = ListeVariables self.DictLois = DictLois - print "DictMCVal=", DictMCVal - print "ListeVariables=", ListeVariables - print "DictLois=", DictLois + #print "DictMCVal=", DictMCVal + #print "ListeVariables=", ListeVariables + #print "DictLois=", DictLois self.texteSTD = defaultSTD self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path @@ -97,6 +102,13 @@ class STDGenerateur : self.variable = { "n" : "n", "p" : "p", + "wrapper" : "wrapper", + "wrapperdata" : "wrapperdata", + "frameworkdata" : "frameworkdata", + "framework" : "framework", + "studyid" : "studyid", + "studycase" : "studycase", + "componentname" : "componentname", "model" : "model", "scaledVector" : "scaledVector", "translationVector" : "translationVector", @@ -105,8 +117,8 @@ class STDGenerateur : "myExperimentPlane" : "myExperimentPlane", "inputSample" : "inputSample", "outputSample" : "outputSample", - "minValue" : "minValue", - "maxValue" : "maxValue", + "minValue" : 'results["minValue"]', + "maxValue" : 'results["maxValue"]', "flags" : "flags", "inSize" : "inSize", "distribution" : "distribution", @@ -116,50 +128,50 @@ class STDGenerateur : "inputRandomVector" : "inputRandomVector", "outputRandomVector" : "outputRandomVector", "myQuadraticCumul" : "myQuadraticCumul", - "meanFirstOrder" : "meanFirstOrder", - "meanSecondOrder" : "meanSecondOrder", - "standardDeviationFirstOrder" : "standardDeviationFirstOrder", - "importanceFactors" : "importanceFactors", + "meanFirstOrder" : 'results["meanFirstOrder"]', + "meanSecondOrder" : 'results["meanSecondOrder"]', + "standardDeviationFirstOrder" : 'results["standardDeviationFirstOrder"]', + "importanceFactors" : 'results["importanceFactors"]', "importanceFactorsGraph" : "importanceFactorsGraph", "importanceFactorsDrawing" : "importanceFactorsDrawing", - "empiricalMean" : "empiricalMean", - "empiricalStandardDeviation" : "empiricalStandardDeviation", - "empiricalQuantile" : "empiricalQuantile", + "empiricalMean" : 'results["empiricalMean"]', + "empiricalStandardDeviation" : 'results["empiricalStandardDeviation"]', + "empiricalQuantile" : 'results["empiricalQuantile"]', "alpha" : "alpha", "beta" : "beta", - "PCCcoefficient" : "PCCcoefficient", - "PRCCcoefficient" : "PRCCcoefficient", - "SRCcoefficient" : "SRCcoefficient", - "SRRCcoefficient" : "SRRCcoefficient", + "PCCcoefficient" : 'results["PCCcoefficient"]', + "PRCCcoefficient" : 'results["PRCCcoefficient"]', + "SRCcoefficient" : 'results["SRCcoefficient"]', + "SRRCcoefficient" : 'results["SRRCcoefficient"]', "kernel" : "kernel", "kernelSmoothedDist" : "kernelSmoothedDist", "kernelSmoothedPDF" : "kernelSmoothedPDF", "myEvent" : "myEvent", "myAlgo" : "myAlgo", "myResult" : "myResult", - "probability" : "probability", - "standardDeviation" : "standardDeviation", + "probability" : 'results["probability"]', + "standardDeviation" : 'results["standardDeviation"]', "level" : "level", "length" : "length", - "coefficientOfVariation" : "coefficientOfVariation", + "coefficientOfVariation" : 'results["coefficientOfVariation"]', "convergenceGraph" : "convergenceGraph", - "iterations" : "iterations", + "iterations" : 'results["iterations"]', "myOptimizer" : "myOptimizer", "specificParameters" : "specificParameters", "startingPoint" : "startingPoint", - "hasoferReliabilityIndex" : "hasoferReliabilityIndex", - "standardSpaceDesignPoint" : "standardSpaceDesignPoint", - "physicalSpaceDesignPoint" : "physicalSpaceDesignPoint", - "eventProbabilitySensitivity" : "eventProbabilitySensitivity", - "hasoferReliabilityIndexSensitivity" : "hasoferReliabilityIndexSensitivity", + "hasoferReliabilityIndex" : 'results["hasoferReliabilityIndex"]', + "standardSpaceDesignPoint" : 'results["standardSpaceDesignPoint"]', + "physicalSpaceDesignPoint" : 'results["physicalSpaceDesignPoint"]', + "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]', + "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]', "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph", "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph", - "modelEvaluationCalls" : "modelEvaluationCalls", - "modelGradientCalls" : "modelGradientCalls", - "modelHessianCalls" : "modelHessianCalls", - "tvedtApproximation" : "tvedtApproximation", - "hohenBichlerApproximation" : "hohenBichlerApproximation", - "breitungApproximation" : "breitungApproximation", + "modelEvaluationCalls" : 'results["modelEvaluationCalls"]', + "modelGradientCalls" : 'results["modelGradientCalls"]', + "modelHessianCalls" : 'results["modelHessianCalls"]', + "tvedtApproximation" : 'results["tvedtApproximation"]', + "hohenBichlerApproximation" : 'results["hohenBichlerApproximation"]', + "breitungApproximation" : 'results["breitungApproximation"]', } # Ce dictionnaire fait la correspondance entre le mot-clef du catalogue et le flag de la bibliotheque @@ -247,10 +259,21 @@ class STDGenerateur : fonction = None if ( self.DictMCVal.has_key( 'FileName' ) ): name = self.DictMCVal[ 'FileName' ] - fonction = name[name.rfind('/')+1:name.rfind('.xml')] + #fonction = name[name.rfind('/')+1:name.rfind('.xml')] txt = "# Charge le modele physique\n" - txt += "%s = NumericalMathFunction( '%s' )\n" % (self.variable["model"], fonction) + txt = "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name) + + txt += "if globals().has_key('%s'):\n" % self.variable["framework"] + txt += " %s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"]) + txt += " %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"]) + txt += " %s.studyid_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studyid"]) + txt += " %s.studycase_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["studycase"]) + txt += " %s.componentname_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"]) + txt += " %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"]) + txt += " %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"]) + + txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],) txt += "%s = %s.getInputNumericalPointDimension()\n" % (self.variable["n"], self.variable["model"]) txt += "\n" return txt diff --git a/generator/OpenturnsXML.py b/generator/OpenturnsXML.py index 7972a4bf..275e94cc 100644 --- a/generator/OpenturnsXML.py +++ b/generator/OpenturnsXML.py @@ -49,7 +49,7 @@ WrapperDataTransferByName = { "pipe" : openturns.WrapperDataTransfer.PIPE, "arguments" : openturns.WrapperDataTransfer.ARGUMENTS, "socket" : openturns.WrapperDataTransfer.SOCKET, - "CORBA" : openturns.WrapperDataTransfer.CORBA, + "corba" : openturns.WrapperDataTransfer.CORBA, None : openturns.WrapperDataTransfer.FILES, } @@ -79,6 +79,7 @@ class XMLGenerateur : data.setHessianDescription( self.HessianDefinition() ) data.setFileList( self.FileList() ) data.setParameters( self.Parameters() ) + data.setFrameworkData( self.FrameworkData() ) wrapper=openturns.WrapperFile() wrapper.setWrapperData( data ) @@ -86,12 +87,19 @@ class XMLGenerateur : return wrapper + class __variable_ordering: + def __init__ (self, dictVar) : + self.dictVar = dictVar + + def __call__(self, a, b): + return self.dictVar[a]['numOrdre'] - self.dictVar[b]['numOrdre'] + def VariableList (self) : ''' Ecrit la liste des variables ''' varList = openturns.WrapperDataVariableList() - for var in self.DictVariables.keys() : + for var in sorted( self.DictVariables.keys(), self.__variable_ordering( self.DictVariables ) ) : varList.add( self.Variable( var, self.DictVariables[var] ) ) return varList @@ -173,7 +181,14 @@ class XMLGenerateur : parameters.out_ = WrapperDataTransferByName[ self.GetMCVal('OutDataTransfer') ] return parameters - + def FrameworkData (self) : + ''' + Ecrit les donnees liees a l utilisation d un framework englobant + ''' + framework = openturns.WrapperFrameworkData() + #framework.studycase_ = "12:23:34" + framework.componentname_ = self.GetMCVal('SolverComponentName') + return framework # --------------------------------------------------------------------------------- -- 2.39.2