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

Revision 535, 2.4 KB (checked in by bhilburn, 14 years ago)

Final commit of engineTreeFix branch.

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