root/vtcross/branches/fixingCBR/src/libvtcross/libvtcross_demo.cpp @ 237

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

Simple typos and missing headers.

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