sort taches par dte deb

master
parent c9d3e9fd3f
commit b878e24b20

@ -10,6 +10,7 @@ OBJ_DIR = obj
SRC_FILES = $(SRC_DIR)/structures.c \
$(SRC_DIR)/charge.c \
$(SRC_DIR)/sort.c \
$(SRC_DIR)/part4.c \
$(SRC_DIR)/main.c
OBJ_FILES = $(SRC_FILES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)

BIN
SAE2

Binary file not shown.

@ -21,6 +21,10 @@ void fusionDevisElements(ListeDevis *R, int *tlogR, ListeDevis *S, int *tlogS, L
void gestionElementsRestants(ListeDevis *mergedList, ListeDevis *last, ListeDevis *source, int *tlogSource, int *k);
void fusionMaillonDevis(ListeDevis R, int tlogR, ListeDevis S, int tlogS, ListeDevis *T);
void triFusionListeDevis(ListeDevis *ldevis, int tlog);
void fusion(Tache *R[], int tR, Tache *S[], int tS, Tache *T[]);
void copy(Tache *T[], int i, int j, Tache *R[]);
void triFusion(Tache *T[], int tlog);
// Fonctions de base -> Qui étaient bien dans structures.h...
@ -29,7 +33,7 @@ int max(int a, int b);
int lenListeDevis(ListeDevis l);
int longueurMaxNomEntreprise(ListeDevis ldevis);
int nombrePred(char travaux[], Precedence prec[], int tlog);
int calculerDureeProjet(Tache **tachesTriees, int nbTaches);
int calculerDureeProjet(Tache **tachesTriees, int nbTaches);
void displayDevis(Devis d);
void displayOffre(Offre *o);
void displayListeDevis(ListeDevis l);
@ -48,8 +52,8 @@ ListeDevis del(ListeDevis l);
ListeDevis insert(ListeDevis l, Devis d);
ListeDevis newListeDevis(void);
Tache *trouverTache(Tache **tabTache, int nbTaches, char *nom);
Tache* defiler(ListeAttente *file);
Tache* defiler(ListeAttente *file);
ListeAttente* initialiserFileAttente(void);
ListeAttente* traiterTaches(Tache **tabTache, int p_tmax);
ListeAttente* traiterTaches(Tache **tabTache);

Binary file not shown.

Binary file not shown.

@ -1,6 +1,6 @@
#include "../includes/main.h"
ListeAttente* traiterTaches(Tache **tabTache, int p_tmax)
ListeAttente* traiterTaches(Tache **tabTache)
{
int i;
int dateCourante;
@ -9,7 +9,7 @@ ListeAttente* traiterTaches(Tache **tabTache, int p_tmax)
Liste successeurs;
ListeAttente *file = initialiserFileAttente();
for (i = 0; i < p_tmax; i++)
for (i = 0; i < TMAXTRAV; i++)
if (tabTache[i]->nbPred == 0)
enfiler(file, tabTache[i]);
@ -21,7 +21,7 @@ ListeAttente* traiterTaches(Tache **tabTache, int p_tmax)
while (successeurs)
{
successeur = trouverTache(tabTache, p_tmax, successeurs->tache);
successeur = trouverTache(tabTache, TMAXTRAV, successeurs->tache);
successeur->dateDebut = max(successeur->dateDebut, dateCourante + tacheCourante->duree);
successeur->nbPred--;

@ -187,3 +187,76 @@ void triFusionListeDevis(ListeDevis *ldevis, int tlog)
fusionMaillonDevis(*ldevis, tlog / 2, qTemp, tlog - tlog / 2, &mergedList);
*ldevis = mergedList;
}
void fusion(Tache *R[], int tR, Tache *S[], int tS, Tache *T[])
{
int i, j, k;
i = 0;
j = 0;
k = 0;
while (i < tR && j < tS)
{
if (R[i]->dateDebut < S[j]->dateDebut)
{
T[k] = R[i];
i++;
}
else
{
T[k] = S[j];
j++;
}
k++;
}
while (i < tR)
{
T[k] = R[i];
i++;
k++;
}
while (j < tS)
{
T[k] = S[j];
j++;
k++;
}
}
void copy(Tache *T[], int i, int j, Tache *R[])
{
int k;
k = 0;
while (i < j)
{
R[k] = T[i];
i++;
k++;
}
}
void triFusion(Tache *T[], int tlog)
{
if (tlog <= 1)
return;
Tache **R = (Tache **)malloc(sizeof(Tache *) * (tlog / 2));
Tache **S = (Tache **)malloc(sizeof(Tache *) * (tlog - tlog / 2));
if (!R || !S)
exit(1);
copy(T, 0, tlog / 2, R);
copy(T, tlog / 2, tlog, S);
triFusion(R, tlog / 2);
triFusion(S, tlog - tlog / 2);
fusion(R, tlog / 2, S, tlog - tlog / 2, T);
free(R);
free(S);
}

@ -62,7 +62,8 @@ Booleen emptyOffre(Offre *o)
}
// file
Booleen estVide(ListeAttente *file) {
Booleen estVide(ListeAttente *file)
{
return (file->debut == file->fin);
}
@ -74,6 +75,7 @@ ListeDevis insert(ListeDevis l, Devis d)
{
trace("insert");
MaillonDevis *md;
md = (MaillonDevis *)malloc(sizeof(MaillonDevis));
if (md == NULL)
{
@ -82,6 +84,7 @@ ListeDevis insert(ListeDevis l, Devis d)
}
md->dev=d;
md->suiv=l;
return md;
}
@ -90,6 +93,7 @@ Liste insertSucc(Liste l, char travaux[])
{
trace("insertSucc");
MaillonSucc *ms;
ms = (MaillonSucc *)malloc(sizeof(MaillonSucc));
if (ms == NULL)
{
@ -99,6 +103,7 @@ Liste insertSucc(Liste l, char travaux[])
ms->nxt=l->nxt;
l->nxt=ms;
strcpy(ms->tache, travaux);
return l;
}
@ -123,15 +128,14 @@ ListeDevis del(ListeDevis l)
{
trace("del");
MaillonDevis *md;
if (l == NULL)
{
printf("\033[0;31mErreur: \033[0msuppression dans une liste vide\n");
exit(1);
}
md = l;
l = l->suiv;
if (md->suiv == NULL)
{
free(md->dev.nomE);
@ -150,9 +154,9 @@ ListeDevis del(ListeDevis l)
Tache* defiler(ListeAttente *file)
{
Tache *tache;
if (file->debut == file->fin)
return (NULL);
tache = file->tab[file->debut];
file->debut = (file->debut + 1) % TMAXTRAV;
return (tache);
@ -334,8 +338,8 @@ void displayPrecedences(Precedence *tabP, int tlog)
{
trace("displayPrecedences");
int i;
printf("Liste des precedences :\n");
printf("Liste des precedences :\n");
for (i = 0; i < tlog; i++)
printf("\t%s\t\t : \t%s\n", tabP[i].travauxPrec, tabP[i].travauxSucc);
}

Loading…
Cancel
Save