Changeset 554
- Timestamp:
- 05/17/10 03:14:03 (14 years ago)
- Location:
- vtcross/branches/nikhil/crossmodel1
- Files:
-
- 13 modified
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
vtcross/branches/nikhil/crossmodel1/src/cognitive_engines/CBR.cpp
r544 r554 21 21 22 22 #include "vtcross/cbr.h" 23 23 #include <iostream> 24 24 25 25 using namespace std; … … 66 66 * use. */ 67 67 ExecuteCommand(); 68 69 std::cout << "Table Created" << std::endl; 68 70 } 69 71 … … 207 209 command += " AND "; 208 210 else 209 command += " order by utility desc;";211 command += ";"; 210 212 211 213 } -
vtcross/branches/nikhil/crossmodel1/src/cognitive_engines/CBR_CE/CBR_CE.cpp
r545 r554 20 20 21 21 #include "CBR_CE.h" 22 22 #include <iostream> 23 23 24 24 using namespace std; … … 33 33 34 34 35 void36 CBR_CE::RegisterServices()37 {38 LOG("Cognitive Engine:: Registering services.\n");39 40 SendMessage(commandSocketFD, "register_service");41 SendMessage(commandSocketFD, "test_srv");42 43 SendMessage(commandSocketFD, "register_service");44 SendMessage(commandSocketFD, "test_srv1");45 46 SendMessage(commandSocketFD, "register_service");47 SendMessage(commandSocketFD, "test_srv2");48 49 SendMessage(commandSocketFD, "register_service");50 SendMessage(commandSocketFD, "test_srv3");51 52 }53 54 55 void56 CBR_CE::DeregisterServices()57 {58 LOG("Cognitive Engine:: Deregistering services.\n");59 60 SendMessage(commandSocketFD, "deregister_service");61 SendMessage(commandSocketFD, "test_srv");62 63 SendMessage(commandSocketFD, "deregister_service");64 SendMessage(commandSocketFD, "test_srv1");65 66 SendMessage(commandSocketFD, "deregister_service");67 SendMessage(commandSocketFD, "test_srv2");68 69 SendMessage(commandSocketFD, "deregister_service");70 SendMessage(commandSocketFD, "test_srv3");71 72 }73 74 75 35 Parameter* 76 CBR_CE::GetSolution(Observable *observables, Parameter *currentParameters )36 CBR_CE::GetSolution(Observable *observables, Parameter *currentParameters, Utility *utilities) 77 37 { 78 38 LOG("Cognitive Engine:: Generating solution.\n"); … … 81 41 82 42 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 83 searchNames[i] = observables[i].name;43 searchNames[i] = uList[i].name; 84 44 } 85 45 … … 90 50 } 91 51 92 uint32_t numberColumns = radioInfo->numUtilities + radioInfo->numParameters \ 93 + radioInfo->numObservables + 1; 52 uint32_t numberColumns = radioInfo->numParameters + radioInfo->numUtilities + radioInfo->numObservables + 1; 94 53 95 54 float returnValues[numberColumns]; … … 129 88 LOG("Cognitive Engine:: Found\n"); 130 89 131 /* Should do a random adaptation.. */132 if(returnValues[numberColumns-1] < 0) {133 returnValues[2] = returnValues[2] - 15;134 returnValues[3] = returnValues[3] - 2;135 } else {136 returnValues[2] = returnValues[2] + 15;137 returnValues[3] = returnValues[3] + 2;138 }139 90 } else if(rc == 31337) { 140 91 LOG("Cognitive Engine:: Not Found.\n"); 141 92 /* No rows in the CBR, pick default parameters */ 142 93 /* Currently this is hard coded and implementation specific! */ 143 returnValues[2] = currentParameters[0].value + 5; 144 returnValues[3] = currentParameters[1].value + 10; 145 146 } else { 147 LOG("Cognitive Engine:: Search return an invalid value.\n"); 148 } 94 95 for (int i = 0; i < radioInfo->numParameters; i++) { 96 returnValues[i] = currentParameters[i].value + pList[i].step; 97 if (returnValues[i] > pList[i].max) { 98 std::cout << "SORRY CANT EXCEED MAX VALUE" << std::endl; 99 returnValues[i] = returnValues[i] - pList[i].step; 100 } 101 if (returnValues[i] < pList[i].min) { 102 std::cout << "SORRY CANT GO BELOW MIN VALUE" << std::endl; 103 returnValues[i] = returnValues[i] + pList[i].step ; 104 } 105 } 106 107 for (int i = 0; i < radioInfo->numUtilities; i++) 108 returnValues[radioInfo->numParameters + i] = uList[i].value; 109 110 for (int i = 0; i < radioInfo->numObservables; i++) 111 returnValues[radioInfo->numParameters + radioInfo->numUtilities + i] = oList[i].value; 149 112 150 113 size_t returnValueIndex = 0; 151 114 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 115 pList[i].value = returnValues[returnValueIndex]; 116 returnValueIndex++; 117 } 118 for(size_t i = 0; i < radioInfo->numParameters; i++) { 152 119 uList[i].value = returnValues[returnValueIndex]; 153 returnValueIndex++;154 }155 for(size_t i = 0; i < radioInfo->numParameters; i++) {156 pList[i].value = returnValues[returnValueIndex];157 120 returnValueIndex++; 158 121 } … … 165 128 string allNames[numberColumns]; 166 129 size_t allNameIndex = 0; 167 for(size_t i = 0; i < radioInfo->numUtilities; i++) {168 allNames[allNameIndex] = uList[i].name;169 returnValues[allNameIndex] = uList[i].target;170 allNameIndex++;171 }172 130 for(size_t i = 0; i < radioInfo->numParameters; i++) { 173 131 allNames[allNameIndex] = pList[i].name; 174 132 allNameIndex++; 175 133 } 134 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 135 allNames[allNameIndex] = uList[i].name; 136 allNameIndex++; 137 } 176 138 for(size_t i = 0; i < radioInfo->numObservables; i++) { 177 139 allNames[allNameIndex] = oList[i].name; 178 returnValues[allNameIndex] = 0;179 140 allNameIndex++; 180 141 } 181 allNames[allNameIndex] = " utility";142 allNames[allNameIndex] = "TotalWeight"; 182 143 183 144 // Add row to CBR. 184 145 myCBR->AddRow(allNames, returnValues, returnValueIndex + 1); 185 146 147 } else { 148 LOG("Cognitive Engine:: Search return an invalid value.\n"); 149 } 150 151 186 152 return pList; 187 153 } 188 154 189 155 190 Parameter*191 CBR_CE::GetSolution(Observable *observables, \192 Parameter *currentParameters, std::string service)193 {194 LOG("Cognitive Engine:: Generating solution for %s service.\n", service.c_str());195 196 return pList;197 }198 199 200 156 void 201 CBR_CE::ReceiveFeedback(Observable *observables, Parameter *parameters )157 CBR_CE::ReceiveFeedback(Observable *observables, Parameter *parameters, Utility *utilities) 202 158 { 203 159 LOG("Cognitive Engine:: Receiving feedback.\n"); 204 160 205 uint32_t numberColumns = radioInfo->numParameters + radioInfo->numUtilities; 206 207 uint32_t obsColumns = radioInfo->numObservables + 1; 208 209 float valList[numberColumns]; 210 float obsVals[numberColumns]; 211 string nameList[numberColumns]; 212 string obsList[obsColumns]; 213 214 size_t columnObsIndex = 0; 215 for (size_t i = 0; i < radioInfo->numObservables; i++){ 216 obsList[columnObsIndex] = observables[i].name; 217 columnObsIndex++; 218 } 219 obsList[columnObsIndex] = "utility"; 220 221 size_t columnIndex = 0; 222 for (size_t i = 0; i < radioInfo->numParameters; i++){ 223 nameList[columnIndex] = parameters[i].name; 224 columnIndex++; 225 } 226 for (size_t i = 0; i < radioInfo->numUtilities; i++){ 227 nameList[columnIndex] = uList[i].name; 228 columnIndex++; 229 } 230 231 size_t obsValueIndex = 0; 161 uint32_t numberColumns = radioInfo->numParameters + radioInfo->numUtilities + radioInfo->numObservables + 1; 162 163 uint32_t whereLen = radioInfo->numParameters; 164 uint32_t setLen = radioInfo->numUtilities + radioInfo->numObservables; 165 166 167 float whereValue[whereLen]; 168 float setValue[setLen]; 169 string whereList[whereLen]; 170 string setList[setLen]; 171 172 173 for(size_t i = 0; i < radioInfo->numParameters; i++) { 174 whereList[i] = parameters[i].name; 175 whereValue[i] = parameters[i].value; 176 } 177 178 size_t returnValueIndex = 0; 179 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 180 setList[returnValueIndex] = utilities[i].name; 181 setValue[returnValueIndex] = utilities[i].value; 182 returnValueIndex++; 183 } 232 184 for(size_t i = 0; i < radioInfo->numObservables; i++) { 233 obsVals[obsValueIndex] = observables[i].value; 234 obsValueIndex++; 235 } 236 237 /* Calculate Utility */ 238 float newUtilityValue = 0; 239 240 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 241 newUtilityValue = newUtilityValue + (uList[i].target - observables[i].value); 242 } 243 obsVals[obsValueIndex] = newUtilityValue; 244 245 size_t returnValueIndex = 0; 246 for(size_t i = 0; i < radioInfo->numParameters; i++) { 247 valList[returnValueIndex] = parameters[i].value; 248 returnValueIndex++; 249 } 250 for(size_t i = 0; i < radioInfo->numUtilities; i++) { 251 valList[returnValueIndex] = uList[i].target; 252 returnValueIndex++; 253 } 254 } 255 256 257 void 258 CBR_CE::ReceiveFeedback(Observable *observables, Parameter *parameters, \ 259 std::string service) 260 { 261 LOG("Cognitive Engine:: Receiving feedback.\n"); 185 setList[returnValueIndex] = observables[i].name; 186 setValue[returnValueIndex] = observables[i].value; 187 returnValueIndex++; 188 } 189 190 191 myCBR->Update(whereList,setList,whereValue,setValue,whereLen,setLen); 192 262 193 } 263 194 … … 267 198 { 268 199 string filename = "ex1"; 200 string filename2 = "ex2"; 269 201 string tablename = "data"; 270 202 271 uint32_t numberColumns = radioInfo->num Utilities + radioInfo->numParameters \203 uint32_t numberColumns = radioInfo->numParameters + radioInfo->numUtilities \ 272 204 + radioInfo->numObservables + 1; 273 205 206 uint32_t numberParameters = radioInfo->numParameters; 207 uint32_t numberUtilities = radioInfo->numUtilities; 208 274 209 string cols[numberColumns]; 210 string Plist[numberParameters]; 211 string Ulist[numberUtilities]; 212 float Utarget[numberUtilities]; 213 string Ugoal[numberUtilities]; 275 214 276 215 size_t columnIndex = 0; 216 size_t Pindex = 0; // new 217 size_t Uindex = 0; // new 218 219 220 for (size_t i = 0; i < radioInfo->numParameters; i++){ 221 cols[columnIndex] = pList[i].name; 222 columnIndex++; 223 Plist[Pindex] = pList[i].name; // new 224 Pindex++; // new 225 } 277 226 for (size_t i = 0; i < radioInfo->numUtilities; i++){ 278 227 cols[columnIndex] = uList[i].name; 279 228 columnIndex++; 280 } 281 for (size_t i = 0; i < radioInfo->numParameters; i++){ 282 cols[columnIndex] = pList[i].name; 283 columnIndex++; 284 } 285 for (size_t i = 0; i < radioInfo->numObservables; i++){ 229 Ulist[Uindex] = uList[i].name; // new 230 Utarget[Uindex] = uList[i].target; // new 231 Ugoal[Uindex] = uList[i].goal; // new 232 Uindex++; // new 233 234 } 235 for (size_t i = 0; i < radioInfo->numObservables; i++){ 286 236 cols[columnIndex] = oList[i].name; 287 288 } 289 cols[columnIndex] = " utility";237 columnIndex++; 238 } 239 cols[columnIndex] = "TotalWeight"; 290 240 291 241 myCBR = new CBR(filename, tablename, cols, numberColumns); 242 292 243 } 293 244 … … 296 247 CBR_CE::PerformUpdatePerformance() 297 248 { 249 298 250 /* Receive Set of current Parameters */ 299 251 char buffer[256]; … … 314 266 } 315 267 268 316 269 /* Receive Set of Observables */ 317 270 memset(buffer, 0, 256); … … 329 282 ReadMessage(commandSocketFD, buffer); 330 283 o[i].value = atof(buffer); 331 } 332 333 ReceiveFeedback(o, p); 284 } 285 286 287 /* Receive Set of Utilities */ 288 memset(buffer, 0, 256); 289 ReadMessage(commandSocketFD, buffer); 290 uint32_t numUtilities = atoi(buffer); 291 292 Utility *u = new Utility[numUtilities]; 293 294 for(size_t i = 0; i < numUtilities; i++) { 295 memset(buffer, 0, 256); 296 ReadMessage(commandSocketFD, buffer); 297 u[i].name = std::string(buffer); 298 299 memset(buffer, 0, 256); 300 ReadMessage(commandSocketFD, buffer); 301 u[i].value = atof(buffer); 302 } 303 304 ReceiveFeedback(o, p, u); 334 305 335 306 delete [] o; 336 307 delete [] p; 308 delete [] u; 337 309 } 338 310 339 311 340 312 void 341 CBR_CE::PerformRequestOptimizationService() 342 { 343 // THIS IS CURRENTLY IN DEMO MODE 344 313 CBR_CE::PerformRequestOptimization() 314 { 345 315 /* Receive Set of Observables */ 346 LOG("\nCognitive Engine:: Receiving service name\n");316 LOG("\nCognitive Engine:: Receiving Observables\n"); 347 317 348 318 char buffer[256]; 349 memset(buffer, 0, 256);350 ReadMessage(commandSocketFD,buffer);351 LOG("\nCognitive Engine:: Got service name, %s\n", buffer);352 353 /* Receive Set of Observables */354 LOG("\nCognitive Engine:: Receiving Observable Parameters\n");355 356 319 memset(buffer, 0, 256); 357 320 ReadMessage(commandSocketFD,buffer); … … 387 350 ReadMessage(commandSocketFD, buffer); 388 351 cp[i].value = atof(buffer); 389 } 390 LOG("Cognitive Engine:: Processing parameters....\n"); 391 392 //Parameter *solutionSet; 393 394 //solutionSet = GetSolution(o,cp); 395 396 // TODO need to actually do something with the observables here 397 398 LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n"); 399 char numParametersChar[10]; 400 //char solutionValue[50]; 401 sprintf(numParametersChar, "%i", radioInfo->numParameters); 402 SendMessage(commandSocketFD, numParametersChar); 403 for(size_t i = 0; i < radioInfo->numParameters; i++) { 404 // TODO What's with all the commented-out code? 405 //SendMessage(commandSocketFD, solutionSet[i].name.c_str()); 406 SendMessage(commandSocketFD, "test"); 407 //memset(solutionValue, 0, 50); 408 //sprintf(solutionValue, "%f", solutionSet[i].value); 409 //SendMessage(commandSocketFD, solutionValue); 410 SendMessage(commandSocketFD, "00"); 411 } 412 413 delete [] o; 414 delete [] cp; 415 416 } 417 418 419 void 420 CBR_CE::PerformRequestOptimization() 421 { 422 /* Receive Set of Observables */ 423 LOG("\nCognitive Engine:: Receiving Observable Parameters\n"); 424 425 char buffer[256]; 426 memset(buffer, 0, 256); 427 ReadMessage(commandSocketFD,buffer); 428 uint32_t numObservables = atoi(buffer); 429 430 Observable *o = new Observable[numObservables]; 431 432 for(size_t i = 0; i < numObservables; i++) { 433 memset(buffer, 0, 256); 434 ReadMessage(commandSocketFD, buffer); 435 o[i].name = std::string(buffer); 436 437 memset(buffer, 0, 256); 438 ReadMessage(commandSocketFD, buffer); 439 o[i].value = atof(buffer); 440 } 441 442 /* Receive Set of current Parameters */ 443 LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n"); 352 } 353 354 /* Receive Set of Utilities */ 355 LOG("Cognitive Engine:: Receiving Utilities\n"); 444 356 445 357 memset(buffer, 0, 256); 446 358 ReadMessage(commandSocketFD, buffer); 447 uint32_t numCurrentParameters = atoi(buffer); 448 449 Parameter *cp = new Parameter[numCurrentParameters]; 450 451 for(size_t i = 0; i < numCurrentParameters; i++) { 452 memset(buffer, 0, 256); 453 ReadMessage(commandSocketFD, buffer); 454 cp[i].name = std::string(buffer); 455 456 memset(buffer, 0, 256); 457 ReadMessage(commandSocketFD, buffer); 458 cp[i].value = atof(buffer); 459 } 359 uint32_t numUtilities = atoi(buffer); 360 361 Utility *u = new Utility[numUtilities]; 362 363 for(size_t i = 0; i < numUtilities; i++) { 364 memset(buffer, 0, 256); 365 ReadMessage(commandSocketFD, buffer); 366 u[i].name = std::string(buffer); 367 368 memset(buffer, 0, 256); 369 ReadMessage(commandSocketFD, buffer); 370 u[i].value = atof(buffer); 371 } 372 373 374 375 460 376 LOG("Cognitive Engine:: Processing parameters....\n"); 461 377 462 378 Parameter *solutionSet; 463 379 464 solutionSet = GetSolution(o,cp );465 466 // TODO need to actually do something with the observables here380 solutionSet = GetSolution(o,cp,u); 381 382 467 383 468 384 LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n"); … … 480 396 delete [] o; 481 397 delete [] cp; 482 } 483 484 485 void 486 CBR_CE::PerformQueryComponentType() 487 { 488 SendComponentType(); 489 } 490 491 492 void 493 CBR_CE::PerformConnectSML() 494 { 495 /* This command implies that we are disconnecting from the shell and 496 * connecting to a SML component. */ 497 char serverName[256]; 498 char serverPort[256]; 499 500 // TODO is this going to end up being too slow? 501 memset(serverName, 0, 256); 502 memset(serverPort, 0, 256); 503 504 ReadMessage(commandSocketFD, serverName); 505 ReadMessage(commandSocketFD, serverPort); 506 507 /* Only continue if we are currently connected to a shell. */ 508 if(!SML_present) { 509 DeregisterComponent(); 510 511 shutdown(commandSocketFD, 2); 512 close(commandSocketFD); 513 514 ConnectToRemoteComponent(serverName, serverPort, true); 515 } 516 } 517 518 519 void 520 CBR_CE::PerformDisconnectSML() 521 { 522 /* This command implies that we are disconnecting from the SML and 523 * connecting to a shell component. */ 524 char serverName[256]; 525 char serverPort[256]; 526 527 // TODO is this going to end up being too slow? 528 memset(serverName, 0, 256); 529 memset(serverPort, 0, 256); 530 531 ReadMessage(commandSocketFD, serverName); 532 ReadMessage(commandSocketFD, serverPort); 533 534 /* We only want to do this if we are actually connected to an SML 535 * currently. */ 536 if(SML_present) { 537 DeregisterServices(); 538 539 shutdown(commandSocketFD, 2); 540 close(commandSocketFD); 541 542 ConnectToRemoteComponent(serverName, serverPort, false); 543 } 398 delete [] u; 544 399 } 545 400 -
vtcross/branches/nikhil/crossmodel1/src/cognitive_engines/CBR_CE/CBR_CE.h
r545 r554 42 42 /*! Default constructor. */ 43 43 CBR_CE() : CognitiveEngine(){}; 44 45 44 /*! Default destructor. */ 46 45 ~CBR_CE(){}; … … 57 56 const int32_t numFields, const bool SML); 58 57 59 void RegisterServices();60 void DeregisterServices();61 62 58 /*! \brief Request that the CE optimize a set of parameters. 63 59 * … … 66 62 * and active. */ 67 63 Parameter *GetSolution(Observable *observables, \ 68 Parameter *currentParameters); 69 Parameter *GetSolution(Observable *observables, \ 70 Parameter *currentParameters, std::string service); 64 Parameter *currentParameters, Utility *utilities); 71 65 72 66 /*! \brief Receive feedback from the radio … … 80 74 * more accurate performance statistics. 81 75 */ 82 void ReceiveFeedback(Observable *observables,Parameter *parameters); 83 void ReceiveFeedback(Observable *observables, Parameter *parameters, \ 84 std::string service); 85 76 void ReceiveFeedback(Observable *observables,Parameter *parameters, Utility *utilities); 86 77 87 78 /*! \brief Initialize the CE and prepare it for operation. … … 102 93 */ 103 94 void PerformUpdatePerformance(); 104 void PerformRequestOptimizationService();105 95 void PerformRequestOptimization(); 106 void PerformQueryComponentType(); 107 void PerformConnectSML(); 108 void PerformDisconnectSML(); 96 109 97 void PerformResetEngineCognitive(); 110 98 void PerformShutdownEngineCognitive(); 111 99 112 100 CBR *myCBR; 101 113 102 }; 114 103 -
vtcross/branches/nikhil/crossmodel1/src/cognitive_engines/CognitiveEngine.cpp
r544 r554 25 25 #include <cmath> 26 26 #include <string> 27 #include <iostream> 27 28 28 29 #include "vtcross/cognitive_engine.h" … … 66 67 67 68 ConnectToRemoteComponent(serverName, serverPort, SML); 68 } 69 69 70 } 70 71 71 72 void … … 85 86 SML_present = SML; 86 87 87 if(SML) { 88 LOG("Cognitive Engine connected to SML at %s.\n", serverName); 88 89 // Considering only Shell to work in this project!! 90 91 LOG("Cognitive Engine connected to shell at %s.\n", serverName); 89 92 90 93 RegisterComponent(); 91 94 ReceiveRadioConfiguration(); 92 95 ReceiveExperience(); 93 RegisterServices(); 94 } 95 else { 96 LOG("Cognitive Engine connected to shell at %s.\n", serverName); 97 98 RegisterComponent(); 99 ReceiveRadioConfiguration(); 100 ReceiveExperience(); 101 } 96 102 97 } 103 98 … … 108 103 char buffer[256]; 109 104 105 std::cout << "IN WAITFORSIGNAL METHOD" << std::endl; 106 110 107 while(true) { 111 108 memset(buffer, 0, 256); … … 114 111 115 112 if(strcmp(buffer, "update_performance") == 0) { 116 113 PerformUpdatePerformance(); 117 114 } 118 else if(strcmp(buffer, "request_optimization_service") == 0) {119 PerformRequestOptimizationService();120 }121 115 else if(strcmp(buffer, "request_optimization") == 0) { 122 116 PerformRequestOptimization(); 123 117 } 124 else if(strcmp(buffer, "query_component_type") == 0) {125 PerformQueryComponentType();126 }127 else if(strcmp(buffer, "connect_sml") == 0) {128 PerformConnectSML();129 }130 else if(strcmp(buffer, "disconnect_sml") == 0) {131 PerformDisconnectSML();132 }133 118 else if(strcmp(buffer, "reset_engine_cognitive") == 0) { 134 119 PerformResetEngineCognitive(); … … 144 129 CognitiveEngine::Shutdown() 145 130 { 146 if(SML_present) {147 DeregisterServices();148 131 DeregisterComponent(); 149 } 150 else { 132 // TODO Need to actually kill this process... 133 } 134 135 136 void 137 CognitiveEngine::Reset() 138 { 139 LOG("Resetting Cognitive Engine.\n"); 140 151 141 DeregisterComponent(); 152 }153 // TODO Need to actually kill this process...154 }155 156 157 void158 CognitiveEngine::Reset()159 {160 LOG("Resetting Cognitive Engine.\n");161 162 if(SML_present) {163 DeregisterServices();164 DeregisterComponent();165 }166 else {167 DeregisterComponent();168 }169 142 170 143 // TODO This function then needs to re-call "ConnectToRemoteComponent" to … … 325 298 326 299 LOG("Cognitive Engine:: Waiting for %i number of entries.\n", numberExp); 327 328 300 SendMessage(commandSocketFD, "receive_exp_ack"); 301 329 302 } 330 303 … … 338 311 339 312 Parameter* 340 CognitiveEngine::GetSolution(Observable *observables, Parameter *currentParameters )313 CognitiveEngine::GetSolution(Observable *observables, Parameter *currentParameters, Utility *utilities) 341 314 { 342 315 LOG("Cognitive Engine:: Generating solution.\n"); … … 348 321 349 322 350 Parameter* 351 CognitiveEngine::GetSolution(Observable *observables, \ 352 Parameter *currentParameters, std::string service) 353 { 354 LOG("Cognitive Engine:: Generating solution for %s service.\n", service.c_str()); 355 356 LOG("CognitiveEngine:: GetSolution with service not implemented.\n"); 357 358 return NULL; 359 } 360 361 362 void 363 CognitiveEngine::ReceiveFeedback(Observable *observables,Parameter *parameters) 323 void 324 CognitiveEngine::ReceiveFeedback(Observable *observables,Parameter *parameters, Utility *utilities) 364 325 { 365 326 LOG("Cognitive Engine:: Receiving feedback.\n"); … … 369 330 370 331 371 void372 CognitiveEngine::ReceiveFeedback(Observable *observables, Parameter *parameters, \373 std::string service)374 {375 LOG("Cognitive Engine:: Receiving feedback.\n");376 377 LOG("CognitiveEngine:: ReceiveFeedback not implemented.\n");378 }379 380 381 332 void 382 333 CognitiveEngine::BuildCognitiveEngine() … … 387 338 388 339 void 389 CognitiveEngine::RegisterServices()390 {391 LOG("Cognitive Engine:: RegisterServices not implemented.\n");392 }393 394 395 void396 CognitiveEngine::DeregisterServices()397 {398 LOG("Cognitive Engine:: DeregisterServices not implemented.\n");399 }400 401 402 void403 340 CognitiveEngine::PerformUpdatePerformance() 404 341 { … … 407 344 408 345 void 409 CognitiveEngine::PerformRequestOptimizationService()410 {411 }412 413 414 void415 346 CognitiveEngine::PerformRequestOptimization() 416 347 { … … 419 350 420 351 void 421 CognitiveEngine::PerformQueryComponentType()422 {423 }424 425 426 void427 CognitiveEngine::PerformConnectSML()428 {429 }430 431 432 void433 CognitiveEngine::PerformDisconnectSML()434 {435 }436 437 438 void439 352 CognitiveEngine::PerformResetEngineCognitive() 440 353 { -
vtcross/branches/nikhil/crossmodel1/src/include/vtcross/cognitive_engine.h
r531 r554 74 74 virtual void DeregisterComponent(); 75 75 76 virtual void RegisterServices();77 virtual void DeregisterServices();78 79 76 /*! \brief Receive radio XML configuration. 80 77 * … … 97 94 * and active. */ 98 95 virtual Parameter *GetSolution(Observable *observables, \ 99 Parameter *currentParameters); 100 virtual Parameter *GetSolution(Observable *observables, \ 101 Parameter *currentParameters, std::string service); 96 Parameter *currentParameters, Utility *utilities); 97 102 98 103 99 /*! \brief Receive feedback from the radio … … 111 107 * more accurate performance statistics. 112 108 */ 113 virtual void ReceiveFeedback(Observable *observables,Parameter *parameters); 114 virtual void ReceiveFeedback(Observable *observables, Parameter *parameters, \ 115 std::string service); 109 virtual void ReceiveFeedback(Observable *observables,Parameter *parameters, Utility *utilities); 116 110 117 111 … … 133 127 */ 134 128 virtual void PerformUpdatePerformance(); 135 virtual void PerformRequestOptimizationService();136 129 virtual void PerformRequestOptimization(); 137 virtual void PerformQueryComponentType();138 virtual void PerformConnectSML();139 virtual void PerformDisconnectSML();140 130 virtual void PerformResetEngineCognitive(); 141 131 virtual void PerformShutdownEngineCognitive(); -
vtcross/branches/nikhil/crossmodel1/src/include/vtcross/components.h
r518 r554 119 119 * Register or deregister services that this engine provides with the 120 120 * service management layer. */ 121 virtual void RegisterServices() = 0;122 virtual void DeregisterServices() = 0;121 // virtual void RegisterServices() = 0; 122 // virtual void DeregisterServices() = 0; 123 123 }; 124 124 -
vtcross/branches/nikhil/crossmodel1/src/include/vtcross/cross_shell.h
r537 r554 93 93 void RegisterCognitiveEngine(int32_t socketFD); 94 94 void DeregisterCognitiveEngine(int32_t socketFD); 95 void RegisterPolicyEngine(int32_t socketFD); 96 void DeregisterPolicyEngine(int32_t socketFD); 97 void RegisterSML(int32_t socketFD); 98 void DeregisterSML(int32_t socketFD); 95 96 97 98 99 99 100 100 /*! \brief Set the active mission. … … 104 104 * This command is basically passed through the CRS to the SML. 105 105 */ 106 void SetActiveMission(int32_t socketFD); 106 107 107 108 108 /* Handle a message that is received from a component. -
vtcross/branches/nikhil/crossmodel1/src/include/vtcross/libvtcross.h
r536 r554 39 39 * communicating with. Note that this can be a local or remote destination. 40 40 */ 41 41 42 void SetCrossShellLocation(std::string hostname, std::string port); 42 43 44 Parameter* GetOptimalParameters(Observable *radioObservables, uint32_t numObservables, Parameter *currentParameters, uint32_t numCurrentParameters, Utility *radioUtilities, uint32_t numUtilities); 43 45 44 /*! \brief Parses XML configuration file and uses it to configure the radio. 45 * 46 * This function *must* be called when the radio first starts up, and may be 47 * called at any point after that to reconfigure the radio. 48 */ 49 bool ParseRadioConfiguration(); 46 bool UpdateParameterPerformance(Parameter *p, uint32_t numParameters, Observable *o, uint32_t numObservables, Utility *u, uint32_t numUtilities); 50 47 51 52 /*! \brief Lists current radio configuration options loaded from the XML. 53 * 54 * TODO How are we listing these? Are we simply returning them to stdout? 55 * Logging them? Returning strings? Need to figure this out... 56 */ 57 void ListCurrentRadioConfiguration(); 58 59 60 /*! \brief View data from the current status of the radio. 61 * 62 * This function allows client code to capture radio properties at any certain 63 * instant. Note, however, that these properties could be changing at very 64 * rapid rates. There is no guarantee that the return results from these 65 * functions will still be valid by the time the client code receives them. 66 */ 67 Observable* GetRadioObservables(); 68 Parameter* GetRadioParameters(); 69 Utility* GetRadioUtilities(); 70 71 72 /*! \brief View components currently connected to the radio by id. 73 * 74 * TODO Should there be another way to list components? If you have 10 cognitive 75 * engines, how are you going to know which is which just by id? 76 */ 77 uint32_t* GetConnectedCognitiveEngines(); 78 uint32_t* GetConnectedPolicyEngines(); 79 uint32_t* GetConnectedManagementServiceLayers(); 80 uint32_t* GetConnectedComponents(); 81 82 83 /*! \brief Given a certain set of observables, ask the radio to find the 84 * optimum radio parameters and return them. 85 * 86 * TODO I'm a little confused about this function... why would anyone need to 87 * use this? Shouldn't this be internal to the radio operation? 88 */ 89 Parameter* GetOptimalParameters(Observable *radioObservables, uint32_t numObservables, 90 Parameter *currentParameters, uint32_t numCurrentParameters); 91 92 93 /*! \brief Update the radio regarding its performance. 94 * 95 * TODO 96 */ 97 bool UpdateParameterPerformance(Parameter *p, uint32_t numParameters, Observable *o, \ 98 uint32_t numObservables); 99 100 /*! \brief Deactivate/Activate/Disconnect a component by id. 101 */ 102 bool ActivateComponent(uint32_t id); 103 bool DeactivateComponent(uint32_t id); 104 bool DisconnectComponent(uint32_t id); 105 106 /*! \brief Set the active mission of the CROSS radio. 107 */ 108 uint32_t SetActiveMission(char * activeMission); 109 110 /*! \brief Shut down the radio. 111 * 112 * This function will deactivate and disconnect all radio components before 113 * finally shutting down the shell and stopping radio operations. 114 */ 115 bool Shutdown(); 116 117 /*! \brief Return total number of currently recognized transmission parameters. 118 */ 119 uint32_t GetNumParameters(); 120 uint32_t GetNumObservables(); 121 uint32_t GetNumUtilities(); 122 48 uint32_t GetNum(std::string); 123 49 124 50 #endif -
vtcross/branches/nikhil/crossmodel1/src/libvtcross/Makefile.am
r429 r554 18 18 19 19 lib_LTLIBRARIES = libvtcross.la 20 bin_PROGRAMS = libvtcross_demo libvtcross_demo_sml20 bin_PROGRAMS = libvtcross_demo 21 21 22 22 libvtcross_la_SOURCES = libvtcross.cpp … … 27 27 libvtcross_demo_LDADD = $(CROSS_LA) 28 28 29 libvtcross_demo_sml_SOURCES = libvtcross_demo_sml.cpp30 libvtcross_demo_sml_LDADD = $(CROSS_LA)31 32 29 SUBDIRS = . swig -
vtcross/branches/nikhil/crossmodel1/src/libvtcross/libvtcross.cpp
r536 r554 57 57 // TODO the following three functions all do exactly the same thing. Why not 58 58 // simply combine them? 59 uint32_t60 GetNumObservables()61 {62 char buffer[256];63 59 64 uint32_t socketfd = ConnectToShell();65 SendMessage(socketfd, "get_number_observables");66 67 memset(buffer, 0, 256);68 ReadMessage(socketfd, buffer);69 uint32_t numObservables = atoi(buffer);70 71 return numObservables;72 }73 74 uint32_t75 GetNumUtilities()76 {77 char buffer[256];78 79 uint32_t socketfd = ConnectToShell();80 SendMessage(socketfd, "get_number_utilities");81 82 memset(buffer, 0, 256);83 ReadMessage(socketfd, buffer);84 uint32_t numUtilities = atoi(buffer);85 86 return numUtilities;87 }88 89 uint32_t90 SetActiveMission(char * activeMission)91 {92 char buffer[256];93 94 uint32_t socketfd = ConnectToShell();95 SendMessage(socketfd, "set_active_mission");96 97 SendMessage(socketfd, activeMission);98 99 //memset(buffer, 0, 256);100 //ReadMessage(socketfd, buffer);101 102 return 1;103 }104 105 uint32_t106 GetNumParameters()107 {108 char buffer[256];109 110 uint32_t socketfd = ConnectToShell();111 SendMessage(socketfd, "get_number_parameters");112 113 memset(buffer, 0, 256);114 ReadMessage(socketfd, buffer);115 uint32_t numParameters = atoi(buffer);116 117 return numParameters;118 }119 // end previous TODO120 121 /* Given a certain set of observables, ask the radio to find the optimum radio122 * parameters and return them.123 *124 * TODO I'm a little confused about this function... why would anyone need to125 * use this? Shouldn't this be internal to the radio operation?126 *127 * TODO this function is returning a pointer to allocated memory, which is fine,128 * but we need to document this and make sure the caller is deallocating the129 * memory when it is done using it.130 */131 60 Parameter* 132 GetOptimalParameters(Observable *radioObservables, uint32_t numObservables, 133 Parameter *currentParameters, uint32_t numCurrentParameters) 61 GetOptimalParameters(Observable *radioObservables, uint32_t numObservables, Parameter *currentParameters, uint32_t numCurrentParameters, Utility *radioUtilities, uint32_t numUtilities) 134 62 { 135 63 char var[50]; … … 163 91 } 164 92 93 /* Send Utilities */ 94 memset(counter, 0, 55); 95 sprintf(counter, "%i", numUtilities); 96 SendMessage(socketFD, counter); 97 for(size_t i = 0; i < numUtilities; i++) { 98 SendMessage(socketFD,radioUtilities[i].name.c_str()); 99 sprintf(var,"%f",radioUtilities[i].value); 100 SendMessage(socketFD,var); 101 } 102 103 165 104 /* Receive Set of Parameters */ 166 105 memset(buffer, 0, 256); … … 184 123 185 124 bool 186 UpdateParameterPerformance(Parameter *p, uint32_t numParameters, Observable *o, 187 uint32_t numObservables) 125 UpdateParameterPerformance(Parameter *p, uint32_t numParameters, Observable *o, uint32_t numObservables, Utility *u, uint32_t numUtilities) 188 126 { 189 127 char counter[55]; … … 205 143 206 144 // Send Observables 145 memset(counter, 0, 55); 207 146 sprintf(counter, "%i", numObservables); 208 147 SendMessage(socketFD, counter); … … 212 151 SendMessage(socketFD, var); 213 152 } 153 154 // Send Utilities 155 memset(counter, 0, 55); 156 sprintf(counter, "%i", numUtilities); 157 SendMessage(socketFD, counter); 158 for(size_t i = 0; i < numUtilities; i++) { 159 SendMessage(socketFD, u[i].name.c_str()); 160 sprintf(var, "%f", u[i].value); 161 SendMessage(socketFD, var); 162 } 163 214 164 } 215 165 216 bool ActivateComponent(uint32_t id) { 217 return 1; 218 } 219 bool DeactivateComponent(uint32_t id) { 220 return 1; 221 } 222 bool DisconnectComponent(uint32_t id) { 223 return 1; 224 } 166 uint32_t GetNum(string type) 167 { 168 169 char buffer[256]; 170 uint32_t socketfd = ConnectToShell(); 171 172 if (type == "parameters") 173 SendMessage(socketfd, "get_number_parameters"); 174 else if (type == "utilities") 175 SendMessage(socketfd, "get_number_utilities"); 176 else if (type == "observables") 177 SendMessage(socketfd, "get_number_observables"); 178 else 179 LOG("Type not included, either 'parameters' or 'utilities' or 'observables'"); 180 181 memset(buffer, 0, 256); 182 ReadMessage(socketfd, buffer); 183 uint32_t number = atoi(buffer); 184 return number; 225 185 226 186 227 /* View components currently connected to the radio by id.228 *229 * TODO Should there be another way to list components? If you have 10 cognitive230 * engines, how are you going to know which is which just by id?231 */232 uint32_t* GetConnectedCognitiveEngines() {233 187 } 234 uint32_t* GetConnectedPolicyEngines(){235 }236 uint32_t* GetConnectedManagementServiceLayers(){237 }238 uint32_t* GetConnectedComponents(){239 }240 241 242 /* View data from the current status of the radio.243 *244 * This function allows client code to capture radio properties at any certain245 * instant. Note, however, that these properties could be changing at very246 * rapid rates. There is no guarantee that the return results from these247 * functions will still be valid by the time the client code receives them.248 */249 Observable* GetRadioObservables() {250 }251 Parameter* GetRadioParameters(){252 }253 Utility* GetRadioUtilities(){254 }255 256 257 /* Parses VTCROSS XML configuration file and uses it to configure the radio.258 *259 * This function *must* be called when the radio first starts up, and may be260 * called at any point after that to reconfigure the radio.261 */262 bool ParseRadioConfiguration(){263 }264 265 266 /* Lists current radio configuration options loaded from the configuration XML267 * file.268 *269 * TODO How are we listing these? Are we simply returning them to stdout?270 * Logging them? Returning strings? Need to figure this out...271 */272 void ListCurrentRadioConfiguration(){273 }274 275 /* Shut down the radio.276 *277 * This function will deactivate and disconnect all radio components before278 * finally shutting down the shell and stopping radio operations.279 */280 bool Shutdown(){281 }282 -
vtcross/branches/nikhil/crossmodel1/src/libvtcross/libvtcross_demo.cpp
r535 r554 24 24 #include "vtcross/libvtcross.h" 25 25 #include "vtcross/socketcomm.h" 26 #include <iostream> 26 27 27 28 int32_t … … 31 32 SetCrossShellLocation("localhost", "40000"); 32 33 33 for(size_t i = 0; i < 10; i++) { 34 Observable *o = new Observable[2]; 35 Parameter *currentParameters = new Parameter[2]; 34 35 // need to include utilties also in system,.. 36 37 Observable *o = new Observable[10]; 38 Parameter *currentParameters = new Parameter[10]; 39 Utility *u = new Utility[10]; 36 40 Parameter *p; 37 41 … … 40 44 uint32_t numUtilities; 41 45 42 o[0].name = "throughput"; 43 o[0].value = 150.00; 44 o[1].name = "PER"; 45 o[1].value = 12.00; 46 u[0].name = "throughput"; 47 // u[0].value = 15 48 u[1].name = "PER"; 49 // u[1].value = 12.00; 50 51 numParameters = GetNum("parameters"); 52 numObservables = GetNum("observables"); 53 numUtilities = GetNum("utilities"); 54 55 56 // This is for loop for performing 10 cycles of updates.. with CBR 57 for(size_t i = 0; i < 10; i++) { 46 58 47 59 if(i == 0) { 48 60 currentParameters[0].name = "bandwidth"; 49 currentParameters[0].value = 300.0;61 currentParameters[0].value = 200.0; 50 62 currentParameters[1].name = "tx_power"; 51 63 currentParameters[1].value = 10.0; … … 57 69 LOG("Application:: Requesting parameter optimization.\n"); 58 70 59 p = GetOptimalParameters(o,2,currentParameters,2); 60 numParameters = GetNumParameters(); 61 numObservables = GetNumObservables(); 62 numUtilities = GetNumUtilities(); 71 p = GetOptimalParameters(o,0,currentParameters,2,u,2); 63 72 64 73 LOG("Application:: Received the following parameters.\n"); … … 68 77 } 69 78 70 /* Try them out! Do they work? */ 71 o[0].value = 0.5*p[0].value + .1*p[1].value;72 o[1].value = 15-p[1].value;79 /// Try them out! Do they work? 80 u[0].value = 2*p[0].value + 1*p[1].value + ((rand()*2.0/RAND_MAX - 1)*10.0); 81 u[1].value = 12-p[0].value/50 - p[1].value/3 + ((rand()*2.0/RAND_MAX - 1.0)*0.1); 73 82 74 UpdateParameterPerformance(p, numParameters, o, numObservables); 75 76 delete [] p; 77 delete [] o; 83 if (u[1].value < 0) 84 u[1].value = 0; 85 86 LOG("utilities\n %s : %f \n %s : %f \n",u[0].name.c_str(),u[0].value,u[1].name.c_str(),u[1].value); 87 88 UpdateParameterPerformance(p, numParameters, o, numObservables, u, numUtilities); 89 90 usleep(1000); 91 78 92 } 79 93 -
vtcross/branches/nikhil/crossmodel1/src/shell/CognitiveRadioShell.cpp
r537 r554 183 183 } 184 184 } 185 185 186 186 187 /* Receive ACK for radio configuration */ … … 215 216 return false; 216 217 } 218 217 219 return true; 218 220 } … … 252 254 } 253 255 254 255 void256 CognitiveRadioShell::RegisterPolicyEngine(int32_t socketFD)257 {258 LOG("Cognitive Radio Shell:: Received registration from Policy Engine on socket %d.\n", \259 socketFD);260 261 PE_present = true;262 }263 264 265 void266 CognitiveRadioShell::DeregisterPolicyEngine(int32_t socketFD)267 {268 LOG("Cognitive Radio Shell:: Received deregistration message from Policy Engine.\n");269 270 PE_present = false;271 272 SendMessage(socketFD, "deregister_ack");273 shutdown(socketFD, 2);274 close(socketFD);275 LOG("Cognitive Radio Shell:: Socket %d closed.\n", socketFD);276 }277 278 279 void280 CognitiveRadioShell::RegisterSML(int32_t socketFD)281 {282 LOG("Cognitive Radio Shell:: Received registration from SML on socket %d.\n", \283 socketFD);284 285 SML_present = true;286 }287 288 289 void290 CognitiveRadioShell::DeregisterSML(int32_t socketFD)291 {292 LOG("Cognitive Radio Shell:: Received deregistration message from SML.\n");293 294 SML_present = false;295 296 SendMessage(socketFD, "deregister_ack");297 shutdown(socketFD, 2);298 close(socketFD);299 LOG("Cognitive Radio Shell:: Socket %d closed.\n", socketFD);300 }301 302 void303 CognitiveRadioShell::SetActiveMission(int32_t socketFD)304 {305 char buffer[256];306 307 LOG("Cognitive Radio Shell:: Received Set Active Mission command from host.\n");308 309 /* Read the name of the active mission to be set from the host. */310 memset(buffer, 0, 256);311 ReadMessage(commandSocketFD, buffer);312 313 /* Send command to SML. */314 SendMessage(ceSocketFD, "set_active_mission");315 SendMessage(ceSocketFD, buffer);316 317 /* Get ack from SML saying the mission was set properly */318 memset(buffer, 0, 256);319 ReadMessage(ceSocketFD, buffer);320 321 /* Forward ack to host */322 SendMessage(commandSocketFD, buffer);323 }324 256 325 257 void … … 415 347 } 416 348 417 if(!match_found) { 418 ERROR(1, "Error: %s: %s is not a valid utility.\n", \ 419 oList[item_count].name.c_str(), oUtilName); 420 } 421 else 422 match_found = false; 349 350 //////////////////WE are not looking for relationship between them.. 351 // if(!match_found) { 352 // ERROR(1, "Error: %s: %s is not a valid utility.\n", \ 353 // oList[item_count].name.c_str(), oUtilName); 354 // } 355 // else 356 // match_found = false; 423 357 } 424 358 oList[item_count].numAffects = affect_count; … … 476 410 } 477 411 478 if(!match_found) {479 ERROR(1, "Error: %s: %s is not a valid utility.\n", \480 pList[item_count].name.c_str(), pUtilName);481 }482 483 match_found = false;412 // if(!match_found) { 413 // ERROR(1, "Error: %s: %s is not a valid utility.\n", \ 414 // pList[item_count].name.c_str(), pUtilName); 415 // } 416 417 // match_found = false; 484 418 } 485 419 … … 536 470 cp[i].value = atof(buffer); 537 471 } 472 ////////////// NEW INCLUSION /////////////////// 473 474 /* Receive Set of Utilities */ 475 memset(buffer, 0, 256); 476 ReadMessage(commandSocketFD,buffer); 477 uint32_t numUtilities = atoi(buffer); 478 479 LOG("Cognitive Radio Shell:: Attempting to get %i utilities.\n",numUtilities); 480 Utility *u = new Utility[numUtilities]; 481 482 for (size_t i = 0;i < numUtilities; i++){ 483 memset(buffer, 0, 256); 484 ReadMessage(commandSocketFD,buffer); 485 u[i].name = std::string(buffer); 486 487 memset(buffer, 0, 256); 488 ReadMessage(commandSocketFD,buffer); 489 u[i].value = atof(buffer); 490 } 491 492 /////////////////////////////////////// 538 493 539 494 /* Send to Cognitive Engine … … 541 496 * to send this information 542 497 */ 498 SendMessage(ceSocketFD,"request_optimization"); 499 543 500 LOG("Cognitive Radio Shell:: Passing on observables.\n"); 544 SendMessage(ceSocketFD,"request_optimization");545 501 sprintf(counter,"%i",numObservables); 546 502 SendMessage(ceSocketFD,counter); … … 559 515 SendMessage(ceSocketFD,var); 560 516 } 517 518 ///////////// NEW //////////////////////////////////////////////////////// 519 LOG("Cognitive Radio Shell:: Passing on utilities.\n"); 520 sprintf(counter,"%i",numUtilities); 521 SendMessage(ceSocketFD,counter); 522 for(size_t i = 0; i < numUtilities; i++) { 523 SendMessage(ceSocketFD,u[i].name.c_str()); 524 sprintf(var,"%f",u[i].value); 525 SendMessage(ceSocketFD,var); 526 } 527 528 ////////////// END of NEW ///////////////////////////////////// 561 529 562 530 /* Receive Set of Parameters */ … … 591 559 592 560 delete [] o; 561 delete [] u; 593 562 delete [] p; 594 563 } … … 634 603 ReadMessage(commandSocketFD, buffer); 635 604 o[i].value = atof(buffer); 605 } 606 607 /* Receive Set of Utilities */ 608 memset(buffer, 0, 256); 609 ReadMessage(commandSocketFD, buffer); 610 uint32_t numUtilities = atoi(buffer); 611 612 Utility *u = new Utility[numUtilities]; 613 614 for(size_t i = 0; i < numUtilities; i++) { 615 memset(buffer, 0, 256); 616 ReadMessage(commandSocketFD, buffer); 617 u[i].name = std::string(buffer); 618 619 memset(buffer, 0, 256); 620 ReadMessage(commandSocketFD, buffer); 621 u[i].value = atof(buffer); 636 622 } 637 623 … … 650 636 651 637 /* Send Observables */ 638 memset(counter, 0, 55); 652 639 sprintf(counter, "%i", numObservables); 653 640 SendMessage(ceSocketFD, counter); … … 658 645 } 659 646 647 /* Send Utilities */ 648 memset(counter, 0, 55); 649 sprintf(counter, "%i", numUtilities); 650 SendMessage(ceSocketFD,counter); 651 for(size_t i = 0; i < numUtilities; i++) { 652 SendMessage(ceSocketFD, u[i].name.c_str()); 653 sprintf(var, "%f", u[i].value); 654 SendMessage(ceSocketFD, var); 655 } 656 657 660 658 delete [] p; 661 659 delete [] o; 660 delete [] u; 662 661 } 663 662 … … 678 677 } else if(strcmp(buffer, "deregister_engine_cognitive") == 0) { 679 678 DeregisterCognitiveEngine(socketFD); 680 } else if(strcmp(buffer, "register_engine_policy") == 0) {681 RegisterPolicyEngine(socketFD);682 } else if(strcmp(buffer, "deregister_engine_policy") == 0) {683 DeregisterPolicyEngine(socketFD);684 } else if(strcmp(buffer, "register_sml") == 0) {685 RegisterSML(socketFD);686 } else if(strcmp(buffer, "deregister_sml") == 0) {687 DeregisterSML(socketFD);688 679 } else if(strcmp(buffer, "update_performance") == 0) { 689 680 UpdateParameterPerformance(socketFD); … … 703 694 /* Receive optimization request and current environment */ 704 695 GetOptimalParameters(socketFD); 705 } else if(strcmp(buffer, "set_active_mission") == 0) { 706 SetActiveMission(socketFD); 707 } else if(strcmp(buffer, "request_optimization_service") == 0) { 708 /* Receive optimization request and current environment */ 709 //GetOptimalParametersService(socketFD); 710 } 696 } 711 697 712 698 return ret; -
vtcross/branches/nikhil/crossmodel1/src/shell/configs/demo.xml
r375 r554 8 8 <!-- utilities : QoS metrics --> 9 9 <utilities> 10 <utility name="t p" units="kbps" goal="max" target="125000" />11 <utility name=" packet_error" units="none" goal="min" target="1" />10 <utility name="throughput" units="kbps" goal="max" target="517" /> 11 <utility name="PER" units="none" goal="min" target="1.2" /> 12 12 </utilities> 13 13 14 14 <!-- radio parameters --> 15 15 <parameters> 16 <parameter name="bandwidth" units="hz" min="1" max="255" step="1"> 17 <affect utility="tp" relationship="improve" /> 16 <parameter name="bandwidth" units="hz" min="1" max="255" step="10"> 18 17 </parameter> 19 18 <parameter name="tx_power" units="dBm" min="1" max="255" step="1"> 20 <affect utility="packet_error" relationship="improve"/>21 19 </parameter> 22 20 </parameters> … … 24 22 <!-- link/channel observations --> 25 23 <observables> 26 <observable name="throughput">27 <affect utility="tp" relationship="improve" />28 </observable>29 <observable name="PER">30 <affect utility="packet_error" relationship="improve" />31 </observable>32 24 </observables> 33 25 </engine>