Exemplo n.º 1
0
def examples():

    network_file_name = "rts.net"

    # read in the list of components and their probability of failure
    components = read(open(network_file_name))

    N1 = list(uniqueCombinations(components.keys(), 1))
    N2 = list(uniqueCombinations(components.keys(), 2))

    def comb(n, k):
        return factorial(n) / (factorial(n - k) * factorial(k))

    print "length of components", len(components)
    print "length of N-1", len(N1)
    print
    print "length of N-2", len(N2)

    assert(len(N1) == len(components))
    assert(len(N2) == comb(len(components), 2))
Exemplo n.º 2
0
def examples():

    network_file_name = "rts.net"

    # read in the list of components and their probability of failure
    components = read(open(network_file_name))

    N1 = list(uniqueCombinations(components.keys(), 1))
    N2 = list(uniqueCombinations(components.keys(), 2))

    def comb(n, k):
        return factorial(n) / (factorial(n - k) * factorial(k))

    print "length of components", len(components)
    print "length of N-1", len(N1)
    print
    print "length of N-2", len(N2)

    assert (len(N1) == len(components))
    assert (len(N2) == comb(len(components), 2))
Exemplo n.º 3
0
def solveN1(network_file_name="rts.net"):

    print
    print("# processing N-1")

    network_file_name = "rts.net"

    # read in the list of components and their probability of failure
    components = read(open(network_file_name))

    # prepare the simulator
    simulate = make_sample_simulator()

    # grab the samples
    n_samples = list(uniqueCombinations(components.keys(), 1))

    # simulate each sample
    results = map(simulate, n_samples)

    for result, fails in zip(results, n_samples):
        infoline = [1] + list(result) + [len(fails)] + list(fails)
        csv_print(infoline)
Exemplo n.º 4
0
def solveN1(network_file_name="rts.net"):

    print
    print("# processing N-1")

    network_file_name = "rts.net"

    # read in the list of components and their probability of failure
    components = read(open(network_file_name))

    # prepare the simulator
    simulate = make_sample_simulator()

    # grab the samples
    n_samples = list(uniqueCombinations(components.keys(), 1))

    # simulate each sample
    results = map(simulate, n_samples)

    for result, fails in zip(results, n_samples):
        infoline = [1] + list(result) + [len(fails)] + list(fails)
        csv_print(infoline)
Exemplo n.º 5
0
def n_minus_x_generator(x, net_file):
    for kill_list in uniqueCombinations(sampler.read(net_file).keys(), x):
        yield 1, Scenario("n-x", 1.0, [1 for _ in range(windlevel.num_wind)],
                          kill_list)
Exemplo n.º 6
0
def failure_scenario_generator(net_file):
    sample_generator = sampler.make_sample_generator(sampler.read(net_file))
    for kill_list in sample_generator:
        yield Scenario("failure", quantised_05(actual_load2(1.0)),
                       windlevel.random_forecast_errors(), kill_list)
Exemplo n.º 7
0
def outage_scenario_generator(net_file):
    outage_generator = sampler.make_outage_generator(sampler.read(net_file))
    for kill_list in outage_generator:
        yield Scenario("outage", quantised_05(random_bus_forecast()),
                       windlevel.random_forecasts(), kill_list)