def test_symbol_expansion_cyclic_constraints(self): """ Tests the Symbol Expansion algorithm on a cyclic graph with constraints. The canonical graph and the canonical material are used for this test. """ model4 = EquationModel("model4", ['D=B*C*11'], constraints=["G==0"]) symbols = GraphTest.generate_canonical_symbols() models = GraphTest.generate_canonical_models(constrain_model_4=True) models['model4'] = model4 material = GraphTest.generate_canonical_material(symbols) g = Graph(symbol_types=symbols, models=models, composite_models=dict()) ts = [] ans = [] ts.append(g.calculable_properties({symbols['A']})) ans.append({x for x in symbols.values() if x is not symbols['A']}) ts.append(g.calculable_properties({symbols['B']})) ans.append({symbols['F']}) ts.append(g.calculable_properties({symbols['C']})) ans.append(set()) ts.append(g.calculable_properties({symbols['C'], symbols['G']})) ans.append({symbols['D']}) ts.append(g.calculable_properties({symbols['B'], symbols['C']})) ans.append({symbols['F']}) for i in range(0, len(ts)): self.assertEqual(ts[i], ans[i], "Symbol Expansion failed: test - " + str(i))
def test_symbol_expansion_cyclic(self): """ Tests the Symbol Expansion algorithm on a cyclic graph. The canonical graph and the canonical material are used for this test. """ symbols = GraphTest.generate_canonical_symbols() models = GraphTest.generate_canonical_models() material = GraphTest.generate_canonical_material(symbols) g = Graph(symbol_types=symbols, models=models, composite_models=dict()) ts = [] ans = [] ts.append(g.calculable_properties({symbols['A']})) ans.append({x for x in symbols.values() if x is not symbols['A']}) ts.append(g.calculable_properties({symbols['B']})) ans.append({symbols['F']}) ts.append(g.calculable_properties({symbols['C']})) ans.append(set()) ts.append(g.calculable_properties({symbols['C'], symbols['G']})) ans.append({symbols['D']}) ts.append(g.calculable_properties({symbols['B'], symbols['C']})) ans.append({x for x in symbols.values() if x is not symbols['B'] and x is not symbols['C']}) for i in range(0, len(ts)): self.assertTrue(ts[i] == ans[i], "Symbol Expansion failed: test - " + str(i))