- Timestamp:
- 05/20/10 17:44:31 (14 years ago)
- Location:
- vtcross/branches/nikhil/crossmodel2/src/cognitive_engines/CBR_CE
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/branches/nikhil/crossmodel2/src/cognitive_engines/CBR_CE/CBR_CE.cpp
r562 r563 27 27 // ZERO is consider +1 sign 28 28 inline int signof(int nos) { return ( (nos < 0) ? -1:1 ); } 29 //inline int signof(int nos) { return (nos==0)?0:(nos<0?-1:1); } 29 30 30 31 31 … … 43 43 { 44 44 LOG("Cognitive Engine:: Generating solution.\n"); 45 46 std::cout << "Ptune value: " << optList->Ptune << std::endl;47 // std::cout << "slope values: " << Slope[0] << std::endl;48 // std::cout << "slope values: " << Slope[1] << std::endl;49 45 50 46 string searchNames[radioInfo->numUtilities]; … … 99 95 100 96 FineTune(); 101 /* 102 No need or random adaptation since it will get updated 103 using update function call 104 if(returnValues[numberColumns-1] < 0) { 105 returnValues[2] = returnValues[2] - 15; 106 returnValues[3] = returnValues[3] - 2; 107 } else { 108 returnValues[2] = returnValues[2] + 15; 109 returnValues[3] = returnValues[3] + 2; 110 } 111 */ 97 112 98 } else if(rc == 31337) { 113 99 LOG("Cognitive Engine:: Not Found.\n"); … … 208 194 string setList[setLen]; 209 195 210 /* 211 size_t columnObsIndex = 0; 212 for (size_t i = 0; i < radioInfo->numObservables; i++){ 213 obsList[columnObsIndex] = observables[i].name; 214 columnObsIndex++; 215 } 216 obsList[columnObsIndex] = "utility"; 217 218 size_t columnIndex = 0; 219 for (size_t i = 0; i < radioInfo->numParameters; i++){ 220 nameList[columnIndex] = parameters[i].name; 221 columnIndex++; 222 } 223 for (size_t i = 0; i < radioInfo->numUtilities; i++){ 224 nameList[columnIndex] = uList[i].name; 225 columnIndex++; 226 } 227 228 size_t obsValueIndex = 0; 229 for(size_t i = 0; i < radioInfo->numObservables; i++) { 230 obsVals[obsValueIndex] = observables[i].value; 231 obsValueIndex++; 232 } 233 234 /// Calculate Utility 235 float newUtilityValue = 0; 236 237 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 238 newUtilityValue = newUtilityValue + (uList[i].target - observables[i].value); 239 } 240 obsVals[obsValueIndex] = newUtilityValue; 241 242 size_t returnValueIndex = 0; 243 for(size_t i = 0; i < radioInfo->numParameters; i++) { 244 valList[returnValueIndex] = parameters[i].value; 245 returnValueIndex++; 246 } 247 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 248 valList[returnValueIndex] = uList[i].target; 249 returnValueIndex++; 250 } 251 */ 196 197 // Calculating total weight 252 198 float TotalWeight = 0; 253 199 int Penalty = 10; … … 276 222 setList[returnValueIndex] = "TotalWeight"; 277 223 setValue[returnValueIndex] = TotalWeight; 224 ///// 278 225 279 226 myCBR1->Update(whereList,setList,whereValue,setValue,whereLen,setLen); 280 227 281 // MAIN CODE HERE //228 // MAIN SELF LEARNING CODE HERE // 282 229 283 230 int searchOps[radioInfo->numParameters]; … … 368 315 } 369 316 370 317 std::cout << "Ptune " << optList->Ptune << std::endl; 371 318 std::cout << "Status1 " << optList->Status[0][0] << std::endl; 372 319 std::cout << "Status2 " << optList->Status[1][0] << std::endl; … … 375 322 std::cout << "Trend1 " << optList->Trend[0][0] << std::endl; 376 323 std::cout << "Trend2 " << optList->Trend[1][0] << std::endl; 324 377 325 /// end of MAIN CODE // 326 327 378 328 } 379 329 … … 387 337 //// NEW SET OF VARIABLES /// 388 338 389 // float * Pweights = new float[radioInfo->numParameters];390 339 optList->Uweights = new float[radioInfo->numUtilities]; 391 340 optList->Pweights = new float[radioInfo->numParameters]; 341 optList->Slope = new int[radioInfo->numParameters]; 392 342 393 343 ///// we have to assume 10 utilities maxxx!!!! VERY important … … 395 345 optList->Status = new float[radioInfo->numParameters][10]; 396 346 optList->Trend = new float[radioInfo->numParameters][10]; 397 optList->PoC = 0.01; 398 optList->Slope = new int[radioInfo->numParameters]; 399 optList->Ptune = 0; // starting with most tunable parameter.. (widest range..) 400 401 402 ////////////initializing here since initialsetting giving wierd errors///// 347 ////////////////////////////////////////////////////////////// 348 349 350 ////////////initializing Opt_List members here///// 351 352 optList->PoC = 0.01; 353 optList->Ptune = 0; // starting with most tunable parameter.. (widest range .. ) 403 354 404 355 for (int x = 0; x < radioInfo->numParameters; x++) { … … 428 379 uint32_t numberColumns = radioInfo->numParameters + radioInfo->numUtilities \ 429 380 + radioInfo->numObservables + 1; 430 431 uint32_t numberParameters = radioInfo->numParameters;432 uint32_t numberUtilities = radioInfo->numUtilities;433 381 434 382 string cols[numberColumns]; … … 613 561 } 614 562 615 void CBR_CE::InitialSetting()616 {617 618 std::cout << "inside initilsetting method" << std::endl;619 620 for (int x = 0; x < radioInfo->numParameters; x++) {621 std::cout << x << std::endl;622 optList->Pweights[x] = 1/(pList[x].step);623 optList->Slope[x] = 0;624 }625 626 627 628 for (size_t i = 0; i < radioInfo->numUtilities; i++) {629 optList->Uweights[i] = 1;630 }631 632 633 for (size_t i = 0; i < radioInfo->numParameters; i++) {634 for (size_t k = 0; k < radioInfo->numUtilities; k++) {635 optList->Status[i][k] = 0;636 optList->Trend[i][k] = 0;637 }638 }639 640 }641 642 563 643 564 void -
vtcross/branches/nikhil/crossmodel2/src/cognitive_engines/CBR_CE/CBR_CE.h
r562 r563 95 95 * cognitive engine's functionality. 96 96 */ 97 void InitialSetting();98 97 99 98 void PerformUpdatePerformance(); … … 106 105 CBR *myCBR1; 107 106 CBR *myCBR2; 108 /*109 private:110 107 111 float * Pweights;112 float * Uweights;113 114 float (*Status)[10];115 // this array stores the relationship between all parameters vs utilities..116 float (*Trend)[10];117 118 int * Slope;119 120 float PoC;121 // this term represents percentage of change.. as in if this min PoC122 // is not detected its as good as no change..123 int Ptune;124 // This is pointer to correspont to which parameter to tune..125 // AS OF NOW ONLY ONE AT A TIME PER CYCLE126 */127 108 128 109 };