-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
57 lines (43 loc) · 1.93 KB
/
Copy pathmain.c
File metadata and controls
57 lines (43 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "genetic.h"
int main(int argc, char *argv[])
{
if (argc < 3)
{
printf("Usage: %s <fichier_instance> <temps_max>\n", argv[0]);
return 1;
}
srand(time(NULL));
KnapsackInstance ksInstance;
read_knapsack_file(argv[1], &ksInstance);
int temps_max = atoi(argv[2]);
// KnapsackSolution *ksSolution = random_initial_solution(&ksInstance);
// KnapsackSolution *ksSolution = greedy_initial_solution(&ksInstance);
/*
KnapsackSolution *ksSolution = random_initial_solution(&ksInstance);
printf("Avant flip : Z = %d\n", ksSolution->Z);
local_search_1_flip(ksSolution, &ksInstance);
*/
/*
KnapsackSolution *ksSolution = random_initial_solution(&ksInstance);
printf("Avant swap : Z = %d\n", ksSolution->Z);
local_search_swap(ksSolution, &ksInstance);
*/
/*
KnapsackSolution *ksSolution = random_initial_solution(&ksInstance);
printf("Avant neighborhood descent : Z = %d\n", ksSolution->Z);
variable_neighborhood_descent(ksSolution, &ksInstance, temps_max);
*/
// Appliquer la recherche à voisinage variable (VNS)
KnapsackSolution *ksSolution = random_initial_solution(&ksInstance);
printf("Avant VNS descent : Z = %d\n", ksSolution->Z);
variable_neighborhood_search(ksSolution, &ksInstance, 3555555, 4, temps_max);
// KnapsackSolution *ksSolution = genetic_algorithm(&ksInstance, 5000, 5000, 0.05, temps_max); // population, generations, mutation_rate, temps_max
// KnapsackSolution *ksSolution = hybrid_GA_VNS(&ksInstance, 100, 100, 0.05, 100, 2,temps_max); // population, generations, mutation_rate, vns_iteration, k, temps_max
print_solution(ksSolution, &ksInstance);
print_solution_index(ksSolution, ksInstance.n);
save_solution_to_file(ksSolution, &ksInstance, "solution.txt");
// Libére la mémoire
free_solution(ksSolution);
free_knapsack_instance(&ksInstance);
return EXIT_SUCCESS;
}