def TEST_crowfail(): from simulation_batch import SimulationBatch text = """# NetworkProbability data file # bus bus_id fail_rate repair_rate bus 101 0.0 10.0 bus 102 0.0 10.0 bus 103 0.0 10.0 # line name fbus tbus fail_rate repair_rate trans_fail line a1 101 102 100000000000.0 10.0 0.0 line a2 102 103 0.0 10.0 0.0 # crow line1 line2 probability crow a1 a2 0.5 """ count = 100000 prob = NetworkProbability() prob.read(StringIO(text)) batch = SimulationBatch() for x in range(count): batch.add(prob.outages(str(x))) assert count == len(batch) batch.write_stats(sys.stdout)
def make_outages(prob, count): """func make_outages :: NetworkProbability, Int -> SimulationBatch ---- Monte Carlo sample the network for it's expected condition. e.g. existing outages, weather & load forcast, etc. """ batch = SimulationBatch() for x in range(count): batch.add(prob.outages(str(x))) EnsureEqual(count, batch.size()) return batch
def make_failures(prob, count): """func make_failures :: NetworkProbability, Int -> SimulationBatch ---- Monte Carlo sample the network for unexpected changes. e.g. new outages (failures), actual weather, actual load level, etc. """ batch = SimulationBatch() for x in range(count): batch.add(prob.failures(str(x))) EnsureEqual(count, batch.size()) return batch
def make_outage_cases(prob, count): """func make_outage_cases :: NetworkProbability, Int -> SimulationBatch ---- like `make_outages` but makes `count` *after* reducing. Monte Carlo sample the network for it's expected condition. e.g. existing outages, weather & load forcast, etc. """ batch = SimulationBatch() current = 0 while len(batch) < count: batch.add(prob.outages(str(current))) current += 1 EnsureEqual(count, len(batch)) return batch
def make_failure_cases(prob, count): """func make_failure_cases :: NetworkProbability, Int -> SimulationBatch ---- like `make_failures` but makes `count` *after* reducing. Monte Carlo sample the network for unexpected changes. e.g. new outages (failures), actual weather, actual load level, etc. """ batch = SimulationBatch() current = 0 while len(batch) < count: batch.add(prob.failures(str(current))) current += 1 EnsureEqual(count, len(batch)) return batch