Ejemplo n.º 1
0
def test_rule(rulename, rulepath, g):
    ibfm_utility.plotPgvGraph(g, "plots/beforeRule.svg", promoteNodeLabels="function", printRelationships="flowType")
    r = ibfm_utility.grammars.Rule(rulename, os.path.join(rulepath, "lhs.csv"), os.path.join(rulepath, "rhs.csv"))
    r.recognize(g)
    g = r.apply(g)
    #    g = r.apply(g,1)
    print(r.recognize_mappings)
    ibfm_utility.plotPgvGraph(
        g, filename="plots/afterRule.svg", promoteNodeLabels="function", printRelationships="flowType"
    )
Ejemplo n.º 2
0
def test_rule(rulename,rulepath,g):
    ibfm_utility.plotPgvGraph(g,'plots/beforeRule.svg',
                            promoteNodeLabels='function',
                            printRelationships='flowType')
    r = ibfm_utility.grammars.Rule(rulename,os.path.join(rulepath,'lhs.csv'),os.path.join(rulepath,'rhs.csv'))
    r.recognize(g)
    g = r.apply(g)
#    g = r.apply(g,1)
    print(r.recognize_mappings)
    ibfm_utility.plotPgvGraph(g,filename='plots/afterRule.svg',
                            promoteNodeLabels='function',
                            printRelationships='flowType')
Ejemplo n.º 3
0
def test_rule(rulename,rulepath,g):
    ibfm_utility.plotPgvGraph(g,'plots/beforeRule.svg',
                            promoteNodeLabels='function',
                            printRelationships='flowType')
    r = ibfm_utility.grammars.Rule(rulename,os.path.join(rulepath,'lhs.csv'),os.path.join(rulepath,'rhs.csv'))
    r.recognize(g)
    g = r.apply(g)
#    g = r.apply(g,1)
    print(r.recognize_mappings)
    ibfm_utility.plotPgvGraph(g,filename='plots/afterRule.svg',
                            promoteNodeLabels='function',
                            printRelationships='flowType')
Ejemplo n.º 4
0
   depth = 3
   popu = rs.build_population_random_stack(g,breadth,depth) 
 
   #graph each member of population
   path = 'plots/graph_population/'
   extension = '.svg'
   for f in os.listdir(path): 
       if f.endswith(extension):
           os.remove(os.path.join(path,f)) 
   for label,rulename,location,graph in rs.get_population(popu):
       print(label,rulename,location,graph)
       path = 'plots/graph_population/'
       extension = '.svg'
       filename = '-'.join([str(label),rulename,str(location)])
       ibfm_utility.plotPgvGraph(graph,filename=os.path.join(path,filename)+extension,
                           promoteNodeLabels='function',
                           printRelationships='flowType')
   
   for label,rulename,location,graph in rs.get_population(popu): 
       if ibfm_utility.grammars.check_model(graph) == True:
           popu[label]['isSimulatable'] = True
       else:
           popu[label]['isSimulatable'] = False
   
   #Run every valid model in the population
   results = {}
   max_simultaneous_faults = 2
   for label,rulename,location,graph in rs.get_population(popu): 
       print(label,rulename)
       if popu[label]['isSimulatable'] == True:
           eps = ibfm.Experiment(graph)
Ejemplo n.º 5
0
'''This is an example of how to import a functional model from csv

'''

import sys

sys.path.append('ibfm_utility')

import ibfm
import ibfm_utility

if __name__ == '__main__':
    filename = 'FunctionalModels/small_eps.csv'
    g = ibfm_utility.ImportFunctionalModel(filename, type='dsm')
    ibfm_utility.plotPgvGraph(g,
                              promoteNodeLabels='function',
                              printRelationships='flowType')
    print(g.nodes(data=True))
    print(g.edges(data=True))
    eps = ibfm.Experiment(g)
    #Run with 2 then 3 simultaneous faults
    eps.run(2)
    eps.run(3)
Ejemplo n.º 6
0
#    rulename = 'AddSeriesAnyElectricalEnergy'
#    rulepath = 'ibfm_utility/rules/testRules/AddSeriesAnyElectricalEnergy/'
#    test_rule(rulename,rulepath,g)
    
    #create population from ruleset
    ruleset_path = 'ibfm_utility/rules/ruleset/'        
    rs = ibfm_utility.grammars.Ruleset(ruleset_path)
    breadth = 3
    depth = 3
    pop = rs.build_population_random_stack(g,breadth,depth) 
  
    #graph each member of population
    path = 'plots/graph_population/'
    extension = '.svg'
    for f in os.listdir(path): 
        if f.endswith(extension):
            os.remove(os.path.join(path,f)) 
    for label,rulename,location,graph in rs.get_population(pop):
        print(label,rulename,location,graph)
        path = 'plots/graph_population/'
        extension = '.svg'
        filename = '-'.join([str(label),rulename,str(location)])
        ibfm_utility.plotPgvGraph(graph,filename=os.path.join(path,filename)+extension,
                            promoteNodeLabels='function',
                            printRelationships='flowType')
    
#    #Create and run experiments (broken until we resolve FunctionFlow vs Function_Flow convention)
#    eps = ibfm.Experiment(g)
#    #Run with 2 then 3 simultaneous faults
#    eps.run(2)
#    eps.run(3)
Ejemplo n.º 7
0
"""This is an example of how to import a functional model from csv

"""

import sys

sys.path.append("ibfm_utility")

import ibfm
import ibfm_utility

if __name__ == "__main__":
    filename = "FunctionalModels/small_eps.csv"
    g = ibfm_utility.ImportFunctionalModel(filename, type="dsm")
    ibfm_utility.plotPgvGraph(g, promoteNodeLabels="function", printRelationships="flowType")
    print(g.nodes(data=True))
    print(g.edges(data=True))
    eps = ibfm.Experiment(g)
    # Run with 2 then 3 simultaneous faults
    eps.run(2)
    eps.run(3)