Skip to content
Snippets Groups Projects
Commit ad5f4791 authored by agnon.kurteshi's avatar agnon.kurteshi
Browse files

final

parent 53074936
No related branches found
No related tags found
No related merge requests found
8 0 7 8 0 7
0 1 2.0 0 1 2.0
1 2 5.0 1 2 5.0
2 1 1.0 2 1 5.0
1 3 2.0 1 3 2.0
3 1 1.0 3 1 1.0
1 5 2.0 1 5 2.0
2 3 1.0 2 3 1.0
2 6 1.0 2 6 4.0
3 4 4.0 3 4 4.0
3 5 2.0 3 5 2.0
3 6 3.0 3 6 3.0
3 7 1.0 3 7 4.0
4 7 2.0 4 7 2.0
6 7 2.0 6 7 2.0
#include "graphe.h" #include "graphe.h"
#define RHO 0.01
graph create_graph(int num, int fourmiliere, int nourriture) graph create_graph(int num, int fourmiliere, int nourriture)
{ {
graph gr = malloc(sizeof(g)); graph gr = malloc(sizeof(g));
...@@ -284,6 +283,7 @@ void export_shortest_path(graph g1, char *filename) ...@@ -284,6 +283,7 @@ void export_shortest_path(graph g1, char *filename)
while (!stack_is_empty(*eclaireuse->path)) while (!stack_is_empty(*eclaireuse->path))
{ {
//afficher le chemin dans le fichier de sortie
stack_pop(eclaireuse->path, &trash); stack_pop(eclaireuse->path, &trash);
fprintf(file, "[%d]", eclaireuse->path->data[ecrit_chemin]); fprintf(file, "[%d]", eclaireuse->path->data[ecrit_chemin]);
ecrit_chemin++; ecrit_chemin++;
......
the shortest path is [0][1][3][7] with a cost of 5 the shortest path is [0][1][3][7] with a cost of 8
...@@ -5,10 +5,23 @@ int main() ...@@ -5,10 +5,23 @@ int main()
//initialisation //initialisation
srand(time(NULL)); srand(time(NULL));
int nb_fourmi_perdu = 0; int nb_fourmi_perdu = 0;
double rho = 0;
int nb_fourmi = 0;
//création du graphe à partir d'un csv //création du graphe à partir d'un csv
graph g1 = main_create_graph("graphe.csv"); graph g1 = main_create_graph("graphe.csv");
printf("number of ants : ");
scanf("%d", &nb_fourmi);
printf("rate of evaporation [rate < 1 and rate > 0] : ");
scanf("%lf", &rho);
while(rho >= 1 || rho <= 0)
{
printf("[rate < 1 and rate > 0] : ");
scanf("%lf", &rho);
}
//lancement de la colonisation des fourmis //lancement de la colonisation des fourmis
nb_fourmi_perdu = launch_colonization(g1, 100000, 0.001); nb_fourmi_perdu = launch_colonization(g1, nb_fourmi, rho);
//impression de la matrice des phéromones et des arêtes //impression de la matrice des phéromones et des arêtes
printf("\n length path matrix \n"); printf("\n length path matrix \n");
......
...@@ -3,14 +3,14 @@ digraph Test { ...@@ -3,14 +3,14 @@ digraph Test {
1->2[penwidth=2, label= 5.000000] 1->2[penwidth=2, label= 5.000000]
1->3[penwidth=2, label= 2.000000] 1->3[penwidth=2, label= 2.000000]
1->5[penwidth=2, label= 2.000000] 1->5[penwidth=2, label= 2.000000]
2->1[penwidth=2, label= 1.000000] 2->1[penwidth=2, label= 5.000000]
2->3[penwidth=2, label= 1.000000] 2->3[penwidth=2, label= 1.000000]
2->6[penwidth=2, label= 1.000000] 2->6[penwidth=2, label= 4.000000]
3->1[penwidth=2, label= 1.000000] 3->1[penwidth=2, label= 1.000000]
3->4[penwidth=2, label= 4.000000] 3->4[penwidth=2, label= 4.000000]
3->5[penwidth=2, label= 2.000000] 3->5[penwidth=2, label= 2.000000]
3->6[penwidth=2, label= 3.000000] 3->6[penwidth=2, label= 3.000000]
3->7[penwidth=2, label= 1.000000] 3->7[penwidth=2, label= 4.000000]
4->7[penwidth=2, label= 2.000000] 4->7[penwidth=2, label= 2.000000]
6->7[penwidth=2, label= 2.000000] 6->7[penwidth=2, label= 2.000000]
} }
\ No newline at end of file
test2.dot.png

49.9 KiB | W: | H:

test2.dot.png

49.8 KiB | W: | H:

test2.dot.png
test2.dot.png
test2.dot.png
test2.dot.png
  • 2-up
  • Swipe
  • Onion skin
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment