Violation d'accès lors de la lecture de l'emplacement 0x0000004b
Fermé
Amiro90
Messages postés
8
Date d'inscription
mercredi 10 août 2016
Statut
Membre
Dernière intervention
10 février 2017
-
10 août 2016 à 14:01
Amiro90 Messages postés 8 Date d'inscription mercredi 10 août 2016 Statut Membre Dernière intervention 10 février 2017 - 31 août 2016 à 18:42
Amiro90 Messages postés 8 Date d'inscription mercredi 10 août 2016 Statut Membre Dernière intervention 10 février 2017 - 31 août 2016 à 18:42
Salut et merci d'avance,
je suis entrain de traiter une amélioration de l'heuristique NEH avec C sous Visual studio pour mon projet de mémoire voilà le problème c'est que mon programme marche normalement correctement pour les petites instances(exemple 10 jobs 5 machines) mais il suffit d'augmenter un peu exemple 40 jobs que j'obtient des résultats bizarres mais
si j'augmente plus le programme bloque et il m'affiche l'erreur :
je suis entrain de traiter une amélioration de l'heuristique NEH avec C sous Visual studio pour mon projet de mémoire voilà le problème c'est que mon programme marche normalement correctement pour les petites instances(exemple 10 jobs 5 machines) mais il suffit d'augmenter un peu exemple 40 jobs que j'obtient des résultats bizarres mais
si j'augmente plus le programme bloque et il m'affiche l'erreur :
A voir également:
- Violation d'accès à l'adresse
- Iptv erreur de lecture - Forum TV & Vidéo
- Le fichier à télécharger est la nouvelle note de service de votre entreprise. importez ce fichier dans le bon dossier sur l'espace pix cloud. donnez à ce fichier les mêmes droits d'accès que les autres notes de service. ✓ - Forum Windows
- Un bloqueur de publicité empêche la lecture. veuillez le désactiver pour démarrer la vidéo - Astuces et Solutions
- Confirmation de lecture whatsapp - Guide
- Accusé de lecture gmail - Guide
5 réponses
jisisv
Messages postés
3645
Date d'inscription
dimanche 18 mars 2001
Statut
Modérateur
Dernière intervention
15 janvier 2017
934
11 août 2016 à 11:45
11 août 2016 à 11:45
Ce n'est vraiment pas une bonne pratique d'utiliser "l" comme nom de variable: ce n'est pas parlant et peut être confondu avec la constante immédiate 1.
Pourquoi ne pas faire un copier colller du code au lieu de fournir une infâme copie d'écran ?
Pourquoi ne pas faire un copier colller du code au lieu de fournir une infâme copie d'écran ?
Amiro90
Messages postés
8
Date d'inscription
mercredi 10 août 2016
Statut
Membre
Dernière intervention
10 février 2017
11 août 2016 à 12:21
11 août 2016 à 12:21
l est une liste ,d'accord je vais copier le code mais il est très grand avec des des parties non nécessaires à l'erreur .Je crois que les parties qui peuvent être nécessaires sont insert initialise read data les définitions et main bien sur
Amiro90
Messages postés
8
Date d'inscription
mercredi 10 août 2016
Statut
Membre
Dernière intervention
10 février 2017
Modifié par baladur13 le 11/08/2016 à 22:14
Modifié par baladur13 le 11/08/2016 à 22:14
/* Filename: Main.c */ /* */ /* main program */ /* */ /* ************************************************************************* */ #include <string.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_J 3000+1 #define MAX_K 3+1 #define MAX_M 300+1 #define MAXTAB 2000 int UpperBound=3000; #define MaxNumOfOperations 500 #define MaxNumOfMachines 50 #define MaxNumOfJobs 50 #define MaxOpProMachine 50 #define true 1 #define false 0 #define NIL 0 typedef int boolean; struct List { int number; struct List *next; }; struct Operation { int process_time; int machine_nr; }; struct ArcList { struct List *pred[MaxNumOfOperations+1], *succ[MaxNumOfOperations+1]; }; struct Operation OpData[MaxNumOfOperations+1],OpData_2mach[MaxNumOfOperations+1]; struct List *OpsOnMachine[MaxNumOfMachines+1],*OpsOnMachine_2mach[MaxNumOfMachines+1]; struct ArcList *ConjArcs, *DisjArcs,*ConjArcs_2mach, *DisjArcs_2mach; int head[MaxNumOfOperations+1],tail[MaxNumOfOperations+1],NumOfJobs, NumOfMachines, NumOfOperations,head_2mach[MaxNumOfOperations+1], tail_2mach[MaxNumOfOperations+1]; /* ************************************************************************* */ /* Procedure Insert() */ /* */ /* INPUT : l linked list of integers */ /* Op integer */ /* */ /* FUNCTION: Op is appended at the end of l if member(l,Op) == false */ /* ************************************************************************* */ struct List *Insert(l,Op) struct List *l; int Op; { register struct List *help; if ( l == NIL ) { l = (struct List *) malloc(sizeof(struct List)); l->number = Op; l->next = NIL; } else { help = l; while ( help->next != NIL ) help = help->next; help->next = (struct List *) malloc(sizeof(struct List)); help = help->next; help->number = Op; help->next = NIL; } return(l); } /* ************************************************************************* */ /* Procedure member() */ /* */ /* INPUT : l linked list of integers */ /* Op integer */ /* */ /* FUNCTION: Check whether Op is in l or not */ /* ************************************************************************* */ boolean Member(l, Op) struct List *l; register int Op; { register struct List *help; help = l; while ( help != NIL ) { if (help->number == Op) return (true); help = help->next; } return(false); } /* ************************************************************************* */ /* Procedure Sort() */ /* */ /* INPUT: key_array: Array with keys */ /* sort_array: Array to be sorted according to the keys */ /* last: last position of the array */ /* */ /* FUNCTION: When this function is called, the integers to be sorted */ /* are stored in sort_array[1] ... sort_array[last]. */ /* The index with smallest key_array-entry is assigned to */ /* sort_array[1], and so on. */ /* ************************************************************************* */ void Sort(key_array, sort_array, last) int key_array[]; int sort_array[]; int last; { register int i, j, k, x; for (i = 1; i < last; ++i) { k = i; x = key_array[sort_array[i]]; for (j = i+1; j <= last; ++j) if (key_array[sort_array[j]] < x) { k = j; x = key_array[sort_array[j]]; } j = sort_array[k]; sort_array[k] = sort_array[i]; sort_array[i] = j; } } /* ************************************************************************* */ /* Procedure Makeempty() */ /* */ /* INPUT : l linked list of integers */ /* */ /* FUNCTION: l is deleted */ /* ************************************************************************* */ struct List *Makeempty(l) register struct List *l; { struct List *cancel; while ( l != NIL ) { cancel = l; l = l->next; free((void *) cancel); } return(NIL); } //***************************************************************************// //***************************************************************************// /*************************************************************************************************************************/ /***********************************************Branch & bound **********************************************************/ /************************************************************************************************************************/ enum boolean {a=0,b=1} ; enum boolean onemach_rupture,onemach_erase,onemach_appJ[MAX_J]; FILE * tex; long onemach_minr,onemach_somp,onemach_ll,onemach_c,onemach_J[MAX_J],onemach_tJ,onemach_UBB,onemach_LBB,onemach_P[MAX_J],onemach_UB,onemach_UBf,onemach_i,onemach_n,onemach_ni,onemach_seq_opt[MAX_J]; long onemach_maxlev,onemach_debut_opt[MAX_J]; typedef struct onemach_nd { long onemach_lev,onemach_n_taille,onemach_n_ens[MAX_J]; long onemach_b_inf,onemach_rr[MAX_J],onemach_qq[MAX_J]; struct onemach_nd * onemach_suiv; }onemach_noeud; long onemach_nb_noeud=0 ; long onemach_nb_exp=0; double onemach_timelimit=3000; void onemach_swap(long onemach_tab[MAX_J],long onemach_a,long onemach_b) {long onemach_hh; onemach_hh=onemach_tab[onemach_a]; onemach_tab[onemach_a]=onemach_tab[onemach_b]; onemach_tab[onemach_b]=onemach_hh; } onemach_noeud * onemach_placer (onemach_noeud * onemach_p , onemach_noeud * onemach_q) {onemach_noeud * onemach_a; if(onemach_q!=NULL) {if (onemach_p==NULL) onemach_p=onemach_q; else {if(onemach_p->onemach_b_inf>onemach_q->onemach_b_inf) {onemach_a=onemach_q; while(onemach_a->onemach_suiv!=NULL) {if(onemach_a->onemach_suiv->onemach_b_inf>=onemach_p->onemach_b_inf) {onemach_p->onemach_suiv=onemach_a->onemach_suiv; onemach_a->onemach_suiv=onemach_p; break; } onemach_a=onemach_a->onemach_suiv; } if(onemach_a->onemach_suiv==NULL) onemach_a->onemach_suiv=onemach_p; onemach_p=onemach_q; } else onemach_p->onemach_suiv=onemach_q; } } return onemach_p; } void onemach_jack(onemach_noeud * onemach_p) {long onemach_hh,onemach_j,onemach_seq1[MAX_J],onemach_tailler,onemach_temp,onemach_h,onemach_jmax,onemach_qmax,onemach_tabr[MAX_J],onemach_ind[MAX_J],onemach_tseq1=0; long onemach_UB1=0,onemach_time,onemach_debut1[MAX_J]; onemach_erase=0; for(onemach_j=1;onemach_j<=onemach_p->onemach_n_taille;onemach_j++) onemach_appJ[onemach_j]=0; for(onemach_j=1;onemach_j<=onemach_p->onemach_n_taille;onemach_j++) {onemach_tabr[onemach_j]=onemach_p->onemach_n_ens[onemach_j]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler=onemach_p->onemach_n_taille; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {onemach_temp=onemach_j; for(onemach_h=onemach_j+1;onemach_h<=onemach_tailler;onemach_h++) {if(onemach_p->onemach_rr[onemach_tabr[onemach_h]]<onemach_p->onemach_rr[onemach_tabr[onemach_temp]]) onemach_temp=onemach_h; } onemach_ind[onemach_tabr[onemach_j]]=onemach_temp; onemach_ind[onemach_tabr[onemach_temp]]=onemach_j; onemach_swap(onemach_tabr,onemach_j,onemach_temp); } onemach_time=onemach_p->onemach_rr[onemach_tabr[1]]; onemach_UB1=0; while(onemach_tailler!=0) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[1]]; onemach_jmax=1; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {if(onemach_p->onemach_rr[onemach_tabr[onemach_j]]<=onemach_time) {if(onemach_p->onemach_qq[onemach_tabr[onemach_j]]>onemach_qmax) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[onemach_j]]; onemach_jmax=onemach_j; } } else break; } onemach_tseq1++; onemach_seq1[onemach_tseq1]=onemach_tabr[onemach_jmax]; onemach_debut1[onemach_tabr[onemach_jmax]]=onemach_time; if(onemach_time+onemach_P[onemach_tabr[onemach_jmax]]+onemach_qmax>onemach_UB1) onemach_UB1=onemach_time+onemach_P[onemach_tabr[onemach_jmax]]+onemach_qmax; onemach_time=onemach_time+onemach_P[onemach_tabr[onemach_jmax]]; for(onemach_j=onemach_ind[onemach_tabr[onemach_jmax]];onemach_j<onemach_tailler;onemach_j++) {onemach_tabr[onemach_j]=onemach_tabr[onemach_j+1]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler--; onemach_time=max(onemach_p->onemach_rr[onemach_tabr[1]],onemach_time); } for(onemach_j=onemach_p->onemach_n_taille;onemach_j>=1;onemach_j--) {if(onemach_debut1[onemach_seq1[onemach_j]]+onemach_P[onemach_seq1[onemach_j]]+onemach_p->onemach_qq[onemach_seq1[onemach_j]]==onemach_UB1) {onemach_ll=onemach_j; break; } } if(onemach_ll==1) {onemach_hh=1; onemach_c=0; } else {for(onemach_j=onemach_ll;onemach_j>1;onemach_j--) {if(onemach_debut1[onemach_seq1[onemach_j-1]]+onemach_P[onemach_seq1[onemach_j-1]]<onemach_p->onemach_rr[onemach_seq1[onemach_j]]) {onemach_hh=onemach_j; break; } } } if(onemach_j==1) onemach_hh=1; for(onemach_j=onemach_ll-1;onemach_j>=onemach_hh;onemach_j--) {if(onemach_p->onemach_qq[onemach_seq1[onemach_j]]<onemach_p->onemach_qq[onemach_seq1[onemach_ll]]) {onemach_c=onemach_j; break; } } if(onemach_j==onemach_hh-1) onemach_c=onemach_hh-1; if(onemach_c==onemach_hh-1) onemach_erase=1; onemach_tJ=0; for(onemach_j=onemach_c+1;onemach_j<=onemach_ll;onemach_j++) {onemach_tJ++; onemach_J[onemach_tJ]=onemach_seq1[onemach_j]; onemach_appJ[onemach_seq1[onemach_j]]=1; } if(onemach_c!=0) onemach_c=onemach_seq1[onemach_c]; onemach_ll=onemach_seq1[onemach_ll]; if(onemach_UB1<onemach_UB) {onemach_UB=onemach_UB1; for(onemach_j=1;onemach_j<=onemach_tseq1;onemach_j++) {onemach_seq_opt[onemach_j]=onemach_seq1[onemach_j]; onemach_debut_opt[onemach_seq_opt[onemach_j]]=onemach_debut1[onemach_seq_opt[onemach_j]]; } } } void onemach_jack2(onemach_noeud * onemach_p) {long onemach_j,onemach_r2[MAX_J],onemach_seq1[MAX_J],onemach_tailler,onemach_temp,onemach_h,onemach_jmax,onemach_qmax,onemach_tabr[MAX_J],onemach_ind[MAX_J],onemach_tseq1=0; long onemach_UB1=0,onemach_time,onemach_debut1[MAX_J]; for(onemach_j=1;onemach_j<=onemach_p->onemach_n_taille;onemach_j++) onemach_r2[onemach_j]=onemach_p->onemach_rr[onemach_j]; onemach_r2[onemach_c]=max(onemach_r2[onemach_c],onemach_minr+onemach_somp); for(onemach_j=1;onemach_j<=onemach_p->onemach_n_taille;onemach_j++) {onemach_tabr[onemach_j]=onemach_p->onemach_n_ens[onemach_j]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler=onemach_p->onemach_n_taille; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {onemach_temp=onemach_j; for(onemach_h=onemach_j+1;onemach_h<=onemach_tailler;onemach_h++) {if(onemach_r2[onemach_tabr[onemach_h]]<onemach_r2[onemach_tabr[onemach_temp]]) onemach_temp=onemach_h; } onemach_ind[onemach_tabr[onemach_j]]=onemach_temp; onemach_ind[onemach_tabr[onemach_temp]]=onemach_j; onemach_swap(onemach_tabr,onemach_j,onemach_temp); } onemach_time=onemach_r2[onemach_tabr[1]]; onemach_UB1=0; while(onemach_tailler!=0) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[1]]; onemach_jmax=1; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {if(onemach_r2[onemach_tabr[onemach_j]]<=onemach_time) {if(onemach_p->onemach_qq[onemach_tabr[onemach_j]]>onemach_qmax) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[onemach_j]]; onemach_jmax=onemach_j; } } else break; } onemach_tseq1++; onemach_seq1[onemach_tseq1]=onemach_tabr[onemach_jmax]; onemach_debut1[onemach_tabr[onemach_jmax]]=onemach_time; if(onemach_time+onemach_P[onemach_tabr[onemach_jmax]]+onemach_qmax>onemach_UB1) onemach_UB1=onemach_time+onemach_P[onemach_tabr[onemach_jmax]]+onemach_qmax; onemach_time=onemach_time+onemach_P[onemach_tabr[onemach_jmax]]; for(onemach_j=onemach_ind[onemach_tabr[onemach_jmax]];onemach_j<onemach_tailler;onemach_j++) {onemach_tabr[onemach_j]=onemach_tabr[onemach_j+1]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler--; onemach_time=max(onemach_r2[onemach_tabr[1]],onemach_time); } if(onemach_UB1<onemach_UB) {onemach_UB=onemach_UB1; for(onemach_j=1;onemach_j<=onemach_tseq1;onemach_j++) {onemach_seq_opt[onemach_j]=onemach_seq1[onemach_j]; onemach_debut_opt[onemach_seq_opt[onemach_j]]=onemach_debut1[onemach_seq_opt[onemach_j]]; } } } long onemach_pmtn(onemach_noeud * onemach_p) {long onemach_j,onemach_PP[MAX_J],onemach_seq1[2*MAX_J],onemach_tailler,onemach_temp,onemach_h,onemach_jmax,onemach_qmax,onemach_tabr[MAX_J],onemach_ind[MAX_J],onemach_tseq1=0; long onemach_UB1=0,onemach_time,onemach_debut1[2*MAX_J]; for(onemach_j=1;onemach_j<=onemach_p->onemach_n_taille;onemach_j++) {onemach_tabr[onemach_j]=onemach_p->onemach_n_ens[onemach_j]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; onemach_PP[onemach_p->onemach_n_ens[onemach_j]]=onemach_P[onemach_p->onemach_n_ens[onemach_j]]; } onemach_tailler=onemach_p->onemach_n_taille; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {onemach_temp=onemach_j; for(onemach_h=onemach_j+1;onemach_h<=onemach_tailler;onemach_h++) {if(onemach_p->onemach_rr[onemach_tabr[onemach_h]]<onemach_p->onemach_rr[onemach_tabr[onemach_temp]]) onemach_temp=onemach_h; } onemach_ind[onemach_tabr[onemach_j]]=onemach_temp; onemach_ind[onemach_tabr[onemach_temp]]=onemach_j; onemach_swap(onemach_tabr,onemach_j,onemach_temp); } onemach_time=onemach_p->onemach_rr[onemach_tabr[1]]; onemach_UB1=0; while(onemach_tailler!=0) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[1]]; onemach_jmax=1; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {if(onemach_p->onemach_rr[onemach_tabr[onemach_j]]<=onemach_time) {if(onemach_p->onemach_qq[onemach_tabr[onemach_j]]>onemach_qmax) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[onemach_j]]; onemach_jmax=onemach_j; } } else break; } onemach_tseq1++; onemach_seq1[onemach_tseq1]=onemach_tabr[onemach_jmax]; onemach_debut1[onemach_tabr[onemach_jmax]]=onemach_time; onemach_j=onemach_jmax+1; while((onemach_j<=onemach_tailler)&&(onemach_p->onemach_rr[onemach_tabr[onemach_j]]<onemach_time+onemach_PP[onemach_tabr[onemach_jmax]])) {if(onemach_p->onemach_qq[onemach_tabr[onemach_j]]>onemach_qmax) break; onemach_j++; } if((onemach_j>onemach_tailler)||(onemach_p->onemach_rr[onemach_tabr[onemach_j]]>=onemach_time+onemach_PP[onemach_tabr[onemach_jmax]])) {if(onemach_time+onemach_PP[onemach_tabr[onemach_jmax]]+onemach_qmax>onemach_UB1) onemach_UB1=onemach_time+onemach_PP[onemach_tabr[onemach_jmax]]+onemach_qmax; onemach_time=onemach_time+onemach_PP[onemach_tabr[onemach_jmax]]; for(onemach_j=onemach_ind[onemach_tabr[onemach_jmax]];onemach_j<onemach_tailler;onemach_j++) {onemach_tabr[onemach_j]=onemach_tabr[onemach_j+1]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler--; } else {onemach_PP[onemach_tabr[onemach_jmax]]=onemach_PP[onemach_tabr[onemach_jmax]]-onemach_p->onemach_rr[onemach_tabr[onemach_j]]+onemach_time; onemach_time=onemach_p->onemach_rr[onemach_tabr[onemach_j]]; } onemach_time=max(onemach_p->onemach_rr[onemach_tabr[1]],onemach_time); } return(onemach_UB1); } void onemach_b_sup0(onemach_noeud * onemach_p) {long onemach_j,onemach_seq1[MAX_J],onemach_tailler,onemach_temp,onemach_h,onemach_jmax,onemach_qmax,onemach_tabr[MAX_J],onemach_ind[MAX_J],onemach_tseq1=0; long onemach_UB1=0,onemach_time,onemach_debut1[MAX_J]; for(onemach_j=1;onemach_j<=onemach_p->onemach_n_taille;onemach_j++) {onemach_tabr[onemach_j]=onemach_p->onemach_n_ens[onemach_j]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler=onemach_p->onemach_n_taille; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {onemach_temp=onemach_j; for(onemach_h=onemach_j+1;onemach_h<=onemach_tailler;onemach_h++) {if(onemach_p->onemach_rr[onemach_tabr[onemach_h]]<onemach_p->onemach_rr[onemach_tabr[onemach_temp]]) onemach_temp=onemach_h; } onemach_ind[onemach_tabr[onemach_j]]=onemach_temp; onemach_ind[onemach_tabr[onemach_temp]]=onemach_j; onemach_swap(onemach_tabr,onemach_j,onemach_temp); } onemach_time=onemach_p->onemach_rr[onemach_tabr[1]]; onemach_UB1=0; while(onemach_tailler!=0) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[1]]; onemach_jmax=1; for(onemach_j=1;onemach_j<=onemach_tailler;onemach_j++) {if(onemach_p->onemach_rr[onemach_tabr[onemach_j]]<=onemach_time) {if(onemach_p->onemach_qq[onemach_tabr[onemach_j]]>onemach_qmax) {onemach_qmax=onemach_p->onemach_qq[onemach_tabr[onemach_j]]; onemach_jmax=onemach_j; } } else break; } onemach_tseq1++; onemach_seq1[onemach_tseq1]=onemach_tabr[onemach_jmax]; onemach_debut1[onemach_tabr[onemach_jmax]]=onemach_time; if(onemach_time+onemach_P[onemach_tabr[onemach_jmax]]+onemach_qmax>onemach_UB1) onemach_UB1=onemach_time+onemach_P[onemach_tabr[onemach_jmax]]+onemach_qmax; onemach_time=onemach_time+onemach_P[onemach_tabr[onemach_jmax]]; for(onemach_j=onemach_ind[onemach_tabr[onemach_jmax]];onemach_j<onemach_tailler;onemach_j++) {onemach_tabr[onemach_j]=onemach_tabr[onemach_j+1]; onemach_ind[onemach_tabr[onemach_j]]=onemach_j; } onemach_tailler--; onemach_time=max(onemach_p->onemach_rr[onemach_tabr[1]],onemach_time); } onemach_UB=onemach_UB1; for(onemach_j=1;onemach_j<=onemach_tseq1;onemach_j++) {onemach_seq_opt[onemach_j]=onemach_seq1[onemach_j]; onemach_debut_opt[onemach_seq_opt[onemach_j]]=onemach_debut1[onemach_seq_opt[onemach_j]]; } } onemach_noeud * onemach_create_noeud(onemach_noeud *onemach_R) { long onemach_LB,onemach_j; onemach_noeud * onemach_N1; onemach_noeud * onemach_N2; onemach_N1=(onemach_noeud*)malloc(sizeof(onemach_noeud)); onemach_N1->onemach_suiv=NULL; onemach_N1->onemach_n_taille=onemach_R->onemach_n_taille; onemach_N1->onemach_b_inf=onemach_R->onemach_b_inf; for(onemach_j=1;onemach_j<=onemach_R->onemach_n_taille;onemach_j++) {onemach_N1->onemach_n_ens[onemach_j]=onemach_R->onemach_n_ens[onemach_j]; onemach_N1->onemach_rr[onemach_R->onemach_n_ens[onemach_j]]=onemach_R->onemach_rr[onemach_R->onemach_n_ens[onemach_j]]; onemach_N1->onemach_qq[onemach_R->onemach_n_ens[onemach_j]]=onemach_R->onemach_qq[onemach_R->onemach_n_ens[onemach_j]]; } onemach_N1->onemach_qq[onemach_c]=max(onemach_N1->onemach_qq[onemach_c],onemach_somp+onemach_N1->onemach_qq[onemach_ll]); onemach_LB=onemach_pmtn(onemach_N1); onemach_N1->onemach_b_inf=max(onemach_LB,onemach_R->onemach_b_inf); if(onemach_N1->onemach_b_inf<onemach_UB) {onemach_nb_noeud++; onemach_N1->onemach_lev=onemach_R->onemach_lev+1; onemach_maxlev=max(onemach_maxlev,onemach_N1->onemach_lev); } else {free(onemach_N1); onemach_N1=NULL; } onemach_N2=(onemach_noeud*)malloc(sizeof(onemach_noeud)); onemach_N2->onemach_n_taille=onemach_R->onemach_n_taille; onemach_N2->onemach_suiv=NULL; onemach_N2->onemach_b_inf=onemach_R->onemach_b_inf; for(onemach_j=1;onemach_j<=onemach_R->onemach_n_taille;onemach_j++) {onemach_N2->onemach_rr[onemach_R->onemach_n_ens[onemach_j]]=onemach_R->onemach_rr[onemach_R->onemach_n_ens[onemach_j]]; onemach_N2->onemach_n_ens[onemach_j]=onemach_R->onemach_n_ens[onemach_j]; onemach_N2->onemach_qq[onemach_R->onemach_n_ens[onemach_j]]=onemach_R->onemach_qq[onemach_R->onemach_n_ens[onemach_j]]; } onemach_N2->onemach_rr[onemach_c]=max(onemach_N2->onemach_rr[onemach_c],onemach_somp+onemach_minr); onemach_LB=onemach_pmtn(onemach_N2); onemach_N2->onemach_b_inf=max(onemach_LB,onemach_R->onemach_b_inf); if(onemach_N2->onemach_b_inf<onemach_UB) {onemach_nb_noeud++; onemach_N2->onemach_lev=onemach_R->onemach_lev+1; onemach_maxlev=max(onemach_maxlev,onemach_N2->onemach_lev); } else {free(onemach_N2); onemach_N2=NULL; } onemach_N1=onemach_placer(onemach_N1,onemach_R->onemach_suiv); onemach_N2=onemach_placer(onemach_N2,onemach_N1); return onemach_N2; } onemach_noeud * onemach_explorer ( onemach_noeud *onemach_N) {onemach_noeud * onemach_pp=NULL,* onemach_q; long onemach_minq,onemach_hJ,onemach_j; if (onemach_N!=NULL) {if (onemach_N->onemach_b_inf<onemach_UB) {onemach_nb_exp++; onemach_jack(onemach_N); if(onemach_erase==0) {onemach_minr=onemach_N->onemach_rr[onemach_J[1]]; onemach_minq=onemach_N->onemach_qq[onemach_J[1]]; for(onemach_j=2;onemach_j<=onemach_tJ;onemach_j++) {if(onemach_N->onemach_qq[onemach_J[onemach_j]]<onemach_minq) onemach_minq=onemach_N->onemach_qq[onemach_J[onemach_j]]; if(onemach_N->onemach_rr[onemach_J[onemach_j]]<onemach_minr) onemach_minr=onemach_N->onemach_rr[onemach_J[onemach_j]]; } onemach_somp=0; for(onemach_j=1;onemach_j<=onemach_tJ;onemach_j++) onemach_somp=onemach_somp+onemach_P[onemach_J[onemach_j]]; onemach_jack2(onemach_N); onemach_hJ=onemach_minr+onemach_somp+onemach_minq; for(onemach_j=1;onemach_j<=onemach_N->onemach_n_taille;onemach_j++) {if((onemach_appJ[onemach_N->onemach_n_ens[onemach_j]]==0)&&(onemach_P[onemach_N->onemach_n_ens[onemach_j]]>onemach_UB-onemach_hJ)) {if(onemach_N->onemach_rr[onemach_N->onemach_n_ens[onemach_j]]+onemach_P[onemach_N->onemach_n_ens[onemach_j]]+onemach_somp+onemach_N->onemach_qq[onemach_ll]>=onemach_UB) onemach_N->onemach_rr[onemach_N->onemach_n_ens[onemach_j]]=max(onemach_N->onemach_rr[onemach_N->onemach_n_ens[onemach_j]],onemach_minr+onemach_somp); if(onemach_minr+onemach_P[onemach_N->onemach_n_ens[onemach_j]]+onemach_somp+onemach_N->onemach_qq[onemach_N->onemach_n_ens[onemach_j]]>=onemach_UB) onemach_N->onemach_qq[onemach_N->onemach_n_ens[onemach_j]]=max(onemach_N->onemach_qq[onemach_N->onemach_n_ens[onemach_j]],onemach_minq+onemach_somp); if(onemach_N->onemach_rr[onemach_N->onemach_n_ens[onemach_j]]+onemach_P[onemach_N->onemach_n_ens[onemach_j]]+onemach_N->onemach_qq[onemach_N->onemach_n_ens[onemach_j]]>=onemach_UB) goto del; } } onemach_pp=onemach_create_noeud(onemach_N); free(onemach_N); } else {del:onemach_pp=onemach_N->onemach_suiv; free(onemach_N); } } else {onemach_pp=onemach_N->onemach_suiv; free(onemach_N); while(onemach_pp!=NULL) {onemach_q=onemach_pp; onemach_pp=onemach_pp->onemach_suiv; free(onemach_q); } } } return onemach_pp; } double onemach_time,onemach_timeglob=0; struct job { long num; long nb_oper; long num_mach[MAX_K]; }; /*********************************Fonction branch & bound**********************************************************/ long branch_and_bound_one_mach(long r[MAX_J],long q[MAX_J],long onemach_ni) { long onemach_LB=0,onemach_j,tot[MAX_J]; onemach_noeud * onemach_R,*p; clock_t startglob,stopglob,start,stop,reset; startglob=clock(); for(onemach_j=1;onemach_j<=onemach_ni;onemach_j++) tot[onemach_j]=onemach_j; onemach_maxlev=0; onemach_nb_exp=0; onemach_nb_noeud=1; start=clock(); onemach_R=(onemach_noeud*)malloc(sizeof(onemach_noeud)); onemach_R->onemach_n_taille=onemach_ni; onemach_R->onemach_lev=0; for(onemach_j=1;onemach_j<=onemach_ni;onemach_j++) {onemach_R->onemach_n_ens[onemach_j]=tot[onemach_j]; onemach_R->onemach_rr[onemach_R->onemach_n_ens[onemach_j]]=r[onemach_R->onemach_n_ens[onemach_j]]; onemach_R->onemach_qq[onemach_R->onemach_n_ens[onemach_j]]=q[onemach_R->onemach_n_ens[onemach_j]]; } onemach_R->onemach_suiv=NULL; onemach_b_sup0(onemach_R); onemach_R->onemach_b_inf=onemach_pmtn(onemach_R); if(onemach_R->onemach_b_inf<onemach_UB) {exp: onemach_R=onemach_explorer(onemach_R); reset=clock(); onemach_time=(double)(reset-start)/CLOCKS_PER_SEC; if(onemach_time>=onemach_timelimit) {onemach_UBB=onemach_UB; onemach_UB=-1; onemach_LBB=onemach_R->onemach_b_inf; while(onemach_R!=NULL) {p=onemach_R; onemach_R=onemach_R->onemach_suiv; free(p); } } onemach_time=min(onemach_time,onemach_timelimit); onemach_timeglob=(double)(reset-startglob)/CLOCKS_PER_SEC; if(onemach_R!=NULL) goto exp; } stop=clock(); onemach_time=(double)(stop-start)/CLOCKS_PER_SEC; if(onemach_UB!=-1) {for(onemach_j=1;onemach_j<=onemach_n;onemach_j++) {if(onemach_debut_opt[onemach_seq_opt[onemach_j]]<r[onemach_seq_opt[onemach_j]]) onemach_rupture=1; if((onemach_j>1)&&(onemach_debut_opt[onemach_seq_opt[onemach_j]]<onemach_debut_opt[onemach_seq_opt[onemach_j-1]]+onemach_P[onemach_seq_opt[onemach_j-1]])) onemach_rupture=1; if(onemach_debut_opt[onemach_seq_opt[onemach_j]]+onemach_P[onemach_seq_opt[onemach_j]]+q[onemach_seq_opt[onemach_j]]>onemach_UB) onemach_rupture=1; } } stopglob=clock(); onemach_timeglob=(double)(stopglob-startglob)/CLOCKS_PER_SEC; while(onemach_R!=NULL) {p=onemach_R; onemach_R=onemach_R->onemach_suiv; free(p); } return onemach_UB; } /*************************************************Fin branch & bound*********************************************************************/ long LB_ONE_MACH; long calcul_borne() { long cmaxx,j; long relax; long temp_rj[MAX_J],temp_qj[MAX_J]; struct List *help; //CALCUL DE LB BASED ON BRANCH AND BOUND CARLIER LB_ONE_MACH=9999999999; for(relax=1;relax<=NumOfMachines;relax++) { help=OpsOnMachine[relax]; j=1; while(help!=NIL) { temp_rj[j]=head[help->number]; temp_qj[j]=tail[help->number]; onemach_P[j]=OpData[help->number].process_time; j++; help=help->next; } cmaxx=branch_and_bound_one_mach(temp_rj,temp_qj,NumOfJobs);//branch & bound 1|rj,qj|cmax if(cmaxx<=LB_ONE_MACH) { LB_ONE_MACH=cmaxx; } } return(LB_ONE_MACH); } /* ************************************************************************* */ /* */ /* */ /* Export: Procedure Compute_ Compute_Head_Tail: */ /* Calculation of heads and tail based on fixed */ /* disjunctions. */ /* ************************************************************************* */ int op_array[MaxOpProMachine+1]; static void Compute_Head(ActualOp) int ActualOp; { register struct List *help; int op_array[MaxOpProMachine+1]; register int i, max = 0, num, new; help = ConjArcs->pred[ActualOp]; while (help != NIL) { if ((new = OpData[help->number].process_time + head[help->number]) > max) max = new; help = help->next; } help = DisjArcs->pred[ActualOp]; if (help != NIL) { num = 0; while (help != NIL) { op_array[++num] = help->number; help = help->next; } Sort(head, op_array, num); new = head[op_array[1]] + OpData[op_array[1]].process_time; for (i = 2; i <= num; ++i) { new = (new < head[op_array[i]])? head[op_array[i]] : new; new += OpData[op_array[i]].process_time; } } head[ActualOp] = (max < new)? new : max; } static void Compute_Tail(ActualOp) int ActualOp; { register struct List *help; int op_array[MaxOpProMachine+1]; register int i, max = 0, num, new; help = ConjArcs->succ[ActualOp]; while (help != NIL) { if ((new = OpData[help->number].process_time + tail[help->number]) > max) max = new; help = help->next; } help = DisjArcs->succ[ActualOp]; if (help != NIL) { num = 0; while (help != NIL) { op_array[++num] = help->number; help = help->next; } Sort(tail, op_array, num); new = OpData[op_array[1]].process_time + tail[op_array[1]]; for (i = 2; i <= num; ++i) { new = (new < tail[op_array[i]])? tail[op_array[i]] : new; new += OpData[op_array[i]].process_time; } } tail[ActualOp] = (max < new)? new : max ; } //******Compute head and Tail on the copy********// /* ************************************************************************* */ /* */ /* */ /* Export: Procedure Compute_ Compute_Head_Tail: */ /* Calculation of heads and tail based on fixed */ /* disjunctions. */ /* ************************************************************************* */ static void Compute_Head_2mach(ActualOp) int ActualOp; { register struct List *help; int op_array[MaxOpProMachine+1]; register int i, max = 0, num, new; help = ConjArcs_2mach->pred[ActualOp]; while (help != NIL) { if ((new = OpData_2mach[help->number].process_time + head_2mach[help->number]) > max) max = new; help = help->next; } help = DisjArcs_2mach->pred[ActualOp]; if (help != NIL) { num = 0; while (help != NIL) { op_array[++num] = help->number; help = help->next; } Sort(head_2mach, op_array, num); new = head_2mach[op_array[1]] + OpData_2mach[op_array[1]].process_time; for (i = 2; i <= num; ++i) { new = (new < head_2mach[op_array[i]])? head_2mach[op_array[i]] : new; new += OpData_2mach[op_array[i]].process_time; } } head_2mach[ActualOp] = (max < new)? new : max; } static void Compute_Tail_2mach(ActualOp) int ActualOp; { register struct List *help; int op_array[MaxOpProMachine+1]; register int i, max = 0, num, new; help = ConjArcs_2mach->succ[ActualOp]; while (help != NIL) { if ((new = OpData_2mach[help->number].process_time + tail_2mach[help->number]) > max) max = new; help = help->next; } help = DisjArcs_2mach->succ[ActualOp]; if (help != NIL) { num = 0; while (help != NIL) { op_array[++num] = help->number; help = help->next; } Sort(tail_2mach, op_array, num); new = OpData_2mach[op_array[1]].process_time + tail_2mach[op_array[1]]; for (i = 2; i <= num; ++i) { new = (new < tail_2mach[op_array[i]])? tail_2mach[op_array[i]] : new; new += OpData_2mach[op_array[i]].process_time; } } tail_2mach[ActualOp] = (max < new)? new : max ; } /* Procedure for fixing all direct disjunctive arcs on mach_no (3 set conditions) */ boolean new_arcs = false; long OperM[1200]; static boolean Select(mach_no) long mach_no; { struct List *help1,*help2; long Oper[1200],i,j,k,TAILLE; static long M,NN; help1=OpsOnMachine[mach_no]; TAILLE=0; while(help1!=NIL) { TAILLE++; Oper[TAILLE]=help1->number; help1=help1->next; } for(i=1;i<=TAILLE;i++) { for(j=1;j<=TAILLE;j++) { if(Oper[i]!=Oper[j]) { if(head[Oper[i]]+OpData[Oper[i]].process_time>(UpperBound-tail[Oper[j]]-1)-OpData[Oper[j]].process_time) { if(!Member(DisjArcs->pred[Oper[i]], Oper[j])) { DisjArcs->succ[Oper[j]] = Insert(DisjArcs->succ[Oper[j]], Oper[i]); DisjArcs->pred[Oper[i]] = Insert(DisjArcs->pred[Oper[i]], Oper[j]); new_arcs = true; //PARCOURS de TTE LES MACHINE POUR RAJOUTER LA PRECEDENCE if(mach_no<=NumOfMachines) { M=1; while(M<=NumOfMachines) { if(M!=mach_no) { help2=OpsOnMachine_2mach[M]; NN=0; while(help2!=NIL) { NN++; OperM[NN]=help2->number; help2=help2->next; } if(!Member(DisjArcs->pred[OperM[i]], OperM[j])) { DisjArcs->succ[OperM[j]] = Insert(DisjArcs->succ[OperM[j]], OperM[i]); DisjArcs->pred[OperM[i]] = Insert(DisjArcs->pred[OperM[i]], OperM[j]); } } M++; } } } } } } } for(i=1;i<=TAILLE;i++) { for(j=1;j<=TAILLE;j++) { for(k=1;k<=TAILLE;k++) { if(Oper[i]!=Oper[j] && Oper[j]!=Oper[k] && Oper[i]!=Oper[k]) { if((head[Oper[k]]+OpData[Oper[k]].process_time+OpData[Oper[j]].process_time>(UpperBound-tail[Oper[i]]-1)-OpData[Oper[i]].process_time) &&(head[Oper[j]]+OpData[Oper[j]].process_time+OpData[Oper[k]].process_time>(UpperBound-tail[Oper[i]]-1)-OpData[Oper[i]].process_time) &&(head[Oper[j]]+OpData[Oper[j]].process_time+OpData[Oper[i]].process_time>(UpperBound-tail[Oper[k]]-1)-OpData[Oper[k]].process_time)) { if(!Member(DisjArcs->pred[Oper[j]], Oper[i])) { DisjArcs->succ[Oper[i]] = Insert(DisjArcs->succ[Oper[i]], Oper[j]); DisjArcs->pred[Oper[j]] = Insert(DisjArcs->pred[Oper[j]], Oper[i]); new_arcs = true; //PARCOURS de TTE LES MACHINE POUR RAJOUTER LA PRECEDENCE if(mach_no<=NumOfMachines) { M=1; while(M<=NumOfMachines) { if(M!=mach_no) { help2=OpsOnMachine[M]; NN=0; while(help2!=NIL) { NN++; OperM[NN]=help2->number; help2=help2->next; } if(!Member(DisjArcs->pred[OperM[j]], OperM[i])) { DisjArcs->succ[OperM[i]] = Insert(DisjArcs->succ[OperM[i]], OperM[j]); DisjArcs->pred[OperM[j]] = Insert(DisjArcs->pred[OperM[j]], OperM[i]); } } M++; } } } } } } } } return(new_arcs); } void Initialize { int i; ConjArcs = (struct ArcList *) malloc(sizeof(struct ArcList)); DisjArcs = (struct ArcList *) malloc(sizeof(struct ArcList)); for (i = 0; i <= MaxNumOfOperations; ++i) { ConjArcs->pred[i] = ConjArcs->succ[i] = NIL; DisjArcs->pred[i] = DisjArcs->succ[i] = NIL; OpData[i].process_time = 0; OpData[i].machine_nr = 0; } for (i = 0; i <= MaxNumOfMachines; ++i) OpsOnMachine[i] = NIL; } int mini_propa(){ int I; for (I = 1; I <= MaxNumOfOperations; ++I) { Compute_Head(I); Compute_Tail(I); } } int Read_Data() { int i, j, num_of_op_for_job, sum = 1; FILE *fp; fp = fopen("VFR10_5_1_Gap.txt","r"); fscanf(fp,"%d %d ", &NumOfMachines, &NumOfJobs); for (i = 1; i <= NumOfJobs; ++i) { if (!fscanf(fp,"%d ", &num_of_op_for_job)) return(false); if (!fscanf(fp,"%d %d ",&OpData[sum].process_time, &OpData[sum].machine_nr)) return(false); if (num_of_op_for_job == 1) { OpsOnMachine[OpData[sum].machine_nr] =Insert(OpsOnMachine[OpData[sum].machine_nr],sum); ConjArcs->pred[sum] = Insert(ConjArcs->pred[sum],0); ConjArcs->succ[0] = Insert(ConjArcs->succ[0],sum); ConjArcs->succ[sum] = Insert(ConjArcs->succ[sum],MaxNumOfOperations); ConjArcs->pred[MaxNumOfOperations] =Insert(ConjArcs->pred[MaxNumOfOperations],sum); sum ++; } else { OpsOnMachine[OpData[sum].machine_nr] =Insert(OpsOnMachine[OpData[sum].machine_nr],sum); ConjArcs->pred[sum] = Insert(ConjArcs->pred[sum],0); ConjArcs->succ[0] = Insert(ConjArcs->succ[0],sum); ConjArcs->succ[sum] = Insert(ConjArcs->succ[sum],sum+1); sum++; for (j = 2; j < num_of_op_for_job; ++j) { if (!fscanf(fp,"%d %d ",&OpData[sum].process_time, &OpData[sum].machine_nr)) return(false); OpsOnMachine[OpData[sum].machine_nr] =Insert(OpsOnMachine[OpData[sum].machine_nr],sum); ConjArcs->pred[sum] = Insert(ConjArcs->pred[sum],sum-1); ConjArcs->succ[sum] = Insert(ConjArcs->succ[sum],sum+1); sum++; } if (!fscanf(fp,"%d %d ",&OpData[sum].process_time,&OpData[sum].machine_nr)) return(false); OpsOnMachine[OpData[sum].machine_nr] =Insert(OpsOnMachine[OpData[sum].machine_nr],sum); ConjArcs->pred[sum] = Insert(ConjArcs->pred[sum],sum-1); ConjArcs->succ[sum] = Insert(ConjArcs->succ[sum],MaxNumOfOperations); ConjArcs->pred[MaxNumOfOperations] =Insert(ConjArcs->pred[MaxNumOfOperations],sum); sum++; } } fclose(fp); NumOfOperations = --sum; return(0); } int fixer_arc() { } int MAX1(int A, int B){if(A<B) return B; else if(A>B) return A;} int X,Y, c,i,ar,m; int T[MAXTAB][MAXTAB]; /* tableau donné */ int oper[MAXTAB][MAXTAB]; int F; int L, C; /* dimensions */ int I, J,h,g; /* indices courants */ int AIDE; /* pour la permutation */ int PMAX; /* indique la position de l'élément */ /* maximal à droite de A[I] */ /* Saisie des données */ int CMAX; int TS[MAXTAB][MAXTAB]; int tchoix[MAXTAB],tchoix2[MAXTAB]; int k=0; int SOM; int main() { /* Déclarations */ /* Lecture du fichier et saisi du tableau contenant les pij*/ FILE *f; int machine_nr; f=fopen("VFR10_5_1_Gap.txt","r"); fscanf(f,"%d %d ", &L, &C); fclose(f); Initialize(); Read_Data(); J=0; k=1; do{ for(I=0;I<C;I++){ T[J][I]=OpData[k].process_time; k++; } J++; }while(J<L); /* calcul des sommes pour chaque tache et ordonancer la matrice des taches selon un ordre décroissant */ I=0; J=0; k=0; do{ for (SOM=0,J=0; J<C; J++){ SOM += T[I][J]; } TS[0][I]=SOM; TS[1][I]=k; k++; I++; }while(I<L); I=0; for (J=0; J<C-1; J++) { PMAX=J; for (h=J+1; h<C; h++) if (TS[I][h]>TS[I][PMAX] ) PMAX=h; /* Echange de TS[I][J] avec le maximum */ AIDE=TS[I][J]; TS[I][J]=TS[I][PMAX]; TS[I][PMAX]=AIDE; AIDE=TS[I+1][J]; TS[I+1][J]=TS[I+1][PMAX]; TS[I+1][PMAX]=AIDE; } /* saisie du tableau contenant les opérations pour chaque objet */ oper[0][0]=1; J=0;/* 1ère ligne */ for(I=1;I<C;I++){ oper[J][I]= oper[J][I-1] + 1;} J=1; do{ oper[J][0]=oper[J-1][C-1] + 1; for(I=1;I<C;I++){ oper[J][I]= oper[J][I-1] + 1;}J++; } while(J<L); Initialize(); Read_Data(); /* ordonancer les deux premières taches*/ for(J=0;J<C;J++){ DisjArcs->succ[oper[TS[1][0]][J]] = Insert(DisjArcs->succ[oper[TS[1][0]][J]],oper[TS[1][1]][J]); DisjArcs->pred[oper[TS[1][1]][J]] = Insert(DisjArcs->pred[oper[TS[1][1]][J]], oper[TS[1][0]][J]); } calcul_borne(); CMAX=LB_ONE_MACH; tchoix[0]=TS[1][0]; tchoix[1]=TS[1][1]; Initialize(); Read_Data(); for(J=0;J<C;J++){ DisjArcs->succ[oper[TS[1][1]][J]] = Insert(DisjArcs->succ[oper[TS[1][1]][J]], oper[TS[1][0]][J]); DisjArcs->pred[oper[TS[1][0]][J]] = Insert(DisjArcs->pred[oper[TS[1][0]][J]], oper[TS[1][1]][J]); } mini_propa(); calcul_borne(); if(CMAX<LB_ONE_MACH){ tchoix[0]=TS[1][0]; tchoix[1]=TS[1][1];} /* ordonancer le reste des taches */ ar=3; do { for(I=(C*L);I>0;I--){ tchoix[I]=tchoix[I-1];} tchoix[0]=TS[1][ar-1]; /* ajout d'arc calcul borne inf */ h=0; Initialize(); Read_Data(); do{ for(J=0;J<C;J++){ DisjArcs->succ[oper[tchoix[h]][J]] = Insert(DisjArcs->succ[oper[tchoix[h]][J]],oper[tchoix[h+1]][J]); DisjArcs->pred[oper[tchoix[h+1]][J]]= Insert(DisjArcs->pred[oper[tchoix[h+1]][J]],oper[tchoix[h]][J]); } h++;}while(h<(ar-1)); mini_propa(); calcul_borne(); CMAX=LB_ONE_MACH; F=head[MaxNumOfOperations]; for(I=0;I<ar;I++){ tchoix2[I]=tchoix[I];} /*permutation ordre */ X=0; Y=1; do{ c=tchoix[X]; tchoix[X]=tchoix[Y]; tchoix[Y]=c; Initialize(); Read_Data(); h=0; do{ for(J=0;J<C;J++){ DisjArcs->succ[oper[tchoix[h]][J]] = Insert(DisjArcs->succ[oper[tchoix[h]][J]],oper[tchoix[h+1]][J]); DisjArcs->pred[oper[tchoix[h+1]][J]] = Insert(DisjArcs->pred[oper[tchoix[h+1]][J]],oper[tchoix[h]][J]); } h++;}while(h<(ar-1)); mini_propa(); calcul_borne(); if(LB_ONE_MACH<CMAX){ F=head[MaxNumOfOperations]; CMAX=LB_ONE_MACH; for(I=0;I<ar;I++){ tchoix2[I]=tchoix[I];} } X++; Y++;}while(X<(ar-1)); for(I=0;I<ar;I++){ tchoix[I]=tchoix2[I];} ar++; }while(ar<(L+1)); printf("%d\n",CMAX); printf("%d\n",F); system("pause"); }
EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI Merci d'y penser dans tes prochains messages. |
Franck7511
Messages postés
14296
Date d'inscription
jeudi 24 décembre 2009
Statut
Membre
Dernière intervention
10 août 2017
1 121
12 août 2016 à 16:34
12 août 2016 à 16:34
As-tu utilisé un debugger pour voir d'où le problème vient ?
Le debugger te permettra de voir d'où l'erreur vient, ainsi que le Call Stack et les paramètres passés aux fonctions...
On dirait une déréférence de pointeur NULL ton problème.
Le debugger te permettra de voir d'où l'erreur vient, ainsi que le Call Stack et les paramètres passés aux fonctions...
On dirait une déréférence de pointeur NULL ton problème.
jisisv
Messages postés
3645
Date d'inscription
dimanche 18 mars 2001
Statut
Modérateur
Dernière intervention
15 janvier 2017
934
Modifié par jisisv le 13/08/2016 à 16:00
Modifié par jisisv le 13/08/2016 à 16:00
Ceci fonctionne mieux:
<run>
Gates gave ^W sold you the windows.
GNU gave us the whole house.(Alexandrin)
#include <stdlib.h> #include <stdio.h> struct List { int number; struct List *next; }; struct List *Insert(struct List **aList, int Op) { register struct List *help, *tmp; if ( *aList == NULL ) { tmp = (struct List *) malloc(sizeof(struct List)); tmp->number = Op; tmp->next = NULL; printf("aList created %p \n", tmp); return tmp; } else { /* TODOutiliser tmp au lieu de help */ help = *aList; while ( help->next != NULL ) help = help->next; /* TODO utiliser une variable intermédiaire */ help->next = (struct List *) malloc(sizeof(struct List)); help->next->number = Op; help->next->next = NULL; help = help->next; return(*aList); } } int main(int argc, char *argv[]) { int i; struct List *myList = NULL, *tmp; for (i = 0 ; i < 1000 ; i++) { myList = Insert(&myList, i); } printf("%p\n", *myList); tmp = myList; while( NULL != tmp) { printf("%d %p\n", tmp->number, tmp); tmp = tmp -> next; } return EXIT_SUCCESS; }
<run>
johand@bata:~/src/CCM/C/liste2016-08$ ./testliste-02 | tail -5</run>
995 0x170bc80
996 0x170bca0
997 0x170bcc0
998 0x170bce0
999 0x170bd00
Gates gave ^W sold you the windows.
GNU gave us the whole house.(Alexandrin)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
jisisv
Messages postés
3645
Date d'inscription
dimanche 18 mars 2001
Statut
Modérateur
Dernière intervention
15 janvier 2017
934
14 août 2016 à 05:24
14 août 2016 à 05:24
Et évidemment plus simple:
#include <stdlib.h> #include <stdio.h> struct List { int number; struct List *next; }; struct List *Insert(struct List *aList, int Op) { register struct List *help; if ( aList == NULL ) { aList = (struct List *) malloc(sizeof(struct List)); aList->number = Op; aList->next = NULL; /* printf("aList created %p \n", aList); */ } else { help = aList; while ( help->next != NULL ) help = help->next; help->next = (struct List *) malloc(sizeof(struct List)); help->next->number = Op; help->next->next = NULL; help = help->next; } return(aList); } int main(int argc, char *argv[]) { int i; struct List *myList = NULL, *tmp; for (i = 0 ; i < 100 ; i++) { myList = Insert(myList, i); } printf("%p\n", myList); tmp = myList; while( NULL != tmp) { printf("%p %d\n", tmp , tmp->number); tmp = tmp -> next; } return EXIT_SUCCESS; }
Amiro90
Messages postés
8
Date d'inscription
mercredi 10 août 2016
Statut
Membre
Dernière intervention
10 février 2017
31 août 2016 à 18:42
31 août 2016 à 18:42
problème réglé je lisais les fichiers de la bechmark ruiz avec un code qui lit celle de taillard (problème de lecture de fichiers d'autre forme que celle dans le code)