Ejemplo n.º 1
0
def resilquant(approach, mdl):
    endclasses, mdlhists = propagate.approach(mdl, approach)
    reshists, diffs, summaries = rd.process.hists(mdlhists)

    fmea = rd.tabulate.summfmea(endclasses, approach)
    fmea2 = rd.tabulate.phasefmea(endclasses, approach)
    util = sum(fmea['expected cost'])
    expdegtimes = rd.process.expdegtimeheatmap(reshists, endclasses)
    return util, expdegtimes, fmea, fmea2
Ejemplo n.º 2
0
def prune_app(app, mdl):
    endclasses, mdlhists = propagate.approach(mdl, app)
    newscenids = dict.fromkeys(app.scenids.keys())

    for modeinphase in app.scenids:
        costs = np.array(
            [endclasses[scen]['cost'] for scen in app.scenids[modeinphase]])
        fullint = np.mean(costs)
        errs = abs(fullint - costs)
        mins = np.where(errs == errs.min())[0]
        newscenids[modeinphase] = [
            app.scenids[modeinphase][mins[int(len(mins) / 2)]]
        ]
    return newscenids
Ejemplo n.º 3
0
def calc_res(mdl, fullcosts=False, faultmodes = 'all'):
    app = SampleApproach(mdl, faults='single-component', phases={'forward'})   
    if faultmodes == 'battery':     app.scenlist = [scen for scen in app.scenlist if list(scen['faults'].keys())[0]=='StoreEE']
    elif faultmodes == 'line':      app.scenlist = [scen for scen in app.scenlist if list(scen['faults'].keys())[0]=='AffectDOF']
    elif faultmodes == 'notvars':   app.scenlist = [scen for scen in app.scenlist if list(scen['faults'].keys())[0] not in {'StoreEE', 'AffectDOF'}]
    
    
    endclasses, mdlhists = propagate.approach(mdl, app, staged=True)
    rescost = rd.process.totalcost(endclasses)
    if fullcosts: 
        rescosts = {'cost':0,'repcost':0, 'landcost':0, 'safecost':0, 'lost value':0}
        for scen in endclasses:
            number = endclasses[scen]['expected cost']/endclasses[scen]['cost']
            rescosts['cost'] += endclasses[scen]['expected cost']
            rescosts['repcost'] += number *  endclasses[scen]['repcost']
            rescosts['landcost'] += number *  endclasses[scen]['landcost']
            rescosts['safecost'] += number *  endclasses[scen]['safecost']
            rescosts['lost value'] += number * -endclasses[scen]['viewed value']
        return rescosts
    else: return rescost
Ejemplo n.º 4
0
def calc_res(mdl):
    app = SampleApproach(mdl, faults='single-component', phases={'forward'})
    endclasses, mdlhists = propagate.approach(mdl, app, staged=True)
    rescost = rd.process.totalcost(endclasses)
    return rescost
Ejemplo n.º 5
0
tab = rd.tabulate.samptime(app_multipt.sampletimes)

app_short = SampleApproach(mdl,
                           faults=[('ImportEE', 'inf_v')],
                           defaultsamp={
                               'samp': 'evenspacing',
                               'numpts': 3
                           })

#newscenids = prune_app(app_full, mdl)

#endclasses, mdlhists = fp.run_approach(mdl, app_full)

#rp.plot_samplecosts(app_full, endclasses)

endclasses, mdlhists = propagate.approach(mdl, app_quad)
rd.plot.samplecosts(app_quad, endclasses)

endclasses_full, mdlhists = propagate.approach(mdl, app_full)
rd.plot.samplecosts(app_full, endclasses_full)

#endclasses, mdlhists = fp.run_approach(mdl, app_fullp)
#rp.plot_samplecosts(app_fullp, endclasses)
costovertime = rd.tabulate.costovertime(endclasses_full, app_full)
rd.plot.costovertime(endclasses_full, app_full)
#rp.plot_costovertime(endclasses_full, app_full, costtype='cost')

endclasses_ml, mdlhists = propagate.approach(mdl, app_maxlike)
rd.plot.samplecosts(app_maxlike, endclasses_ml)

Ejemplo n.º 6
0
import fmdtools.faultsim.propagate as propagate
import fmdtools.resultdisp as rd
from ex_pump import *  #required to import entire module
import time

#mdl = Pump(params={'repair', 'ee', 'water', 'delay'})
mdl = Pump(params={
    'cost': {'water'},
    'delay': 10,
    'units': 'hrs'
})  # should give identical utilities
mdl = Pump()

app_full_plin = SampleApproach(mdl, defaultsamp={'samp': 'fullint'})

endclasses, mdlhists = propagate.approach(mdl, app_full_plin)
fmea = rd.tabulate.phasefmea(endclasses, app_full_plin)
rd.plot.samplecost(app_full_plin,
                   endclasses, ('ExportWater', 'block'),
                   samptype='fullint')

app_full_plin.prune_scenarios(endclasses, samptype='piecewise')
endclasses_plin, mdlhists_plin = propagate.approach(mdl, app_full_plin)
fmea_plin = rd.tabulate.phasefmea(endclasses_plin, app_full_plin)

rd.plot.samplecost(app_full_plin,
                   endclasses_plin, ('ExportWater', 'block'),
                   samptype='pruned piecewise-linear')

app_full_sing = SampleApproach(mdl, defaultsamp={'samp': 'fullint'})
app_full_sing.prune_scenarios(endclasses, samptype='bestpt')
Ejemplo n.º 7
0
                                                    time=2)

rd.plot.mdlhistvals(mdlhist, fault='NotVisible', time=2)
rd.graph.show(resgraph, faultscen='NotVisible', time=2)

endresults, resgraph, mdlhist = propagate.one_fault(mdl,
                                                    'Human',
                                                    'FalseReach',
                                                    time=2,
                                                    gtype='component')

rd.plot.mdlhistvals(mdlhist, fault='FalseReach', time=2)
rd.graph.show(resgraph, gtype='bipartite', faultscen='FalseReach', time=2)

#import matplotlib.pyplot as plt
#plt.figure()
#reshist, diff, summary = rp.compare_hist(mdlhist)
#rp.plot_resultsgraph_from(mdl,reshist,time=20)

endclasses, mdlhists = propagate.single_faults(mdl)

app_stuck = SampleApproach(mdl, faults=[('Import_Water', 'Stuck')])

endresults, resgraph, mdlhist = propagate.one_fault(mdl,
                                                    'Import_Water',
                                                    'Stuck',
                                                    time=2)

app_full = SampleApproach(mdl)
endclasses, mdlhists = propagate.approach(mdl, app_full)
Ejemplo n.º 8
0
                    time=5)

rd.plot.mdlhistvals(mdlhist, 'StoreEE S1P1nocharge', time=5)

# mdlhist['nominal']['functions']['Planpath']
###
#endresults, resgraph, mdlhist2=fp.run_one_fault(mdl, 'AffectDOF', 'RFshort', time=13, staged=True)
# is the model not being reset???

#rp.show_graph(resgraph)
#fp.plotflowhist(flowhist2, 'RFshort', time=13)
#fp.plotghist(ghist2, 't=13 RFshort')
#

app = SampleApproach(mdl, faults='single-component')
a, b = propagate.approach(mdl, app)

p_hazardous = np.sum([v['severities']['hazardous'] for k, v in a.items()])
p_minor = np.sum([v['severities']['minor'] for k, v in a.items()])

#resultstab=fp.runlist(mdl,staged=True)

#resultstab.write('tab4.ecsv', overwrite=True)

#resultstab=fp.run_list(mdl, staged=True)

#t1=time.time()
#endclasses, mdlhists=fp.run_list(mdl, staged=True)
#simplefmea = rp.make_simplefmea(endclasses)
#t2=time.time()
#print(simplefmea)
Ejemplo n.º 9
0
                        'RSig_Traj': 'mode',
                        'Planpath': 'mode',
                        'DOFs': 'planvel',
                        'StoreEE': 'soc'
                    },
                    time=4,
                    legend=False)
plot_faulttraj(mdlhist_split, mdl_split.params)
plot_xy(mdlhist_split['faulty'], endresults_split)

fhist = mdlhist_med['faulty']
faulttime = sum([
    any([
        fhist['functions'][f]['faults'][t] != {'nom'}
        for f in fhist['functions']
    ]) for t in range(len(fhist['time'])) if fhist['flows']['DOFs']['elev'][t]
])

app_med = SampleApproach(mdl_med,
                         faults='single-component',
                         phases={'forward'})
endclasses_med, mdlhists = propagate.approach(mdl_med, app_med, staged=True)
simplefmea_med = rd.tabulate.simplefmea(endclasses_med)

app_split = SampleApproach(mdl_split,
                           faults='single-component',
                           phases={'forward'})
endclasses_split, mdlhists = propagate.approach(mdl_split,
                                                app_split,
                                                staged=True)
simplefmea_split = rd.tabulate.simplefmea(endclasses_split)