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

Revision 412, 2.4 KB (checked in by trnewman, 15 years ago)

Adding Apache license information.

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