[412] | 1 | /* |
---|
| 2 | Copyright 2009 Virginia Polytechnic Institute and State University |
---|
[283] | 3 | |
---|
[412] | 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 5 | you may not use this file except in compliance with the License. |
---|
| 6 | You may obtain a copy of the License at |
---|
| 7 | |
---|
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 9 | |
---|
| 10 | Unless required by applicable law or agreed to in writing, software |
---|
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 13 | See the License for the specific language governing permissions and |
---|
| 14 | limitations under the License. |
---|
| 15 | */ |
---|
| 16 | |
---|
[283] | 17 | /* TODO DESCRIPTION OF FILE. |
---|
| 18 | * |
---|
| 19 | * This file is a temporary demo of a policy engine using some of our socket |
---|
| 20 | * communication functions. This is *not* an actual implementation of our |
---|
| 21 | * defined PolicyEngine class. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | #include <cstdlib> |
---|
| 26 | #include <cstring> |
---|
| 27 | #include <stdint.h> |
---|
| 28 | |
---|
| 29 | #include "vtcross/debug.h" |
---|
| 30 | #include "vtcross/error.h" |
---|
| 31 | #include "vtcross/libvtcross.h" |
---|
| 32 | #include "vtcross/socketcomm.h" |
---|
| 33 | |
---|
| 34 | int32_t |
---|
| 35 | main(int32_t argc, char *argv[]) |
---|
| 36 | { |
---|
| 37 | uint32_t ret = 0; |
---|
| 38 | |
---|
| 39 | uint32_t numParameters = 2; |
---|
| 40 | uint32_t numObservables = 2; |
---|
| 41 | |
---|
[285] | 42 | //for(size_t i = 0; i < 10; i++) { |
---|
[283] | 43 | |
---|
| 44 | Observable *o = new Observable[2]; |
---|
| 45 | Parameter *currentParameters = new Parameter[2]; |
---|
| 46 | Parameter *p; |
---|
| 47 | |
---|
| 48 | o[0].name = "throughput"; |
---|
| 49 | o[0].value = 150.00; |
---|
| 50 | o[1].name = "PER"; |
---|
| 51 | o[1].value = 12.00; |
---|
| 52 | |
---|
[285] | 53 | //if(i == 0) { |
---|
[283] | 54 | currentParameters[0].name = "bandwidth"; |
---|
| 55 | currentParameters[0].value = 300.0; |
---|
| 56 | currentParameters[1].name = "tx_power"; |
---|
| 57 | currentParameters[1].value = 10.0; |
---|
[285] | 58 | // } else { |
---|
| 59 | // currentParameters[0].value = p[0].value; |
---|
| 60 | // currentParameters[1].value = p[1].value; |
---|
| 61 | // } |
---|
[283] | 62 | |
---|
| 63 | |
---|
| 64 | // Set the currently active SML misson |
---|
| 65 | // Note: mission name must match a mission |
---|
| 66 | // in the SML xml file |
---|
[285] | 67 | SetActiveMission("0"); |
---|
[283] | 68 | |
---|
| 69 | // Send a request to the system for a new set of |
---|
| 70 | // parameters. |
---|
[285] | 71 | p = GetOptimalParameters(o,numObservables,currentParameters,numParameters); |
---|
[283] | 72 | |
---|
[285] | 73 | LOG("Application:: Received the following parameters.\n"); |
---|
[283] | 74 | |
---|
[285] | 75 | for(size_t i = 0; i < numParameters; i++) { |
---|
| 76 | LOG("%s:: %f\n", p[i].name.c_str(), p[i].value); |
---|
| 77 | } |
---|
[283] | 78 | |
---|
| 79 | // Simulate the REAL observable values after the |
---|
| 80 | // given parameters were set. |
---|
| 81 | |
---|
| 82 | //o[0].value = 0.5*p[0].value + .1*p[1].value; |
---|
| 83 | //o[1].value = 15-p[1].value; |
---|
| 84 | |
---|
| 85 | // Send the new observable values to the system with the |
---|
| 86 | // associated parameter set. |
---|
| 87 | //UpdateParameterPerformance(p, numParameters, o, numObservables); |
---|
| 88 | |
---|
| 89 | delete [] p; |
---|
| 90 | delete [] o; |
---|
[285] | 91 | //} |
---|
[283] | 92 | |
---|
| 93 | return 0; |
---|
| 94 | } |
---|
| 95 | |
---|