Esempio 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))
Esempio 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))
Esempio 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)
Esempio 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)
Esempio 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)