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 | /*! This file provides a default implementation for a case-based-reasoning based |
---|
18 | * cognitive engine. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef CBR_CE_H |
---|
22 | #define CBR_CE_H |
---|
23 | |
---|
24 | #include <cstdlib> |
---|
25 | #include <cstring> |
---|
26 | #include <stdint.h> |
---|
27 | #include <cmath> |
---|
28 | #include <string> |
---|
29 | |
---|
30 | #include "vtcross/cbr.h" |
---|
31 | #include "vtcross/cognitive_engine.h" |
---|
32 | #include "vtcross/ppe.h" |
---|
33 | #include "vtcross/common.h" |
---|
34 | #include "vtcross/containers.h" |
---|
35 | #include "vtcross/debug.h" |
---|
36 | #include "vtcross/error.h" |
---|
37 | #include "vtcross/socketcomm.h" |
---|
38 | |
---|
39 | |
---|
40 | //typedef float (*array)[radioInfo->numParameters][radioInfo->numUtilities]; |
---|
41 | |
---|
42 | class CBR_CE : public CognitiveEngine |
---|
43 | { |
---|
44 | public: |
---|
45 | |
---|
46 | /*! Default constructor. */ |
---|
47 | CBR_CE() : CognitiveEngine(){}; |
---|
48 | /*! Default destructor. */ |
---|
49 | ~CBR_CE(){}; |
---|
50 | |
---|
51 | /*! \brief Preferred constructor. |
---|
52 | * |
---|
53 | * Overloaded constructor that creates a cognitive engine object and |
---|
54 | * connects it to either the shell or an SML, depening on the SML bool. |
---|
55 | * |
---|
56 | * The 'numFields' parameter sets how large the parameter, observable, |
---|
57 | * and utility arrays should be upon instantiation. |
---|
58 | */ |
---|
59 | CBR_CE(const char* serverName, const char* serverPort, \ |
---|
60 | const int32_t numFields, const bool SML); |
---|
61 | |
---|
62 | /*! \brief Request that the CE optimize a set of parameters. |
---|
63 | * |
---|
64 | * Find the most optimal set of transmission parameters given certain |
---|
65 | * observables and possibly a service if the SML component is present |
---|
66 | * and active. */ |
---|
67 | Parameter *GetSolution(Observable *observables, \ |
---|
68 | Parameter *currentParameters, Utility *utilities); |
---|
69 | |
---|
70 | /*! \brief Receive feedback from the radio |
---|
71 | * |
---|
72 | * Receive a feedback from the radio regarding the performance of a |
---|
73 | * certain set of parameters, possibly associated with a service. |
---|
74 | * |
---|
75 | * Feedback is a single set of performance statistics that is achieved |
---|
76 | * corresponding to a specific set of transmission parameters. Feedback |
---|
77 | * helps a Cognitive Engine make better future decisions based upon |
---|
78 | * more accurate performance statistics. |
---|
79 | */ |
---|
80 | void ReceiveFeedback(Observable *observables,Parameter *parameters, Utility *utilities); |
---|
81 | |
---|
82 | /*! \brief Initialize the CE and prepare it for operation. |
---|
83 | * |
---|
84 | * BuildCognitiveEngine performs the CE implementation specific work |
---|
85 | * that defines the internals of a CE. For example, a CBR CE engine |
---|
86 | * would build the case-base reasoner or create the database, a neural |
---|
87 | * network based CE may perform the initial training, a GA based CE |
---|
88 | * may build the chromosome structure. |
---|
89 | */ |
---|
90 | void BuildCognitiveEngine(); |
---|
91 | |
---|
92 | /*! \brief Each of these functions responds to a specific command. |
---|
93 | * |
---|
94 | * These functions are left principally un-implemented. It is the duty |
---|
95 | * of child classes to implement these functions, as they define the |
---|
96 | * cognitive engine's functionality. |
---|
97 | */ |
---|
98 | void InitialSetting(); |
---|
99 | |
---|
100 | void PerformUpdatePerformance(); |
---|
101 | void PerformRequestOptimization(); |
---|
102 | |
---|
103 | void PerformResetEngineCognitive(); |
---|
104 | void PerformShutdownEngineCognitive(); |
---|
105 | |
---|
106 | CBR *myCBR1; |
---|
107 | CBR *myCBR2; |
---|
108 | |
---|
109 | private: |
---|
110 | |
---|
111 | float * Pweights; |
---|
112 | float * Uweights; |
---|
113 | |
---|
114 | float (*Status)[10]; |
---|
115 | // this array stores the relationship between all parameters vs utilities.. |
---|
116 | float (*Trend)[10]; |
---|
117 | |
---|
118 | int * Slope; |
---|
119 | |
---|
120 | float PoC; |
---|
121 | // this term represents percentage of change.. as in if this min PoC |
---|
122 | // is not detected its as good as no change.. |
---|
123 | |
---|
124 | }; |
---|
125 | |
---|
126 | #endif |
---|