for p, g_max, g_min in zip(nb_people, nb_Gen_Max, nb_Gen_Min): for nb in range(nb_ped): nbChild = random.randint(6, 12) g = random.randint(g_min, g_max) ped = Pedigree() ped.gen_ped(nb, p, g, nbChild, cl, 0.03) for i in range(gene_depart, gene + 1): #bn = pview.bn_multi_pb(ped, f, i, distance[:i-1]) bn = pview.bn_multi_morgans(ped, f, i, centimorgans[:i]) pview.save(ped, f'./samples/pedigree_{p}_{g}_{nbChild}_{cl}_G{nb}') pview.save_bn(bn, f'./bn/bn_{p}_{g}_{nbChild}_{cl}_G{nb}') ie1 = laz.lazyPosterior( f"./bn/bn_{p}_{g}_{nbChild}_{cl}_G{nb}.bif", evidence) ie2 = lbp.lbpPosterior(f"./bn/bn_{p}_{g}_{nbChild}_{cl}_G{nb}.bif", evidence) for j in ped.get_pedigree().keys(): #for g in range(1, 3): for g in range(1, gene + 1): p1 = ie1.posterior(f'X{j}_{g}') p2 = ie2.posterior(f'X{j}_{g}') x = [ abs(p1[0] - p2[0]), abs(p1[1] - p2[1]), abs(p1[2] - p2[2]),
t2 = process_time() time_sen_compact = t2 - t1 for p, g_max, g_min in zip(nb_people, nb_Gen_Max, nb_Gen_Min): tab_lis = np.zeros(nb_ped) tab_diff = np.zeros(nb_ped) for nb in range(nb_ped): nbChild = random.randint(6, 12) g = random.randint(g_min, g_max) ped = Pedigree() ped.gen_ped(nb, p, g, nbChild, cl, 0.03) bn_compact = pview.ped_to_bn_compact(ped, f) pview.save( ped, f'../cplex/samples/IS/pedigree_{p}_{g}_{nbChild}_{cl}_G{nb}') pview.save_bn( bn_compact, f'../cplex/bn/IS/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}') t1 = process_time() ie1 = imp.lisPosterior( f'../cplex/bn/IS/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}.bif') t2 = process_time() t2 = t2 - t1 tab_lis[nb] = t2 ie2 = laz.lazyPosterior( f'../cplex/bn/IS/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}.bif') error_lbp_laz = [] for i in ped.get_pedigree().keys(): p1 = ie1.posterior(f'X{i}') p2 = ie2.posterior(f'X{i}')
t1 = process_time() ped.gen_ped(nb, p, g, nbChild, cl, 0.03) t2 = process_time() t3 = process_time() bn = pview.ped_to_bn(ped, f) t4 = process_time() t7 = process_time() #bn_compact = pview.ped_to_bn_compact(ped,f) t8 = process_time() pview.save( ped, f'../cplex/samples/compact/pedigree_{p}_{g}_{nbChild}_{cl}_G{nb}') pview.save_bn( bn, f'../cplex/bn/no_compact/bn_{p}_{g}_{nbChild}_{cl}_G{nb}') #pview.save_bn(bn_compact,f'../cplex/bn/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}') t5 = process_time() laz.doLazyProg( f"../cplex/bn/no_compact/bn_{p}_{g}_{nbChild}_{cl}_G{nb}.bif") t6 = process_time() t9 = process_time() #laz.doLazyProg(f'../cplex/bn/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}.bif') t10 = process_time() t2 = t2 - t1 t4 = t4 - t3 t6 = t6 - t5 t8 = t8 - t7