Пример #1
0
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
Пример #2
0
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
Пример #3
0
def text_to_scenario(text):
    """func text_to_scenario     :: Str -> Scenario
       ----
       make `text` into a Scenario by reading as if a 
       single element batch file
    """

    with closing(StringIO(text)) as batch_stream:
        batch = SimulationBatch()
        batch.read(batch_stream)

    EnsureEqual(len(batch), 1)
    return list(batch)[0]
Пример #4
0
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
Пример #5
0
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