Ejemplo n.º 1
0
int main(int argc, char * argv[]){



    srand(time(NULL));


    //exactTest(11,200);
            int n1 = 0;
            instance_t* t = instanceCreer(10,"test");
            instanceInit(t); 
            instanceRandNC(t);
            
            //instanceAfficher(t);
          	//instance_t* johnlogn = johnsonnlogn(t,0);
	        //instanceAfficher(johnlogn);
          
            instance_t * sol = branch_bound(t,&n1);
          
            //printf("Solution finale :");
            //instanceAfficher(sol);
            
            instanceDetruire(sol);
             instanceDetruire(t);
    
    return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
void instanceRandNC(instance_t * inst){
    instanceInit(inst);
	for(int i = 0;i<inst->nb_elem;i++){
	    inst->ordre[i] = i;
	    inst->A[i] = aleatoire(1,100);
	    inst->B[i] = aleatoire(1,100);
	    inst->C[i] = aleatoire(1,100);
	}
}
Ejemplo n.º 3
0
instance_t * instanceRead(char * name){

    FILE *ifp;
    int buff;
    instance_t * inst = NULL;

    ifp = fopen(name, "r");

    if (ifp == NULL) {
      fprintf(stderr, "Can't open input file.\n");
      exit(1);
    }
    
    //Lecture du nombre de taches
    if(fscanf(ifp, "%i", &(buff)) != 1){
        fprintf(stderr, "Error while reading file.\n");
        exit(1);
    }
    
    inst = instanceCreer(buff,name);
    instanceInit(inst);
    
    //Lecture du tableau A
    for(int i = 0;i<inst->nb_elem;i++){
        if(fscanf(ifp, "%i",&(inst->A[i])) != 1){
            fprintf(stderr, "Error while reading file.\n");
            exit(1);
        }
    
    }
    //Lecture du tableau B
    for(int i = 0;i<inst->nb_elem;i++){
        if(fscanf(ifp, "%i",&(inst->B[i]))!= 1){
            fprintf(stderr, "Error while reading file.\n");
            exit(1);
        }
    }
    //Lecture du tableau C
    for(int i = 0;i<inst->nb_elem;i++){
        if(fscanf(ifp, "%i",&(inst->C[i]))!= 1){
            fprintf(stderr, "Error while reading file.\n");
            exit(1);
        }
    }
    
    fclose(ifp);
    return inst;
}
Ejemplo n.º 4
0
void exactTest(int instMax,int loop){
    float c1 = 0.0;
    float c2 = 0.0;
    float c3 = 0.0;
    int n1 = 0;
    int n2 = 0;
    int n3 = 0;
    
    chrono();
    for(int i = 0;i<instMax;i++){
        for(int j = 0;j<loop;j++){
            instance_t* t = instanceCreer(i,"test");
            instanceInit(t); 
            instanceRandNC(t);
            
            //instanceAfficher(t);
          	//instance_t* johnlogn = johnsonnlogn(t,0);
	        //instanceAfficher(johnlogn);
          
            instance_t * sol = branch_bound(t,&n1);
          
            //printf("Solution finale :");
            //instanceAfficher(sol);
            
            instanceDetruire(sol);
            

            c1 += chrono();
            
            instanceRandDE(t);                      
            sol = branch_bound(t,&n2);                      
            instanceDetruire(sol);
            c2 += chrono();
            
            instanceRandM(t);                      
            sol = branch_bound(t,&n3);                      
            instanceDetruire(sol);
            c3 += chrono();
            
            
            instanceDetruire(t);
            
        }
        printf("%i %.5f %.5f %.5f %i %i %i\n",i,c1/loop,c2/loop,c3/loop,n1/loop,n2/loop,n3/loop);
    }

}
Ejemplo n.º 5
0
void johnsonTest(int instMax){
  
    float c1 = 0.0;
    float c2 = 0.0;
    float c3 = 0.0;
    float c4 = 0.0;
    float c5 = 0.0;
    float c6 = 0.0;
    for(int i = 0;i<instMax;i+=100){
        instance_t* t = instanceCreer(i,"test");
        instanceInit(t);
 
        instanceRandNC(t);
        
        chrono();  
        instanceDetruire(johnsonnlogn(t,0));
        c1 = chrono();  
        instanceDetruire(johnson(t));
        c2 = chrono();  
        
        instanceRandDE(t);
        chrono();  
        instanceDetruire(johnsonnlogn(t,0));
        c3 = chrono();  
        instanceDetruire(johnson(t));
        c4 = chrono();  
        
        instanceRandM(t);
        
        chrono();  
        instanceDetruire(johnsonnlogn(t,0));
        c5 = chrono();  
        instanceDetruire(johnson(t));
        c6 = chrono();  
        printf("%i %.4f %.4f %.4f %.4f %.4f %.4f\n",i,c2,c1,c4,c3,c6,c5);
        instanceDetruire(t);
    }
}
	virtual void init(int samplingFreq) {
		classInit(samplingFreq);
		instanceInit(samplingFreq);
	}
Ejemplo n.º 7
0
  virtual void init(int samplingFreq) {
		classInit(samplingFreq);
		instanceInit(samplingFreq);
		FFTInit(); //one fft for now
	}