Changeset 563

Show
Ignore:
Timestamp:
05/20/10 17:44:31 (14 years ago)
Author:
nikhil
Message:

final codes

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  
    2727// ZERO is consider +1 sign 
    2828inline int signof(int nos) { return ( (nos < 0) ? -1:1 ); } 
    29 //inline int signof(int nos) { return (nos==0)?0:(nos<0?-1:1); } 
     29 
    3030 
    3131 
     
    4343{ 
    4444    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; 
    4945 
    5046    string searchNames[radioInfo->numUtilities]; 
     
    9995         
    10096        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 
    11298    } else if(rc == 31337) { 
    11399        LOG("Cognitive Engine:: Not Found.\n"); 
     
    208194    string setList[setLen]; 
    209195 
    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 
    252198        float TotalWeight = 0; 
    253199        int Penalty = 10; 
     
    276222        setList[returnValueIndex] = "TotalWeight"; 
    277223        setValue[returnValueIndex] = TotalWeight;  
     224///// 
    278225         
    279226myCBR1->Update(whereList,setList,whereValue,setValue,whereLen,setLen); 
    280227 
    281 // MAIN CODE HERE // 
     228// MAIN SELF LEARNING CODE HERE // 
    282229 
    283230int searchOps[radioInfo->numParameters]; 
     
    368315    } 
    369316 
    370  
     317   std::cout << "Ptune " << optList->Ptune << std::endl; 
    371318   std::cout << "Status1 " << optList->Status[0][0] << std::endl; 
    372319   std::cout << "Status2 " << optList->Status[1][0] << std::endl; 
     
    375322   std::cout << "Trend1 " << optList->Trend[0][0] << std::endl; 
    376323   std::cout << "Trend2 " << optList->Trend[1][0] << std::endl; 
     324 
    377325 /// end of MAIN CODE // 
     326 
     327 
    378328} 
    379329 
     
    387337        //// NEW SET OF VARIABLES /// 
    388338 
    389 //      float * Pweights = new float[radioInfo->numParameters]; 
    390339        optList->Uweights = new float[radioInfo->numUtilities]; 
    391340        optList->Pweights = new float[radioInfo->numParameters]; 
     341        optList->Slope = new int[radioInfo->numParameters]; 
    392342 
    393343///// we have to assume 10 utilities maxxx!!!! VERY important 
     
    395345        optList->Status = new float[radioInfo->numParameters][10]; 
    396346        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 .. ) 
    403354 
    404355        for (int x = 0; x < radioInfo->numParameters; x++) { 
     
    428379    uint32_t numberColumns = radioInfo->numParameters + radioInfo->numUtilities \ 
    429380                             + radioInfo->numObservables + 1; 
    430  
    431     uint32_t numberParameters = radioInfo->numParameters; 
    432     uint32_t numberUtilities = radioInfo->numUtilities; 
    433381 
    434382    string cols[numberColumns]; 
     
    613561} 
    614562 
    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  
    642563 
    643564void 
  • vtcross/branches/nikhil/crossmodel2/src/cognitive_engines/CBR_CE/CBR_CE.h

    r562 r563  
    9595         * cognitive engine's functionality. 
    9696         */ 
    97         void InitialSetting(); 
    9897 
    9998        void PerformUpdatePerformance(); 
     
    106105        CBR *myCBR1; 
    107106        CBR *myCBR2; 
    108 /* 
    109     private: 
    110107 
    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 PoC 
    122 // 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 CYCLE 
    126 */  
    127108 
    128109};