Changeset 95 for vtcross/trunk/CR_engines
- Timestamp:
- 02/09/09 16:51:58 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/CR_engines/CBR/src/main_cognitive_engine.c
r89 r95 285 285 strcpy(buffer, "xml received"); 286 286 SendMessage(sockfd, buffer); 287 printf("xml reception done\n");287 //printf("xml reception done\n"); 288 288 289 289 return 1; … … 306 306 } 307 307 308 int GetRequest(int sockfd) 309 { 310 char buffer[256]; 311 312 bzero(buffer,256); 313 ReadMessage(sockfd,buffer); 314 315 return 1; 316 } 308 317 309 318 int GetExperience(int sockfd, int num_rows, int num_cols, … … 536 545 // get xml info from server 537 546 GetXMLFromServer(sockfd, uList, pList, oList, &ce_info); 538 print_current_config(uList, pList, oList, &ce_info); 539 547 printf("Received Radio Operation Profile from Server Successfully.\n\n"); 548 //print_current_config(uList, pList, oList, &ce_info); 549 550 540 551 // get experience size from server 541 552 int num_rows, num_cols; 542 553 GetExperienceSize(sockfd, &num_rows, &num_cols); 554 543 555 // get experience 544 556 int i, j; 545 /*float **past_exp;546 past_exp = (float **)malloc(sizeof(float)*num_rows);547 for (i = 0; i< 1; i++){548 past_exp[i] = (float*)malloc(sizeof(float)*num_cols);549 }*/550 557 float past_exp[num_rows][num_cols]; 551 558 GetExperience(sockfd, num_rows, num_cols, past_exp); 552 for (i = 0; i < num_rows; i++){ 553 printf("experience #%d:\n", i+1); 554 for (j = 0; j < num_cols; j++){ 555 printf(" %f", past_exp[i][j]); 556 } 557 printf("\n"); 558 } 559 559 printf("Received Previous Radio Experience from Server Successfully.\n\n"); 560 560 561 // calculate utility 561 562 562 563 563 // cbr operation … … 567 567 num_cols = num_cols + ce_info.numObservables; 568 568 num_cols = num_cols + 1; // overall utility 569 printf("number of rows: %d, number of columns: %d\n", 570 num_rows, num_cols); 571 RunCBREngine(uList, pList, oList, &ce_info, num_cols, num_rows, 569 570 //while(1) { 571 572 // Wait until request is received from server to perform optimization 573 //printf("Waiting for Request for optimization from Server\n\n"); 574 //GetRequest(sockfd); 575 //printf("Received optimization request from server\n\n"); 576 RunCBREngine(uList, pList, oList, &ce_info, num_cols, num_rows, 572 577 past_exp); 573 // print out results 574 //int i; 575 printf("search result: "); 576 for (i=0;i<ce_info.numUtilities; i++) 577 printf("%f, ",uList[i].value); 578 for (i=0;i<ce_info.numParameters; i++) 579 printf("%f, ",pList[i].value); 580 for (i=0;i<ce_info.numObservables; i++) 581 printf("%f, ",oList[i].value); 582 printf("\n"); 583 584 // send results back to server 585 SendCEResults(sockfd, uList, pList, oList, &ce_info); 586 587 588 return 0; 589 } 578 579 printf("Sending optimization results to server.\n\n"); 580 // send results back to server 581 SendCEResults(sockfd, uList, pList, oList, &ce_info); 582 //} 583 584 return 0; 585 }