340 | | void UpdateCEExperience(float * exp[]) { |
341 | | |
| 340 | void UpdateCEExperience(int socketfd, int num_rows, int num_cols, |
| 341 | float * past_exp[]) |
| 342 | { |
| 343 | char buffer[256]; |
| 344 | int i, j; |
| 345 | char counter[55]; |
| 346 | char var[50]; |
| 347 | |
| 348 | for (i = 0; i < num_rows; i++){ |
| 349 | for (j = 0; j< num_cols; j++){ |
| 350 | sprintf(var,"%f",past_exp[i][j]); |
| 351 | printf("%f, \n", past_exp[i][j]); |
| 352 | printf("%s, \n", var); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // send the number of rows to the ce first |
| 357 | sprintf(counter,"%d",num_rows); |
| 358 | SendMessage(socketfd,counter); |
| 359 | // send the number of columns to the ce |
| 360 | sprintf(counter,"%d",num_cols); |
| 361 | SendMessage(socketfd,counter); |
| 362 | // update ce with experience |
| 363 | for (i = 0; i < num_rows; i++){ |
| 364 | for (j = 0; j< num_cols; j++){ |
| 365 | sprintf(var,"%f",past_exp[i][j]); |
| 366 | SendMessage(socketfd,var); |
| 367 | } |
| 368 | } |
411 | | UpdateCEExperience(past_exp); |
412 | | } |
413 | | |
414 | | void StartMessaging(int socketfd, Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) { |
415 | | |
416 | | float **past_exp; |
417 | | |
| 436 | // need to initialize |
| 437 | //UpdateCEExperience(socketfd, num_rows, num_cols, past_exp); |
| 438 | } |
| 439 | |
| 440 | void StartMessaging(int socketfd, Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) |
| 441 | { |
420 | | UpdateCEExperience(past_exp); |
| 444 | // cr experience |
| 445 | float **past_exp; |
| 446 | int num_cols; |
| 447 | // get number of columns |
| 448 | num_cols = ce_info->numUtilities + ce_info->numParameters; |
| 449 | num_cols = num_cols + ce_info->numObservables; |
| 450 | num_cols = num_cols + 1; // overall utility |
| 451 | int num_rows = 1; |
| 452 | past_exp = (float **)malloc(sizeof(float)*num_rows); |
| 453 | int i; |
| 454 | for (i=0; i<num_rows; i++){ |
| 455 | past_exp[i] = (float*)malloc(sizeof(float)*num_cols); |
| 456 | } |
| 457 | // sample experience #1 |
| 458 | past_exp[0][0] = 1e3f; // throughput |
| 459 | past_exp[0][1] = 1; // spectral_efficiency |
| 460 | past_exp[0][2] = -3.5; // log10_ber |
| 461 | past_exp[0][3] = 1; // mod_scheme |
| 462 | past_exp[0][4] = -3.5; // tx_power |
| 463 | past_exp[0][5] = 10.0; // SNR |
| 464 | past_exp[0][6] = 0.762; // overall utility |
| 465 | /*// sample experience #2 |
| 466 | past_exp[1][0] = 1e2f; // throughput |
| 467 | past_exp[1][1] = 1; // spectral_efficiency |
| 468 | past_exp[1][2] = -3.5; // log10_ber |
| 469 | past_exp[1][3] = 1; // mod_scheme |
| 470 | past_exp[1][4] = -3.5; // tx_power |
| 471 | past_exp[1][5] = 3.0; // SNR |
| 472 | past_exp[1][6] = 0.462; // overall utility*/ |
| 473 | |
| 474 | |
| 475 | // update ce with experience |
| 476 | UpdateCEExperience(socketfd, num_rows, num_cols, past_exp); |