Changeset 89 for vtcross

Show
Ignore:
Timestamp:
11/27/08 21:32:50 (16 years ago)
Author:
ahe
Message:

fixed the bug, experience transmission works

Location:
vtcross/branches/trnewman/CR_engines/CBR/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/trnewman/CR_engines/CBR/src/cbr.c

    r88 r89  
    8585        } else { 
    8686            printf("no matched rearch results. use default values\n"); 
    87             // set default values 
     87             
    8888            _retvals[0] = 100;  // throughput 
    8989            _retvals[1] = 1;    // spectral_efficiency 
  • vtcross/branches/trnewman/CR_engines/CBR/src/main_cognitive_engine.c

    r88 r89  
    303303    ReadMessage(sockfd,buffer); 
    304304    *num_cols = atoi(buffer); 
    305     /*printf("number of rows: %d, number of columns: %d\n",  
    306             *num_rows, *num_cols); */ 
    307305    return 1; 
    308306} 
     
    310308 
    311309int GetExperience(int sockfd, int num_rows, int num_cols,  
    312         float **past_exp) 
     310        //float **past_exp) 
     311        float past_exp[num_rows][num_cols]) 
    313312{ 
    314313    char buffer[256]; 
     
    380379int RunCBREngine(struct Utility uList[], struct Parameter pList[], 
    381380        struct Observable oList[], struct CE_Info *ce_info,  
    382         int num_cols, int num_rows, float ** past_exp) 
     381        //int num_cols, int num_rows, float ** past_exp) 
     382        int num_cols, int num_rows, float past_exp[num_rows][num_cols]) 
    383383{ 
    384384     
     
    386386 
    387387    // get column names 
    388     //char *cols[50]; 
     388    /*char *cols[50] = {"throughput", "spectral_efficiency",  
     389    "log10_ber", "mod_scheme", "tx_power", "SNR", "utility"};*/ 
    389390    //char cols[num_cols][50]; 
     391     
    390392    char **cols; 
    391393    cols = (char **)malloc(sizeof(char)*num_cols); 
     
    409411        j++; 
    410412    } 
    411     printf("number of columns: %d, %d\n", num_cols, j); 
    412413    cols[j] = malloc(strlen("utility")+1); 
    413414    cols[j] = "utility"; 
    414     //strcpy(cols[j], "utility"); 
    415     printf("here\n"); 
    416      
    417     printf("number of columns: %d\n", num_cols); 
     415     
    418416    printf("column names:"); 
    419417    for (i = 0; i<num_cols; i++){ 
     
    429427    cbr mycbr = cbr_create(filename, tablename, cols, num_cols); 
    430428    //cbr mycbr = cbr_create("ex1", "data", cols, num_cols); 
    431      
     429 
    432430    // add row here 
    433431    float vals[num_cols]; 
     
    440438    vals[5] = 10.0f;   // SNR 
    441439    vals[6] = 0.762;    // utility*/ 
    442     printf("here\n"); 
    443440    for (i = 0; i < num_rows; i++){ 
    444441        for (j = 0; j < num_cols; j++){ 
    445442            vals[j] = past_exp[i][j]; 
    446443        } 
    447         printf("add row to cbr table\n"); 
    448444        rc = cbr_add_row(mycbr, cols, vals, num_cols); 
    449445    } 
     
    542538    print_current_config(uList, pList, oList, &ce_info);  
    543539 
    544     // get experience size rom server 
     540    // get experience size from server 
    545541    int num_rows, num_cols; 
    546542    GetExperienceSize(sockfd, &num_rows, &num_cols); 
    547     //printf("number of rows: %d, number of columns: %d\n",  
    548     //        num_rows, num_cols);  
    549543    // get experience 
    550     float **past_exp; 
    551544    int i, j; 
     545    /*float **past_exp; 
    552546    past_exp = (float **)malloc(sizeof(float)*num_rows); 
    553547    for (i = 0; i< 1; i++){ 
    554548        past_exp[i] = (float*)malloc(sizeof(float)*num_cols); 
    555     } 
     549    }*/ 
     550    float past_exp[num_rows][num_cols]; 
    556551    GetExperience(sockfd, num_rows, num_cols, past_exp); 
    557552    for (i = 0; i < num_rows; i++){ 
     553        printf("experience #%d:\n", i+1); 
    558554        for (j = 0; j < num_cols; j++){ 
    559         printf("experience: %f\n", past_exp[i][j]); 
    560         } 
     555        printf(" %f", past_exp[i][j]); 
     556        } 
     557        printf("\n"); 
    561558    } 
    562559