Exemplo n.º 1
0
def solve_with_best_granularity(args):
    graph = load_graph()
    if graph == None:
        logger.critical("Can't load graph. did you run cere profile?")
        return False

    if (len(graph.nodes()) == 0):
        logger.info('Graph is empty, nothing to select')
        return True

    args.force = False
    #Compute coverage for different error
    error_filename = "{0}/table_error.csv".format(var.CERE_REPORT_PATH)
    table = utils.Error_table()
    args.max_error = 100
    while args.max_error >= 5:
        logger.info("Computing matching with a maximum error of {0}%".format(
            args.max_error))
        update_graph.update(args)
        graph = load_graph()
        table_chosen, table_coverage = solve(graph)
        table.complete_error_table(args.max_error, table_coverage)
        args.max_error = args.max_error - 5
    table.write_table(error_filename)

    args.max_error = 15
    update_graph.update(args)
    graph = load_graph()
    padding = max([len(d['_name']) for n, d in graph.nodes(data=True)])
    chosen, coverage = solve(graph)

    if coverage == 0:
        logger.error("Solution impossible")
    else:
        logger.info("Solved with coverage >= {0}".format(coverage))

    graph.graph['coverage'] = 0
    for c in chosen:
        graph.graph['coverage'] = graph.graph['coverage'] + graph.node[c][
            '_self_coverage']
        print >> sys.stderr, "> {0} {1}".format(
            graph.node[c]['_name'].ljust(padding),
            graph.node[c]['_self_coverage'])
    save_graph(graph)
    return True
Exemplo n.º 2
0
def solve_with_best_granularity(args):
    graph = load_graph()
    if graph == None:
        logger.critical("Can't load graph. did you run cere profile?")
        return False

    if( len(graph.nodes()) == 0):
        logger.info('Graph is empty, nothing to select')
        return True

    args.force=False
    #Compute coverage for different error
    error_filename = "{0}/table_error.csv".format(var.CERE_REPORT_PATH)
    table = utils.Error_table()
    args.max_error = 100
    while args.max_error >= 5:
        logger.info("Computing matching with a maximum error of {0}%".format(args.max_error))
        update_graph.update(args)
        graph = load_graph()
        table_chosen, table_coverage = solve(graph)
        table.complete_error_table(args.max_error, table_coverage)
        args.max_error = args.max_error-5
    table.write_table(error_filename)

    args.max_error = 15
    update_graph.update(args)
    graph = load_graph()
    padding = max([len(d['_name']) for n,d in graph.nodes(data=True)])
    chosen, coverage = solve(graph)

    if coverage == 0:
        logger.error("Solution impossible")
    else:
        logger.info("Solved with coverage >= {0}".format(coverage))

    graph.graph['coverage'] = 0
    for c in chosen:
        graph.graph['coverage'] = graph.graph['coverage'] + graph.node[c]['_self_coverage']
        print >>sys.stderr, "> {0} {1}".format(graph.node[c]['_name'].ljust(padding), graph.node[c]['_self_coverage'])
    save_graph(graph)
    return True
Exemplo n.º 3
0
def run(args):
    if not cere_configure.init():
        return False
    if not check_dependancies(args):
        return False
    if not check_arguments(args):
        return False
    #Find matching codelets
    if not update(args):
        return False
    #Select matching codelets with best coverage
    if not solve_with_best_granularity(args):
        return False
    return True