[222] | 1 | /* Virginia Tech Cognitive Radio Open Source Systems |
---|
| 2 | * Virginia Tech, 2009 |
---|
| 3 | * |
---|
| 4 | * TODO LICENSE INFORMATION GOES HERE |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | /* TODO DESCRIPTION OF FILE. |
---|
| 8 | * |
---|
| 9 | * This file is a temporary demo of a policy engine using some of our socket |
---|
| 10 | * communication functions. This is *not* an actual implementation of our |
---|
| 11 | * defined PolicyEngine class. |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | #include <cstdlib> |
---|
| 16 | #include <cstring> |
---|
| 17 | #include <stdint.h> |
---|
| 18 | |
---|
| 19 | #include "vtcross/libvtcross.h" |
---|
| 20 | #include "vtcross/socketcomm.h" |
---|
| 21 | |
---|
| 22 | int32_t |
---|
| 23 | main(int32_t argc, char *argv[]) |
---|
| 24 | { |
---|
[230] | 25 | |
---|
| 26 | for(size_t i = 0; i < 10; i++) { |
---|
| 27 | Observable *o = new Observable[2]; |
---|
[228] | 28 | Parameter *currentParameters = new Parameter[2]; |
---|
[222] | 29 | Parameter * p; |
---|
| 30 | |
---|
[228] | 31 | uint32_t numParameters; |
---|
[230] | 32 | uint32_t numObservables; |
---|
| 33 | uint32_t numUtilities; |
---|
[222] | 34 | |
---|
[230] | 35 | o[0].name = "throughput"; |
---|
| 36 | o[0].value = 150.00; |
---|
| 37 | o[1].name = "PER"; |
---|
| 38 | o[1].value = 12.00; |
---|
[222] | 39 | |
---|
[230] | 40 | if(i == 0) { |
---|
| 41 | currentParameters[0].name = "bandwidth"; |
---|
| 42 | currentParameters[0].value = 300.0; |
---|
| 43 | currentParameters[1].name = "tx_power"; |
---|
| 44 | currentParameters[1].value = 10.0; |
---|
[228] | 45 | |
---|
[230] | 46 | } else { |
---|
| 47 | currentParameters[0].value = p[0].value; |
---|
| 48 | currentParameters[1].value = p[1].value; |
---|
| 49 | } |
---|
| 50 | p = GetOptimalParameters(o,2,currentParameters,2); |
---|
[228] | 51 | numParameters = GetNumParameters(); |
---|
[230] | 52 | numObservables = GetNumObservables(); |
---|
| 53 | numUtilities = GetNumUtilities(); |
---|
[228] | 54 | |
---|
[222] | 55 | printf("Application:: Received the following parameters.\n"); |
---|
[228] | 56 | |
---|
| 57 | for(size_t i = 0; i < numParameters; i++) { |
---|
| 58 | printf("%s:: %f\n",p[i].name.c_str(),p[i].value); |
---|
| 59 | } |
---|
[222] | 60 | |
---|
[228] | 61 | // Try them out! Do they work? |
---|
| 62 | |
---|
[230] | 63 | o[0].value = 0.5*p[0].value + .1*p[1].value; |
---|
| 64 | o[1].value = 15-p[1].value; |
---|
| 65 | |
---|
| 66 | UpdateParameterPerformance(p,numParameters,o,numObservables); |
---|
[228] | 67 | |
---|
| 68 | |
---|
| 69 | delete [] p; |
---|
[225] | 70 | delete [] o; |
---|
[230] | 71 | } |
---|
[222] | 72 | return 0; |
---|
| 73 | } |
---|
| 74 | |
---|