コード例 #1
0
def find_and_save_path(name, seed):
    edges, perfs = validate_file(name)
    graph = make_weighted_graph(edges, perfs)
    caller = supress_stdout(find_cover)
    random.seed(seed)
    res = caller(deepcopy(graph), find_sets)
    outname = "%s_path_%s.txt" % (name.replace(".in", ""), str(seed).zfill(4))
    save_path(res, outname)
コード例 #2
0
def find_and_save_path(filename, seed):
    fpath = "final_inputs/%s" % filename
    graph = make_weighted_graph(*validate_file(fpath))
    random.seed(seed)
    caller = supress_stdout(find_cover)
    res = caller(deepcopy(graph), find_sets)
    outname = "paths/%s_%s_hail.txt" % (filename.replace(".in", ""), str(seed).zfill(4))
    save_path(res, outname)
コード例 #3
0
ファイル: level.py プロジェクト: zzeleznick/horsey-sauce
def gen_scores(filename, r=20):
    fpath = "final_inputs/%s" % filename
    graph = make_weighted_graph(*validate_file(fpath))
    # random.seed(10)
    # find_sets(graph)
    scores = repeat_find_cover(graph, find_sets, r)
    outname = "output/%s_level.txt" % filename.split(".in")[0]
    save_scores(scores, outname)
コード例 #4
0
def main():
    # filename =  "generated1.in" # "sample3.in" # "generated3.in"
    # path = "data/%s" % filename
    # filename =  "02_01_00.in" #"3.in" #"0037.in"
    # path = "proposals/%s" % filename
    filename = "1.in"  #"3.in" #"0037.in"
    path = "final_inputs/%s" % filename
    # """
    edges, perfs = validate_file(path)
    graph = make_weighted_graph(edges, perfs)
    scores = repeat_find_cover(graph, find_sets, 20)
コード例 #5
0
def compute_score(filename, paths):
    fpath = "final_inputs/%s" % filename
    graph = make_weighted_graph(*validate_file(fpath))

    def calc_score(vertices):
        return len(vertices) * sum(graph[v].value for v in vertices)

    if type(paths[0]) == list:
        score = sum(calc_score(p) for p in paths)
    else:
        score = sum(paths)
    return score