Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • e87374u/projet_pne
1 result
Select Git revision
Show changes
Commits on Source (2)
Showing
with 1032 additions and 0 deletions
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
LE_PROJET___CLION_VER
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/LE PROJET.iml" filepath="$PROJECT_DIR$/.idea/LE PROJET.iml" />
</modules>
</component>
</project>
\ No newline at end of file
{
"configurations": [
{
"name": " Make MPM",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/../bin/mpm",
"args": ["data/graph2.dta"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Activer l'impression en mode Pretty pour gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Définir la version désassemblage sur Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "make: all",
"miDebuggerPath": "/usr/bin/gdb"
},
],
"version": "2.0.0"
}
\ No newline at end of file
{
"C_Cpp.errorSquiggles": "disabled"
}
\ No newline at end of file
cmake_minimum_required(VERSION 3.30)
project(LE_PROJET___CLION_VER C)
set(CMAKE_C_STANDARD 11)
include_directories("LES TA DES TACHES/include")
include_directories("LES TA DES TACHES/Main and rank 3")
add_executable(LE_PROJET___CLION_VER
"LES TA DES TACHES/include/db.h"
"LES TA DES TACHES/include/job_1 (1).h"
"LES TA DES TACHES/include/job_2.h"
"LES TA DES TACHES/include/job_3.h"
"LES TA DES TACHES/include/list_1 (1).h"
"LES TA DES TACHES/include/list_2.h"
"LES TA DES TACHES/include/outils.h"
"LES TA DES TACHES/include/list.h"
"LES TA DES TACHES/include/list_elm.h"
"LES TA DES TACHES/Main and rank 3/main (1).c"
"LES TA DES TACHES/Main and rank 3/rank (3).h"
"LES TA DES TACHES/READGRAPH ET QUICKSORT/Projet_Canevas/canevas/io.c"
"LES TA DES TACHES/READGRAPH ET QUICKSORT/Projet_Canevas/canevas/job.c"
"LES TA DES TACHES/src/db.c"
"LES TA DES TACHES/src/job_1 (1).c"
"LES TA DES TACHES/src/job_2.c"
"LES TA DES TACHES/src/job_3.c"
"LES TA DES TACHES/src/list_1 (1).c"
"LES TA DES TACHES/src/list_2.c"
"LES TA DES TACHES/src/outils.c"
"LES TA DES TACHES/src/list.c"
"LES TA DES TACHES/src/list_elm.c")
#include <stdio.h>
#include <stdlib.h>
#include "job_2.h"
#include "job_3.h"
#include "list_1 (1).h"
#include "list_2.h"
int main(int argc, char ** argv){
if(argc < 2) exit(-1);
list_t * G = read_graph(argv[1]);
printf("Liste des tâches lue\n");
view_list(G, &view_job);
printf("Liste des tâches triée par degré d'entrée croissant\n");
quick_sort(G, &iDegreeJobCmp);
view_list(G,&view_job);
printf("Liste des tâches triée par rang croissant\n");
ranking(G);
view_list(G,&view_job);
printf("Prune edges\n");
prune(G);
view_list(G,&view_job);
printf("\nMarges totales des tâches\n");
marges(G);
view_list(G,&view_job);
return 0;
}
#include "list_1 (1).h"
void ranking(list_t * G);
void prune(list_t * G);
void marges(list_t * G);
File added
#include <list.h>
#include <list_elm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "job_1 (1).h"
#include "job_2.h"
#include "job_3.h"
#include "list_1 (1).h"
#include "list_2.h"
list_t * read_graph ( char * filename ) {
FILE * fd = fopen ( filename, "rt" );
list_t * G = new_list ( );
assert ( fd && G );
char job_name [ BUFSIZ ];
while ( !feof ( fd ) ) {
fscanf ( fd, " %s", job_name);
if ( !strcmp (job_name, "NIL" ) ) continue;
job_t * J = new_job ( job_name );
/** @note
À l'appel J pointe sur le job que l'on vient de créer.
FIND retrouve le job J dans la liste G des jobs grâce à la fonction titleJobCmp.
Si ce job n'est pas dans la liste G alors
le job pointé par J est enregistré dans G
Si ce job est déjà dans G alors
le job pointé par J est supprimé grâce à free_job
puis le pointeur de J est réassigné sur le job trouvé dans G
*/
find ( G, ( void ** ) &J, &titleJobCmp, &free_job );
fscanf ( fd, "%lf", &(J->life) );
/** @note
Enregistrement des préséances
*/
job_t * predJ;
fscanf( fd, " %s", job_name );
while ( strcmp ( job_name, "NIL" ) ) {
predJ = new_job ( job_name );
find ( G, (void **) &predJ, &titleJobCmp, &free_job );
ordered_insert ( predJ->posteriority, J, &titleJobCmp );
incr_job_oDegree ( predJ );
ordered_insert ( J->precedence, predJ, &titleJobCmp );
incr_job_iDegree ( J );
fscanf ( fd, " %s", job_name );
}
/** @note valeurs par défaut des autres champs */
J->dyn_input_degree = J->input_degree;
J->rank = UNDEF;
J->au_plus_tard = UNDEF;
J->au_plus_tot = UNDEF;
J->marge_totale = UNDEF;
J->critique = false;
}
view_list(G,&view_job);
return G;
}
void quick_sort(list_t * L, int (*cmpFct)()){
assert(L && cmpFct);
if(L->numelm > 1){
elmlist_t * pivot = get_head(L);
L->head = get_suc(pivot); // reste(L)
pivot->pred = NULL;
pivot->suc = NULL;
list_t * val_inf_pivot = new_list();
list_t * val_sup_pivot = new_list();
partition(L,pivot,val_inf_pivot,val_sup_pivot,cmpFct);
/// On supprimer les éléments de L sans supprimer ni L ni les jobs
elmlist_t * S;
for(elmlist_t * E = L->head; E; E = S){
S = E->suc;
free(E);
}
/** @note
* Si la partie inf est vide alors L commence par le pivot
* Sinon on tri grâce à cmpFct la partie inf puis on ajoute en queue le pivot
*/
if(is_empty(val_inf_pivot)){
L->head = pivot;
L->tail = pivot;
L->numelm = 1;
}else{
quick_sort(val_inf_pivot,cmpFct);
L->head = val_inf_pivot->head;
L->tail = val_inf_pivot->tail;
L->numelm = val_inf_pivot->numelm;
pivot->pred= L->tail;
L->tail->suc = pivot;
L->tail = pivot;
L->numelm += 1;
}
/** @note
* Si la partie sup n'est pas vide alors
* On la trie puis on la concatène à la partie inf
*/
if(!is_empty(val_sup_pivot)){
quick_sort(val_sup_pivot,cmpFct);
val_sup_pivot->head->pred = pivot;
set_suc(pivot, val_sup_pivot->head);
L->tail = val_sup_pivot->tail;
L->numelm += val_sup_pivot->numelm;
}
free(val_inf_pivot);
free(val_sup_pivot);
}
}
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "job_2.h"
#include "job_1 (1).h"
#include "list.h"
job_t * new_empty_job ( ) {
job_t * J = calloc ( 1, sizeof (job_t ) );
assert( J );
J->precedence = new_list ( );
J->posteriority = new_list ( );
J->rank = UNDEF;
J->au_plus_tard = UNDEF;
J->au_plus_tot = UNDEF;
J->marge_totale = UNDEF;
J->critique = false;
return J;
}
job_t * new_job ( char * title ) {
job_t * J = new_empty_job ( );
J->title = strdup ( title );
return J;
}
void free_job(job_t ** ptrJ ) {
assert ( ptrJ && *ptrJ );
if( (*ptrJ)->title ) free ( (*ptrJ)->title );
free ( *ptrJ );
*ptrJ = NULL;
}
void view_job ( job_t * J ) {
printf ( "JOB %s\n\tpreceeded by [", get_job_tilte ( J ) );
for(elmlist_t * E = get_head ( J->precedence ); E; E = get_suc ( E ) ) {
printf ( " %s", get_job_tilte ( get_data ( E ) ) );
}
printf ( " ]\n" );
// if ( !get_numelm ( J->posteriority ) ) printf ( "\t" );
printf ( "\tfollowed by [" );
for(elmlist_t * E = get_head(J->posteriority); E; E = get_suc(E)){
printf(" %s", get_job_tilte(get_data(E)));
}
printf ( " ]\n" );
printf ( "\tiDeg=%d\toDeg=%d\tlife=%2.2lf", J->input_degree, J->output_degree, J->life );
printf ( "\trank=" );
if ( J->rank == UNDEF ) printf ( "U" ); else printf ( "%d", J->rank );
printf ( "\tearly=" );
if(J->au_plus_tot == UNDEF ) printf("U"); else printf ( "%2.2lf",J->au_plus_tot );
printf ( "\tlate=" );
if(J->au_plus_tard == UNDEF ) printf("U"); else printf ( "%2.2lf",J->au_plus_tard );
printf ( "\ttotale= " );
if ( J->marge_totale == UNDEF ) printf("U"); else printf ( "%2.2lf", J->marge_totale );
printf ( "\tcritical= " );
if ( J->critique ) printf("Y\n"); else printf ( "N\n" );
}
#ifndef DB_H
#define DB_H
#include "list.h"
/* file mode : text or binary */
typedef enum file_mode { TEXT, BINARY } file_mode_t;
/**
* @brief read a list from a text or binary file acording to the mode
* @param mode : TEXT or BIN
* @param data_read_fct : ptr to fct that reads datum from file fd ; fct's parameters : (fd, mode)
* @param del_fct : ptr to fct that deallocate datum's memory, ; fct's parameter (datum)
*/
list_t * read_list ( file_mode_t mode, void * (*read_fct) (), void (*del_fct) () );
/**
* @brief write a list into a text or binary file acording to the mode
* @param mode : TEXT or BIN
* @param data_write_fct : ptr to fct that writes datum into file fd ; fct's parameters : (datum, fd, mode)
*/
void write_list ( list_t * L, file_mode_t mode, void (*write_fct) () );
\ No newline at end of file
#define UNDEF -2
#include "list.h"
#include <stdbool.h>
/** Des redondances possibles avec d'autres TAs ! */
typedef struct {
char * title; // Nom de la tâche
double life; // Durée de la tâche
int input_degree; // Son degré de dépendance
int output_degree; // Les tâches qui en dépendent
int rank; // Rang de la tâche
int dyn_input_degree; // Facilité de prog
list_t * precedence; // Les tâches précédentes
list_t * posteriority; // Les tâches ultérieures
double au_plus_tot; // Date au plus tôt
double au_plus_tard; // Date au plus tard
double marge_totale; // Marge totale
double marge_libre; // Marge libre
bool critique; // Une tâche critique ?
} job_t;
#ifndef LIST_H
#define LIST_H
#include <stdbool.h>
#include "list_elm.h"
typedef struct list {
list_elm_t * head, * tail;
int numelm;
} list_t;
list_t * new_list();
void del_list ( list_t * * L, void (*ptrf) () );
bool empty_list ( list_t * L );
list_elm_t * get_head ( list_t * L );
list_elm_t * get_tail ( list_t * L );
void view_list ( list_t * L, void (*ptrf)() );
void cons ( list_t * L, void * data );
void queue ( list_t * L, void * data );
void ordered_insert ( list_t * L, void * data, int (*cmpFct)() );
\ No newline at end of file
#include <stdbool.h>
//verifier le struct elmlist_t
typedef struct{
elmlist_t * pred;
elmlist_t * suc;
void * job;
} elmlist_t ;
typedef struct{
elmlist_t * head;
elmlist_t * tail;
int numelm;
} list_t ;
// Create an empty list
list_t * new_list();
// Delete list, its elements and possibly the data
void del_list(list_t ** ptrL, void (*ptrf) ());
// Clean list; delete its elments but keep data and the list
void clean(list_t * L);
// Is list L empty ?
bool is_empty(list_t * L);
// Gimme the head of L
elmlist_t * get_head(list_t * L);
// Gimme the tail of L
elmlist_t * get_tail(list_t * L);
#include "list_1 (1).h"
// Gimme the number of elements of L
int get_numelm(struct list_t * L);
// Take out the data D of the list L if it is present
void take_out(struct list_t * L, void * D);
// Add a element holding data to the head of L
void cons(struct list_t * L, void * data);
// Add a element holding data to the tail of L
void queue(struct list_t * L, void * data);
// Insert in L a element holding data wrt order given by cmp_ptrf
void ordered_insert(struct list_t * L, void * data, int (*cmp_ptrf)());
// Do the quick sort
void quick_sort(list_t * L, int (*cmpFct)());
// View list
void view_list(list_t * L, void (*ptrf)());
// Return a ptr to element which data is key else NULL
void find(list_t * L, void ** ptrKey, int (*cmpFct)(), void (*delFct)());
#ifndef LIST_ELM_H
#define LIST_ELM_H
typedef struct list_elm {
void * data;
struct list_elm * suc, * pred;
} list_elm_t;
list_elm_t * new_list_elm ( void * data );
/**
* @brief delete the list element E and optionnaly its datum
* @param ptrf : a ptr to fct that deallocates datum's memory ;
* if ptrf is NULL, datum is not freed
*/
void del_list_elm( list_elm_t * * E, void (*ptrf)() );
list_elm_t * get_suc ( list_elm_t * E );
list_elm_t * get_pred ( list_elm_t * E );
void * get_data ( list_elm_t * E );
void set_suc ( list_elm_t * E, list_elm_t * S );
void set_pred ( list_elm_t * E, list_elm_t * P );
void set_data ( list_elm_t * E, void * data );
void view_list_elm ( list_elm_t * E, void (*ptrf)() );