diff --git a/examples/scripts/sellar_problem.py b/examples/scripts/sellar_problem.py index cba0a796923e259fdf2420ce63adf1301d783b3c..45ba5038fe8c1ac2e873f21766514cb3c71c94ee 100644 --- a/examples/scripts/sellar_problem.py +++ b/examples/scripts/sellar_problem.py @@ -26,7 +26,7 @@ mdao_definitions = ['unconverged-MDA-J', # 0 'CO'] # 13 # Settings for scripting -mdao_definitions_loop_all = False # Option for looping through all MDAO definitions +mdao_definitions_loop_all = True # Option for looping through all MDAO definitions mdao_definition_id = 13 # Option for selecting a MDAO definition (in case mdao_definitions_loop_all=False) # Settings for saving diff --git a/kadmos/cmdows/cmdows.py b/kadmos/cmdows/cmdows.py index e103ebbf99cc07d53c7ed13e25c3139312331e84..f07e35b57e94a89db2c7cda2143c17b9140813b1 100644 --- a/kadmos/cmdows/cmdows.py +++ b/kadmos/cmdows/cmdows.py @@ -37,6 +37,7 @@ class CMDOWS(object): self.XMLNS_PREFIX = 'https://bitbucket.org/imcovangent/cmdows/raw/master/schema/' self.XMLNS_SUFFIX = '/cmdows.xsd' if file_path: + assert os.path.isfile(file_path), 'File {} does not seem to exist.'.format(file_path) self.file = file_path if element is not None: self.root = ElementTree(element).getroot() @@ -301,7 +302,7 @@ class CMDOWS(object): # Add elements el.add("creator", creator) el.add("description", description) - el.add("timestamp", str(datetime.now()) if timestamp is None else timestamp) + el.add("timestamp", str(datetime.now()).replace(' ', 'T') if timestamp is None else timestamp) el.add("fileVersion", fileVersion) el.add("cmdowsVersion", cmdowsVersion) return diff --git a/kadmos/graph/graph_data.py b/kadmos/graph/graph_data.py index 3bb040368793f96d4f4789911b55dec51b84605f..7a4fba70fbf1f0035d195b81b66e81b92018e276 100644 --- a/kadmos/graph/graph_data.py +++ b/kadmos/graph/graph_data.py @@ -5305,8 +5305,6 @@ class MdaoDataGraph(DataGraph, MdaoMixin): skip_coupling = True if skip_coupling: continue - # Remove coupling edge between coupling variable -> function - self.remove_edge(coupling[2], coupling[1]) # Create initial guess coupling variable node ini_guess_node = self.copy_node_as(coupling[2], self.ARCHITECTURE_ROLES_VARS[0]) # If there is no converger node, then just add an initial guess of the coupled node @@ -5321,7 +5319,7 @@ class MdaoDataGraph(DataGraph, MdaoMixin): coupling_copy_node = self.copy_node_as(coupling[2], self.ARCHITECTURE_ROLES_VARS[2]) if not self.has_edge(converger, coupling_copy_node): self.add_edge(converger, coupling_copy_node) - self.add_edge(coupling_copy_node, coupling[1]) + self.copy_edge((coupling[2], coupling[1]) ,(coupling_copy_node, coupling[1])) # Connect original coupling node to the converger self.add_edge(coupling[2], converger) # If the converger node is an optimizer (IDF), then connect it accordingly @@ -5333,7 +5331,7 @@ class MdaoDataGraph(DataGraph, MdaoMixin): coupling_copy_node = self.copy_node_as(coupling[2], self.ARCHITECTURE_ROLES_VARS[2]) if not self.has_edge(converger, coupling_copy_node): self.add_edge(converger, coupling_copy_node) - self.add_edge(coupling_copy_node, coupling[1]) + self.copy_edge((coupling[2], coupling[1]), (coupling_copy_node, coupling[1])) # Connect original and copied coupling node to the consistency constraint function self.add_edge(coupling[2], self.CONSCONS_STRING, equation_label='y{}'.format(idx)) self.add_edge(coupling_copy_node, self.CONSCONS_STRING, equation_label='y{}c'.format(idx)) @@ -5348,6 +5346,8 @@ class MdaoDataGraph(DataGraph, MdaoMixin): self.node[self.CONSCONS_STRING]['consistency_nodes'].append(consistency_node) else: self.node[self.CONSCONS_STRING]['consistency_nodes'] = [consistency_node] + # Remove coupling edge between coupling variable -> function + self.remove_edge(coupling[2], coupling[1]) # If required, create final coupling variable node and let it come from the coupled function if converger and ('problem_role' in self.node[coupling[2]] or include_couplings_as_final_output): final_node = self.copy_node_as(coupling[2], self.ARCHITECTURE_ROLES_VARS[1]) diff --git a/kadmos/graph/graph_kadmos.py b/kadmos/graph/graph_kadmos.py index 62eef74d9f6c2fd81256ca7d68b61511a881f306..8c76ddced27370cc50898dc8de9ed3f5ee6dab58 100644 --- a/kadmos/graph/graph_kadmos.py +++ b/kadmos/graph/graph_kadmos.py @@ -1166,7 +1166,7 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): projectSpecific=function.finddict('projectSpecific')) for inp in function.findall('inputs/input'): - self.add_edge(inp.findtext('parameterUID'), function.get('uID'), + self.add_edge(inp.findtext('parameterUID').replace("'", '"'), function.get('uID'), valid_ranges=inp.finddict('validRanges', ordered=False, camel_case_conversion=True)) if not function.findall('inputs/input'): @@ -1181,7 +1181,7 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): # # # for output in function.findall('outputs/output'): - self.add_edge(function.get('uID'), output.findtext('parameterUID')) + self.add_edge(function.get('uID'), output.findtext('parameterUID').replace("'", '"')) if not function.findall('outputs/output'): # Determine assumed output file location (same folder as CMDOWS file) @@ -1193,6 +1193,7 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): else: logger.warning('Could not find outputs for function: ' + function.get('uID')) + # Add inputs and outputs based on XML io_list = inputs_list+outputs_list _perform_check_list(io_list, check_list, keep_running=keep_running) @@ -1223,7 +1224,7 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): def _load_cmdows_parameters(self, cmdows): for variable in cmdows.findall('parameters/parameter'): - self.add_node(variable.get('uID'), + self.add_node(variable.get('uID').replace("'", '"'), category='variable', shape='o', label=variable.findtext('label'), @@ -1242,8 +1243,10 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): cmdows_edges = cmdows_data_graph.find('edges') if cmdows_edges is not None: for edge in list(cmdows_edges): - from_id = edge.findtext('fromExecutableBlockUID', default=edge.findtext('fromParameterUID')) - to_id = edge.findtext('toExecutableBlockUID', default=edge.findtext('toParameterUID')) + from_id = edge.findtext('fromExecutableBlockUID', default=edge.findtext('fromParameterUID')).replace("'", '"') + to_id = edge.findtext('toExecutableBlockUID', default=edge.findtext('toParameterUID')).replace("'", '"') + self.assert_node_exists(from_id) + self.assert_node_exists(to_id) self.add_edge(from_id, to_id) else: logger.warning('No dataGraph element found in the CMDOWS file. Ignoring missing information.') diff --git a/kadmos/graph/mixin_equation.py b/kadmos/graph/mixin_equation.py index b3c20ffc8831a98f42a7151a74d787f0287c9908..ff9f4d61f86d8d7a5a4456c8e3b455546bf95cc8 100644 --- a/kadmos/graph/mixin_equation.py +++ b/kadmos/graph/mixin_equation.py @@ -269,7 +269,7 @@ class EquationMixin(object): label=function.findtext('label'), function_type=function.findtext('functionType')) for inp in function.findall('inputs/input'): - self.add_edge(inp.findtext('parameterUID'), function.get('uID'), + self.add_edge(inp.findtext('parameterUID').replace("'", '"'), function.get('uID'), equation_label=inp.findtext('equationLabel'), valid_ranges=inp.finddict('validRanges', ordered=False, camel_case_conversion=True)) for outp in function.findall('outputs/output'): @@ -277,5 +277,5 @@ class EquationMixin(object): equations = cmdows.xpath('.//*[@uID="' + outp.find('equationsUID').text + '"]')[0] else: equations = outp.findall('equations/equation') - self.add_edge(function.get('uID'), outp.findtext('parameterUID'), + self.add_edge(function.get('uID'), outp.findtext('parameterUID').replace("'", '"'), equations={eq.get('language'): eq.text for eq in equations}) diff --git a/requirements.txt b/requirements.txt index 41f76cfe7229684681b56e1bd308c99806d1f28d..c25dc98c80b4583cb130cd90178d26fae6ac1d1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ matlab networkx>=2.0 numpy progressbar2 -deap \ No newline at end of file +deap +Flask \ No newline at end of file diff --git a/setup.py b/setup.py index 419efcf2842f7bbe26a558c7cd2ef55a1d5d579b..567fb411c0dfca053a0c7b3c804884d396a05a79 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,8 @@ setup(name='kadmos', 'networkx>=2.0', 'numpy', 'progressbar2', - 'deap' + 'deap', + 'Flask' ], include_package_data=True, zip_safe=False)