root/vtcross/trunk/src/libvtcross/libvtcross_demo_sml.cpp

Revision 412, 2.7 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    uint32_t ret = 0;
38   
39    uint32_t numParameters = 2;
40    uint32_t numObservables = 2;
41
42    //for(size_t i = 0; i < 10; i++) {
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
53        //if(i == 0) {
54            currentParameters[0].name = "bandwidth";
55            currentParameters[0].value = 300.0;
56            currentParameters[1].name = "tx_power";
57            currentParameters[1].value = 10.0;
58       // } else {
59       //     currentParameters[0].value = p[0].value;
60       //     currentParameters[1].value = p[1].value;
61       // }
62
63
64        // Set the currently active SML misson
65        // Note: mission name must match a mission
66        // in the SML xml file
67        SetActiveMission("0");
68
69        // Send a request to the system for a new set of
70        //  parameters.
71        p = GetOptimalParameters(o,numObservables,currentParameters,numParameters);
72       
73        LOG("Application:: Received the following parameters.\n");
74       
75        for(size_t i = 0; i < numParameters; i++) {
76            LOG("%s:: %f\n", p[i].name.c_str(), p[i].value);
77        }
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;
91    //}
92
93    return 0;
94}
95
Note: See TracBrowser for help on using the browser.