diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7d0da0d --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +make: + cd build/ && \ + gnat make -gnatwa -gnata -g ../src/*.adb + +clean: + cd build/ && \ + gnat clean ../src/*.adb + diff --git a/LISEZ-MOI.txt b/README.md similarity index 79% rename from LISEZ-MOI.txt rename to README.md index 1865f04..40493ac 100644 --- a/LISEZ-MOI.txt +++ b/README.md @@ -41,20 +41,18 @@ communiquez avec votre coéquipier ! # Organisation du dépôt SVN -src/ - -: pour les sources de votre projet (fichiers .adb, ads, etc.) - -livrables/ - -: les fichiers qui sont demandés dans le sujet. Attention à -respecter les noms. Certains sont déjà là. Il suffit de les remplacer. - -docs/ - -: c'est ici que vous pouvez mettre les fichiers qui vous permettent -d'obtenir le rapport (par exemple fichier LaTeX, markdown, etc.) - +. \ +├── build \ +├── doc \ +├── livrables \ +│   ├── raffinages.txt \ +│   └── rapport.pdf \ +├── Makefile \ +├── README.md \ +└── src \ + ├── googleNaive.ada \ + ├── googleNaive.ads \ + └── pageRank.ada \ # Autres informations diff --git a/livrables/raffinages.txt b/livrables/raffinages.txt index e69de29..c4e672f 100644 --- a/livrables/raffinages.txt +++ b/livrables/raffinages.txt @@ -0,0 +1,134 @@ +Ce raffinage décrit l'implémentation de l'algorithme de PageRank dans le cas d'une implémentation de matrice naives. +Une syntaxe proche du python3 est adoptée pour simplifier l'écriture et la lisibilité. +DISCLAIMER: raffinages pas encore finis +On suppose que les procédures/fonctions suivantes sont élémentaires: + Std: + - Arguments + - Longueur + - Exception + - Écrire + - Lire + - Ouvrir + - Fermer + - Fin // end of file + - Abs + - Somme + + Matrice: + - Transposer + - Ones + - Zeros + - Les opérations binaires: * / + + - L'accès via les [ ] + - Trier + + +R0: Calculer le PageRank et le poids de chaque nœud d'un réseau + +R1: Comment « Calculer le PageRank et le poids de chaque nœud d'un réseau » ? + Récuperer les arguments de la ligne de commande out: filename, ite_max, alpha, naif + Initialiser les variables out: pi, G, epsilon, N + Éxecuter l'algorithme itératif in out: pi ; in: G, epsilon + Écrire les résultats dans des fichiers in: pi, filename, N + +R2: Comment « Récupérer les arguments de la ligne de commande » ? + args ← Arguments() + len_args ← Longueur(args) + Si non 0 < len_args <= 6 Alors + Exception(ERROR_ARGS) + Sinon + Traiter les arguments in: args, len_args ; out: filename, ite_max, alpha, naif + FinSi + Si Exception(QUELCONQUE) + Afficher les consignes d'utilisation + Fin Si + +R2: Comment « Traiter les arguments » ? + ite_max ← 150 + alpha ← 0.85 + naif ← False + i ← 0 + Répéter + Si args[i] = "-I" Alors + ite_max ← args[i+1] + i ← i + 2 + SinonSi args[i] = "-A" Alors + alpha ← args[i+1] + i ← i + 2 + SinonSi args[i][-4:-1] == ".net" Alors + filename ← args[i][0:-4] + i ← i + 1 + SinonSi args[i] == "-P" Alors + naif ← True + i ← i + 1 + Sinon + Exception(ERROR_ARGS) + FinSi + SortirQuand i < len_args + FinRépéter + +R3: Comment « Afficher les consignes d'utilisation » ? + Écrire("Erreur lors de la saisi de la commande") + Écrire("Usage: pagerank [-I max_iterations] [-A alpha] fichier_reseau.net") + +R2: Comment « Initialiser les variables » ? + epsilon ← 0.01 + Créer H out: H, N + Créer S in: H, N ; out: S + pi ← Ones(N, N)/N + E ← Ones(N, N) * (1-alpha)/N + G ← alpha * S + E + +R3: Comment « Créer H » ? + fichier ← Ouvrir(filename + ".net") + N ← Lire(fichier) + + H ← Zeros(N, N) + TantQue non Fin(fichier) Faire + i ← Lire(fichier) + j ← Lire(fichier) + H[i, j] ← 1 + FinTantQue + Fermer(fichier) + + Pour i de 0 à N-1 Faire + H[i,:] ← H[i,:]/Somme(H[i,:]) + FinPour + +R3: Comment « Créer S » ? + X ← Ones(N, 1) + V ← H * X + S ← H + Pour i de 0 a N-1 Faire + Si V[i] = 0 Alors + S[i,:] = 1/N + Fin Si + FinPour + +R2: Comment « Éxecuter l'algorithme itératif » ? + i ← 0 + Répéter + pi_last ← pi + pi ← Transposer(G) * pi + i ← i + 1 + SortirQuand i >= ite_max ou Abs(pi - pi_last) < epsilon + FinRépéter + +R2: Comment « Écrire les résultats dans des fichiers » ? + Coupler les poids et leur indice in: pi ; out: pi_couple + pi_couple ← Trier(pi_couple, 'c', 0) // on trie selon la première colonne + + fichier ← Ouvrir(filename + ".p") + Écrire(fichier, pi_couple[:,0]) + Fermer(fichier) + + fichier ← Ouvrir(filename + ".ord") + Écrire(fichier, pi_couple[:,1]) + Fermer(fichier) + +R3: Comment « Coupler les poids et leur indice » ? + pi_couple ← Zeros(N, 2) + pi_couple[:, 0] = pi + Pour i de 0 N-1 Faire + pi_couple[i, 1] ← i + FinPour \ No newline at end of file diff --git a/src/googleNaive.ada b/src/googleNaive.ada new file mode 100644 index 0000000..ed54559 --- /dev/null +++ b/src/googleNaive.ada @@ -0,0 +1,5 @@ +package body googleNaive is + + -- TODO + +end googleNaive; \ No newline at end of file diff --git a/src/googleNaive.ads b/src/googleNaive.ads new file mode 100644 index 0000000..4fda6f3 --- /dev/null +++ b/src/googleNaive.ads @@ -0,0 +1,37 @@ +generic + + type T_Element is private; + CAPACITY: Positive; + +package googleNaive is + + type T_Row is limited private; + type T_Google is limited private; + + function "*"(left, right: T_Google) return T_Google; + function "+"(left, right: T_Google) return T_Google; + + function "*"(left: T_Google; right: Integer) return T_Google; + function "/"(left: T_Google; right: Integer) return T_Google; + + function isEmpty(mat: T_Google) return Boolean; + + procedure initialize(mat: in out T_Google) with + Post => isEmpty(mat); + + function ones(rows, cols: Positive) return T_Google; + function zeros(rows, cols: Positive) return T_Google; + + procedure insert(mat: in out T_Google; i, j: Natural; elm: T_Element); + + function transpose(mat: in T_Google) return T_Google; + +private + + type T_Row is array (0..CAPACITY-1) of T_Element; + type T_Google is record + dimension: array (0..1) of Positive; + matrix: array (0..CAPACITY-1) of T_Row; + end record; + +end googleNaive; \ No newline at end of file diff --git a/src/pageRank.ada b/src/pageRank.ada new file mode 100644 index 0000000..3ef9c33 --- /dev/null +++ b/src/pageRank.ada @@ -0,0 +1,7 @@ +procedure pageRank is + +begin + + -- TODO + +end pageRank; \ No newline at end of file