root/vtcross/trunk/src/libvtcross/libvtcross_demo.cpp @ 231

Revision 231, 1.9 KB (checked in by bhilburn, 15 years ago)

Style fixes for the most part. Perhaps one or two memory leaks. Added a
bunch of TODOs.

Line 
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
22int32_t
23main(int32_t argc, char *argv[])
24{
25        for(size_t i = 0; i < 10; i++) {
26        Observable *o = new Observable[2];
27        Parameter *currentParameters = new Parameter[2];
28        Parameter *p;
29
30        uint32_t numParameters;
31        uint32_t numObservables;
32        uint32_t numUtilities;
33
34        o[0].name = "throughput";
35        o[0].value = 150.00;
36        o[1].name = "PER";
37        o[1].value = 12.00;
38
39        if(i == 0) {
40            currentParameters[0].name = "bandwidth";
41            currentParameters[0].value = 300.0;
42            currentParameters[1].name = "tx_power";
43            currentParameters[1].value = 10.0;
44        } else {
45            currentParameters[0].value = p[0].value;
46            currentParameters[1].value = p[1].value;
47        }
48
49        p = GetOptimalParameters(o,2,currentParameters,2);
50        numParameters = GetNumParameters();
51        numObservables = GetNumObservables();
52        numUtilities = GetNumUtilities();
53
54        LOG("Application:: Received the following parameters.\n");
55       
56        for(size_t i = 0; i < numParameters; i++) {
57            LOG("%s:: %f\n", p[i].name.c_str(), p[i].value);
58        }
59
60        /* Try them out! Do they work? */
61        o[0].value = 0.5*p[0].value + .1*p[1].value;
62        o[1].value = 15-p[1].value;
63
64        UpdateParameterPerformance(p, numParameters, o, numObservables);       
65       
66        delete [] p;
67        delete [] o;
68        }
69
70        return 0;
71}
72
Note: See TracBrowser for help on using the browser.