def class3_test(nb_whales=30, max_iter=50, b=1.5, a=4, beta=1.5): print("__________CLASSE 03 ________________") file = open("Résultats_Scholl_Classe3_ILWOA.txt", "a") file.write( "===========b={0}, a={1}, max_iter={2}, nb_whales={3}============\n". format(b, a, max_iter, nb_whales)) i = 0 for filename in os.listdir("./Instances_scholl/classe3"): if filename.endswith(".txt"): n, c, liste = Instances_reader.ReadInstance( "./Instances_scholl/classe3" + "/" + filename) obj_l = Instances_generator.generate_obj_list2(liste, n) ilwoa = ILWOA(objects_list=obj_l, capacity=c) start_time = time.time() nbin, _ = ilwoa.optimize(nb_whales=nb_whales, max_iter=max_iter, b=b, a=a, beta=beta) t_exec = time.time() - start_time file.write(filename[0:len(filename) - 4] + " " + str(t_exec) + " " + str(nbin) + "\n") i = i + 1 file.close()
def exploit_explor_eval(instances=[ "./Instances_scholl/classe1/N4C2W4_F.txt", "./Instances_scholl/classe2/N1W3B3R3.txt", "./Instances_scholl/classe3/HARD7.txt" ], nb_whales=30, max_iter=50, b=1.5, a=4): file = open("exploit_explor_eval_ILWOA.txt", "a") file.write( "===========b={0}, a={1}, max_iter={2}, nb_whales={3}============\n". format(b, a, max_iter, nb_whales)) i = 0 for filename in instances: n, c, liste = Instances_reader.ReadInstance(filename) obj_l = Instances_generator.generate_obj_list2(liste, n) ilwoa = ILWOA(objects_list=obj_l, capacity=c) _, evals = ilwoa.optimize(nb_whales=nb_whales, max_iter=max_iter, b=b, a=a) file.write(filename[28:len(filename) - 4] + " " + str(evals) + "\n")