def benchmark_nets(g):
    # atributs varis
    arestes_llevables = len(removable_edges(g))
    fulles = len(get_leaf_nodes(g))
    nodes = len(g.nodes())
    arestes = len(g.edges())
    hibrids = len(hybrid_nodes(g))
    grau_hibriditzacio = hybridization_degree(g)
    es_treechild = is_treechild(g)
    nodes_conflictius = len(problematic_treechild_nodes(g))
    subarbres = potential_number_of_calls(g)
    temps_soft, temps_soft_cache = -1, -1
    n_families, temps_families = -1, -1
    # tree-child
    # poda amb timeout
    # if arestes_llevables > MAX_ARESTES:
    #     return
    if not es_treechild:
        try:
            log.debug("inici construccio {}".format(arestes_llevables))
            executor = ThreadPoolExecutor(max_workers=1)
            begin_families = time.time()
            future = executor.submit(construct_treechild, g)
            families = future.result(TIMEOUT)
            end_families = time.time()
            temps_families = end_families - begin_families
            n_families = len(families)
            log.debug("final {}".format(arestes_llevables))
        except TimeoutError:
            log.debug("timeout {}".format(arestes_llevables))
            n_familes, temps_families = -1, -1
    else:
        n_families, temps_families = 0, 0
    BenchmarkCase.create(
        test = TEST_NUMBER,
        fulles = fulles,
        nodes = nodes,
        arestes = arestes,
        hibrids = hibrids,
        subarbres = subarbres,
        grau_hibriditzacio = grau_hibriditzacio,
        temps_soft = temps_soft,
        temps_soft_cache = temps_soft_cache,
        arestes_llevables = arestes_llevables,
        es_treechild = es_treechild,
        nodes_conflictius = nodes_conflictius,
        temps_families = temps_families,
        n_families = n_families,
    )
예제 #2
0
def test_case(g):
    test = TEST_NUMBER
    nodes = len(g.nodes())
    fulles = len(get_leaf_nodes(g))
    arestes = len(g.edges())
    hibrids = len(hybrid_nodes(g))
    grau_hibriditzacio = hybridization_degree(g)
    arestes_llevables = len(removable_edges(g))
    es_treechild = is_treechild(g)
    nodes_conflictius = len(problematic_treechild_nodes(g))
    subarbres = potential_number_of_calls(g)
    # soft
    if subarbres < MAX_SUBARBRES:
        begin_soft = time.time()
        cluster_soft_cache(g)
        end_soft = time.time()
        temps_soft = end_soft - begin_soft
        begin_soft_cache = time.time()
        for i in range(SOFT_TIMES):
            cluster_soft_cache(g)
        end_soft_cache = time.time()
        temps_soft_cache = (end_soft_cache - begin_soft_cache) / SOFT_TIMES
    else:
        temps_soft, temps_soft_cache = -1, -1
    # tree-child
    if not es_treechild:
        begin_families = time.time()
        families = construct_treechild(g)
        end_families = time.time()
        n_families = len(families)
        temps_families = end_families - begin_families
    else:
        n_families, temps_families = 0, 0
    BenchmarkCase.create(
        test = test,
        fulles = fulles,
        nodes = nodes,
        arestes = arestes,
        hibrids = hibrids,
        subarbres = subarbres,
        grau_hibriditzacio = grau_hibriditzacio,
        temps_soft = temps_soft,
        temps_soft_cache = temps_soft_cache,
        arestes_llevables = arestes_llevables,
        es_treechild = es_treechild,
        nodes_conflictius = nodes_conflictius,
        temps_families = temps_families,
        n_families = n_families,
    )
예제 #3
0
def benchmark_nets(g):
    # atributs varis
    arestes_llevables = len(removable_edges(g))
    fulles = len(get_leaf_nodes(g))
    nodes = len(g.nodes())
    arestes = len(g.edges())
    hibrids = len(hybrid_nodes(g))
    grau_hibriditzacio = hybridization_degree(g)
    es_treechild = is_treechild(g)
    nodes_conflictius = len(problematic_treechild_nodes(g))
    subarbres = potential_number_of_calls(g)
    temps_soft, temps_soft_cache = -1, -1
    n_families, temps_families = -1, -1
    # tree-child
    if not es_treechild:
        if arestes_llevables < MAX_ARESTES:
            begin_families = time.time()
            families = construct_treechild(g)
            end_families = time.time()
            temps_families = end_families - begin_families
            n_families = len(families)
    else:
        n_families, temps_families = 0, 0
    BenchmarkCase.create(
        test=TEST_NUMBER,
        fulles=fulles,
        nodes=nodes,
        arestes=arestes,
        hibrids=hibrids,
        subarbres=subarbres,
        grau_hibriditzacio=grau_hibriditzacio,
        temps_soft=temps_soft,
        temps_soft_cache=temps_soft_cache,
        arestes_llevables=arestes_llevables,
        es_treechild=es_treechild,
        nodes_conflictius=nodes_conflictius,
        temps_families=temps_families,
        n_families=n_families,
    )