FROM = SIMP(statut = "o", typ = "TXM", into=(${data_into}), defaut=${data_default}),
SCRIPT_DATA = BLOC ( condition = " FROM in ( 'Script', ) ",
- SCRIPT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr())),
+ SCRIPT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant la définition d'une variable interne de même nom que le concept parent", ang="Waiting for a script file name, with or without the full path to find it, containing the definition of an internal variable of the same name as the parent concept"),
),
STRING_DATA = BLOC ( condition = " FROM in ( 'String', ) ",
- STRING = SIMP(statut = "o", typ = "TXM"),
+ STRING = SIMP(statut = "o", typ = "TXM", fr="En attente d'une chaine de caractères entre guillements, qui soit valide pour construire un vecteur : une suite de nombres, utilisant un espace ou une virgule pour séparer deux éléments et un point-virgule pour séparer deux lignes", ang="Waiting for a string in quotes, valid to build a vector: a floats serie, using a space or comma to separate two elements in a line, a semi-colon to separate rows"),
+ ),
+ SCRIPTWITHFUNCTIONS_DATA = BLOC ( condition = " FROM in ( 'ScriptWithFunctions', ) ",
+
+ SCRIPTWITHFUNCTIONS_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant en variables internes trois fonctions de calcul nommées DirectOperator, TangentOperator et AdjointOperator", ang="Waiting for a script file name, with or without the full path to find it, containing as internal variables three computation functions named DirectOperator, TangentOperator and AdjointOperator"),
+ ),
+ SCRIPTWITHSWITCH_DATA = BLOC ( condition = " FROM in ( 'ScriptWithSwitch', ) ",
+
+ SCRIPTWITHSWITCH_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant un switch pour les calculs direct, tangent et adjoint", ang="Waiting for a script file name, with or without the full path to find it, containing a switch for direct, tangent and adjoint computations"),
),
FUNCTIONDICT_DATA = BLOC ( condition = " FROM in ( 'FunctionDict', ) ",
- FUNCTIONDICT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr())),
+ FUNCTIONDICT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="OBSOLETE : conservé pour compatibilité avec la version 6.5, sera supprimé dans le futur", ang="OBSOLETE: keeped for compatibility with the 6.5 version, will be removed in the future"),
),
)
"""
decl_choices = ""
decl_opts = ""
if infos.AssimDataDefaultDict[assim_data_input_name] in infos.StoredAssimData:
- storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0),"
+ storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0, fr=\"Choix de stockage interne ou non du concept parent\", ang=\"Choice of the storage or not of the parent concept\"),"
for choice in infos.AssimDataDict[assim_data_input_name]:
choices += "\"" + choice + "\", "
decl_choices += assim_data_choice.substitute(choice_name = choice)
if choice in infos.StoredAssimData:
- storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0),"
+ storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0, fr=\"Choix de stockage interne ou non du concept parent\", ang=\"Choice of the storage or not of the parent concept\"),"
default_choice = "\"" + infos.AssimDataDefaultDict[assim_data_input_name] + "\""
mem_file.write(assim_data_method.substitute(assim_name = assim_name,
else:
CAS_node.getInputPort(port_name).edInitPy(FunctionDict["Script"][FunctionName])
+ if data_config["Type"] == "Function" and data_config["From"] == "ScriptWithSwitch" and key == "ObservationOperator":
+ ScriptWithSwitch = data_config["Data"]
+ for FunctionName in ScriptWithSwitch["Function"]:
+ port_name = "ObservationOperator" + FunctionName
+ CAS_node.edAddInputPort(port_name, t_string)
+ if repertory:
+ CAS_node.getInputPort(port_name).edInitPy(os.path.join(base_repertory, os.path.basename(ScriptWithSwitch["Script"][FunctionName])))
+ else:
+ CAS_node.getInputPort(port_name).edInitPy(ScriptWithSwitch["Script"][FunctionName])
+
+ if data_config["Type"] == "Function" and data_config["From"] == "ScriptWithSwitch" and key == "EvolutionModel":
+ ScriptWithSwitch = data_config["Data"]
+ for FunctionName in ScriptWithSwitch["Function"]:
+ port_name = "EvolutionModel" + FunctionName
+ CAS_node.edAddInputPort(port_name, t_string)
+ if repertory:
+ CAS_node.getInputPort(port_name).edInitPy(os.path.join(base_repertory, os.path.basename(ScriptWithSwitch["Script"][FunctionName])))
+ else:
+ CAS_node.getInputPort(port_name).edInitPy(ScriptWithSwitch["Script"][FunctionName])
+
+ if data_config["Type"] == "Function" and data_config["From"] == "ScriptWithFunctions" and key == "ObservationOperator":
+ ScriptWithFunctions = data_config["Data"]
+ for FunctionName in ScriptWithFunctions["Function"]:
+ port_name = "ObservationOperator" + FunctionName
+ CAS_node.edAddInputPort(port_name, t_string)
+ if repertory:
+ CAS_node.getInputPort(port_name).edInitPy(os.path.join(base_repertory, os.path.basename(ScriptWithFunctions["Script"][FunctionName])))
+ else:
+ CAS_node.getInputPort(port_name).edInitPy(ScriptWithFunctions["Script"][FunctionName])
+
+ if data_config["Type"] == "Function" and data_config["From"] == "ScriptWithFunctions" and key == "EvolutionModel":
+ ScriptWithFunctions = data_config["Data"]
+ for FunctionName in ScriptWithFunctions["Function"]:
+ port_name = "EvolutionModel" + FunctionName
+ CAS_node.edAddInputPort(port_name, t_string)
+ if repertory:
+ CAS_node.getInputPort(port_name).edInitPy(os.path.join(base_repertory, os.path.basename(ScriptWithFunctions["Script"][FunctionName])))
+ else:
+ CAS_node.getInputPort(port_name).edInitPy(ScriptWithFunctions["Script"][FunctionName])
+
# Step 3: create compute bloc
compute_bloc = runtime.createBloc("compute_bloc")
ADAO_Case.edAddChild(compute_bloc)
opt_script_nodeOO.setScript(node_script)
opt_script_nodeOO.edAddInputPort("computation", t_param_input)
opt_script_nodeOO.edAddOutputPort("result", t_param_output)
+ elif data_config["Type"] == "Function" and data_config["From"] == "ScriptWithSwitch":
+ # Get script
+ ScriptWithSwitch = data_config["Data"]
+ script_filename = ""
+ for FunctionName in ScriptWithSwitch["Function"]:
+ # We currently support only one file
+ script_filename = ScriptWithSwitch["Script"][FunctionName]
+ break
+
+ # We create a new pyscript node
+ opt_script_nodeOO = runtime.createScriptNode("", "FunctionNodeOO")
+ if repertory:
+ script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
+ try:
+ script_str= open(script_filename, 'r')
+ except:
+ logging.fatal("Exception in opening function script file : " + script_filename)
+ traceback.print_exc()
+ sys.exit(1)
+ node_script = "#-*-coding:iso-8859-1-*-\n"
+ node_script += "import sys, os \n"
+ if base_repertory != "":
+ node_script += "filepath = \"" + base_repertory + "\"\n"
+ else:
+ node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n"
+ node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n"
+ node_script += " sys.path.insert(0,filepath)\n"
+ node_script += script_str.read()
+ opt_script_nodeOO.setScript(node_script)
+ opt_script_nodeOO.edAddInputPort("computation", t_param_input)
+ opt_script_nodeOO.edAddOutputPort("result", t_param_output)
+ elif data_config["Type"] == "Function" and data_config["From"] == "ScriptWithFunctions":
+ # Get script
+ ScriptWithFunctions = data_config["Data"]
+ script_filename = ""
+ for FunctionName in ScriptWithFunctions["Function"]:
+ # We currently support only one file
+ script_filename = ScriptWithFunctions["Script"][FunctionName]
+ break
+
+ # We create a new pyscript node
+ opt_script_nodeOO = runtime.createScriptNode("", "FunctionNodeOO")
+ if repertory:
+ script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
+ try:
+ script_str= open(script_filename, 'r')
+ except:
+ logging.fatal("Exception in opening function script file : " + script_filename)
+ traceback.print_exc()
+ sys.exit(1)
+ node_script = "#-*-coding:iso-8859-1-*-\n"
+ node_script += "import sys, os, numpy, logging\n"
+ if base_repertory != "":
+ node_script += "filepath = \"" + base_repertory + "\"\n"
+ else:
+ node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n"
+ node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n"
+ node_script += " sys.path.insert(0,filepath)\n"
+ node_script += """# ==============================================\n"""
+ node_script += script_str.read()
+ node_script += """# ==============================================\n"""
+ node_script += """for param in computation["specificParameters"]:\n"""
+ node_script += """ if param["name"] == "method": method = param["value"]\n"""
+ node_script += """ else: method = ""\n"""
+ node_script += """logging.info("ComputationFunctionNode: Found method is \'%s\'"%method)\n"""
+ node_script += """#\n"""
+ node_script += """#\n"""
+ node_script += """if method == "Direct":\n"""
+ node_script += """ try:\n"""
+ node_script += """ DirectOperator\n"""
+ node_script += """ except NameError:\n"""
+ node_script += """ raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
+ node_script += """ logging.info("ComputationFunctionNode: Direct computation")\n"""
+ node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n"""
+ node_script += """ data = DirectOperator(numpy.matrix( Xcurrent ).T)\n"""
+ node_script += """#\n"""
+ node_script += """if method == "Tangent":\n"""
+ node_script += """ try:\n"""
+ node_script += """ TangentOperator\n"""
+ node_script += """ except NameError:\n"""
+ node_script += """ raise ValueError("ComputationFunctionNode: TangentOperator not found in the imported user script file")\n"""
+ node_script += """ logging.info("ComputationFunctionNode: Tangent computation")\n"""
+ node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n"""
+ node_script += """ dXcurrent = computation["inputValues"][0][0][1]\n"""
+ node_script += """ data = TangentOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( dXcurrent ).T))\n"""
+ node_script += """#\n"""
+ node_script += """if method == "Adjoint":\n"""
+ node_script += """ try:\n"""
+ node_script += """ AdjointOperator\n"""
+ node_script += """ except NameError:\n"""
+ node_script += """ raise ValueError("ComputationFunctionNode: AdjointOperator not found in the imported user script file")\n"""
+ node_script += """ logging.info("ComputationFunctionNode: Adjoint computation")\n"""
+ node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n"""
+ node_script += """ Ycurrent = computation["inputValues"][0][0][1]\n"""
+ node_script += """ data = AdjointOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( Ycurrent ).T))\n"""
+ node_script += """#\n"""
+ node_script += """logging.info("ComputationFunctionNode: Formatting the output")\n"""
+ node_script += """it = data.flat\n"""
+ node_script += """outputValues = [[[[]]]]\n"""
+ node_script += """for val in it:\n"""
+ node_script += """ outputValues[0][0][0].append(val)\n"""
+ node_script += """#\n"""
+ node_script += """result = {}\n"""
+ node_script += """result["outputValues"] = outputValues\n"""
+ node_script += """result["specificOutputInfos"] = []\n"""
+ node_script += """result["returnCode"] = 0\n"""
+ node_script += """result["errorMessage"] = ""\n"""
+ node_script += """# ==============================================\n"""
+ #
+ opt_script_nodeOO.setScript(node_script)
+ opt_script_nodeOO.edAddInputPort("computation", t_param_input)
+ opt_script_nodeOO.edAddOutputPort("result", t_param_output)
else:
factory_opt_script_node = catalogAd.getNodeFromNodeMap("FakeOptimizerLoopNode")
opt_script_nodeOO = factory_opt_script_node.cloneNode("FakeFunctionNode")
opt_script_nodeEM.setScript(node_script)
opt_script_nodeEM.edAddInputPort("computation", t_param_input)
opt_script_nodeEM.edAddOutputPort("result", t_param_output)
+ elif data_config["Type"] == "Function" and data_config["From"] == "ScriptWithSwitch":
+ # Get script
+ ScriptWithSwitch = data_config["Data"]
+ script_filename = ""
+ for FunctionName in ScriptWithSwitch["Function"]:
+ # We currently support only one file
+ script_filename = ScriptWithSwitch["Script"][FunctionName]
+ break
+
+ # We create a new pyscript node
+ opt_script_nodeEM = runtime.createScriptNode("", "FunctionNodeEM")
+ if repertory:
+ script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
+ try:
+ script_str= open(script_filename, 'r')
+ except:
+ logging.fatal("Exception in opening function script file : " + script_filename)
+ traceback.print_exc()
+ sys.exit(1)
+ node_script = "#-*-coding:iso-8859-1-*-\n"
+ node_script += "import sys, os \n"
+ if base_repertory != "":
+ node_script += "filepath = \"" + base_repertory + "\"\n"
+ else:
+ node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n"
+ node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n"
+ node_script += " sys.path.insert(0,filepath)\n"
+ node_script += script_str.read()
+ opt_script_nodeEM.setScript(node_script)
+ opt_script_nodeEM.edAddInputPort("computation", t_param_input)
+ opt_script_nodeEM.edAddOutputPort("result", t_param_output)
+ elif data_config["Type"] == "Function" and data_config["From"] == "ScriptWithFunctions":
+ # Get script
+ ScriptWithFunctions = data_config["Data"]
+ script_filename = ""
+ for FunctionName in ScriptWithFunctions["Function"]:
+ # We currently support only one file
+ script_filename = ScriptWithFunctions["Script"][FunctionName]
+ break
+
+ # We create a new pyscript node
+ opt_script_nodeEM = runtime.createScriptNode("", "FunctionNodeEM")
+ if repertory:
+ script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
+ try:
+ script_str= open(script_filename, 'r')
+ except:
+ logging.fatal("Exception in opening function script file : " + script_filename)
+ traceback.print_exc()
+ sys.exit(1)
+ node_script = "#-*-coding:iso-8859-1-*-\n"
+ node_script += "import sys, os, numpy, logging\n"
+ if base_repertory != "":
+ node_script += "filepath = \"" + base_repertory + "\"\n"
+ else:
+ node_script += "filepath = \"" + os.path.dirname(script_filename) + "\"\n"
+ node_script += "if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):\n"
+ node_script += " sys.path.insert(0,filepath)\n"
+ node_script += script_str.read()
+ node_script += """# ==============================================\n"""
+ node_script += """for param in computation["specificParameters"]:\n"""
+ node_script += """ if param["name"] == "method": method = param["value"]\n"""
+ node_script += """ else: method = ""\n"""
+ node_script += """logging.info("ComputationFunctionNode: Found method is \'%s\'"%method)\n"""
+ node_script += """#\n"""
+ node_script += """#\n"""
+ node_script += """if method == "Direct":\n"""
+ node_script += """ try:\n"""
+ node_script += """ DirectOperator\n"""
+ node_script += """ except NameError:\n"""
+ node_script += """ raise ValueError("ComputationFunctionNode: mandatory DirectOperator not found in the imported user script file")\n"""
+ node_script += """ logging.info("ComputationFunctionNode: Direct computation")\n"""
+ node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n"""
+ node_script += """ data = DirectOperator(numpy.matrix( Xcurrent ).T)\n"""
+ node_script += """#\n"""
+ node_script += """if method == "Tangent":\n"""
+ node_script += """ try:\n"""
+ node_script += """ TangentOperator\n"""
+ node_script += """ except NameError:\n"""
+ node_script += """ raise ValueError("ComputationFunctionNode: mandatory TangentOperator not found in the imported user script file")\n"""
+ node_script += """ logging.info("ComputationFunctionNode: Tangent computation")\n"""
+ node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n"""
+ node_script += """ dXcurrent = computation["inputValues"][0][0][1]\n"""
+ node_script += """ data = TangentOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( dXcurrent ).T))\n"""
+ node_script += """#\n"""
+ node_script += """if method == "Adjoint":\n"""
+ node_script += """ try:\n"""
+ node_script += """ AdjointOperator\n"""
+ node_script += """ except NameError:\n"""
+ node_script += """ raise ValueError("ComputationFunctionNode: mandatory AdjointOperator not found in the imported user script file")\n"""
+ node_script += """ logging.info("ComputationFunctionNode: Adjoint computation")\n"""
+ node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n"""
+ node_script += """ Ycurrent = computation["inputValues"][0][0][1]\n"""
+ node_script += """ data = AdjointOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( Ycurrent ).T))\n"""
+ node_script += """#\n"""
+ node_script += """logging.info("ComputationFunctionNode: Formatting the output")\n"""
+ node_script += """it = data.flat\n"""
+ node_script += """outputValues = [[[[]]]]\n"""
+ node_script += """for val in it:\n"""
+ node_script += """ outputValues[0][0][0].append(val)\n"""
+ node_script += """#\n"""
+ node_script += """result = {}\n"""
+ node_script += """result["outputValues"] = outputValues\n"""
+ node_script += """result["specificOutputInfos"] = []\n"""
+ node_script += """result["returnCode"] = 0\n"""
+ node_script += """result["errorMessage"] = ""\n"""
+ node_script += """# ==============================================\n"""
+ #
+ opt_script_nodeEM.setScript(node_script)
+ opt_script_nodeEM.edAddInputPort("computation", t_param_input)
+ opt_script_nodeEM.edAddOutputPort("result", t_param_output)
else:
factory_opt_script_node = catalogAd.getNodeFromNodeMap("FakeOptimizerLoopNode")
opt_script_nodeEM = factory_opt_script_node.cloneNode("FakeFunctionNode")