- Timestamp:
- 07/29/09 00:31:04 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp
r389 r390 44 44 SML_present = false; 45 45 commandSocketFD = -1; 46 srand ( time(NULL) ); 46 47 } 47 48 … … 274 275 LOG("Cognitive Engine:: Processing parameters....\n"); 275 276 276 Parameter *solutionSet;277 278 //solutionSet = GetSolution(o,cp);279 280 277 // TODO need to actually do something with the observables here 281 278 282 279 LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n"); 283 280 char numParametersChar[10]; 284 char solutionValue[50];285 281 sprintf(numParametersChar, "%i", radioInfo->numParameters); 286 282 SendMessage(commandSocketFD, numParametersChar); 287 283 for(size_t i = 0; i < radioInfo->numParameters; i++) { 288 //SendMessage(commandSocketFD, solutionSet[i].name.c_str());289 284 SendMessage(commandSocketFD, "test"); 290 //memset(solutionValue, 0, 50);291 //sprintf(solutionValue, "%f", solutionSet[i].value);292 //SendMessage(commandSocketFD, solutionValue);293 285 SendMessage(commandSocketFD, "00"); 294 286 } … … 649 641 /* Put together the CBR search array */ 650 642 651 char *searchNames[ radioInfo->numUtilities +1];652 float searchVals[ radioInfo->numUtilities +1];653 int searchOps[ radioInfo->numUtilities +1];643 char *searchNames[1]; 644 float searchVals[1]; 645 int searchOps[1]; 654 646 uint32_t numberColumns = radioInfo->numUtilities + 655 647 radioInfo->numParameters + 656 648 radioInfo->numObservables + 1; 657 649 658 for(size_t i = 0; i < radioInfo->numUtilities; i++) {659 searchNames[i] = (char*)uList[i].name.c_str();660 661 if(strcmp(uList[i].goal.c_str(), "max") == 0) {662 searchOps[i] = GT;663 } else if(strcmp(uList[i].goal.c_str(), "min") == 0) {664 searchOps[i] = LT;665 }666 667 /* Set search target to utility target */668 /* This may be bad if no target is set */669 searchVals[i] = uList[i].target;670 }671 672 673 650 /* Make sure we do not return any entries for the current channel */ 674 searchNames[ radioInfo->numUtilities+1] = "channel";675 searchOps[ radioInfo->numUtilities+1] = NE;676 searchVals[ radioInfo->numUtilities+1] = currentParameters[0].value;651 searchNames[0] = "channel"; 652 searchOps[0] = NE; 653 searchVals[0] = currentParameters[0].value; 677 654 678 655 float returnValues[numberColumns]; … … 680 657 /* Execute CBR search and put output into returnValues */ 681 658 uint32_t rc = cbr_search(myCBR, searchNames, searchOps, searchVals, 682 radioInfo->numUtilities, returnValues);659 1, returnValues); 683 660 684 661 if(rc == 0){ … … 688 665 LOG("Cognitive Engine:: Previous similar environment found\n"); 689 666 667 /* generate random channel */ 668 returnValues[CHANNEL] = rand() % (int)pList[0].max + (int)pList[0].min; 669 690 670 if(returnValues[numberColumns-1] < 0) { 691 692 returnValues[2] = returnValues[2] - 15;693 returnValues[3] = returnValues[3] - 2;694 671 695 672 } else { 696 673 697 returnValues[2] = returnValues[2] + 15;698 returnValues[3] = returnValues[3] + 2;699 700 674 } 701 675 } else if(rc == 31337) { … … 703 677 LOG("Cognitive Engine:: No previous similar environment found.\n"); 704 678 705 /* In the DSA case, the default is to select a random channel */706 707 /* initialize random seed: */708 srand ( time(NULL) );709 710 679 /* generate random channel */ 711 //returnValues[CHANNEL] = rand() % currentParameters[0].max + currentParameters[0].min; 712 returnValues[CHANNEL] = rand() % 5; 713 714 printf("One: %i Two: %i\n",(int)currentParameters[0].max,(int)currentParameters[0].min); 715 680 returnValues[CHANNEL] = rand() % (int)pList[0].max + (int)pList[0].min; 716 681 } else { 717 682 LOG("Cognitive Engine:: Search return an invalid value.\n");