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 header exports the declaration for the Cognitive Engine component type. |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef COGNITIVE_ENGINE_H |
---|
21 | #define COGNITIVE_ENGINE_H |
---|
22 | |
---|
23 | |
---|
24 | #include "components.h" |
---|
25 | |
---|
26 | |
---|
27 | /*! \brief Cognitive Engine class declaration. |
---|
28 | * |
---|
29 | * This is the declaration for the default cognitive engine class. Note that |
---|
30 | * most of the below functions are implemented in CognitiveEngine.cpp - however, |
---|
31 | * the functionality is very non-specific. |
---|
32 | * |
---|
33 | * Each of the 'Perform*' functions are left un-implemented, for the most part. |
---|
34 | * |
---|
35 | * The purpose of this class is to act as a non-abstract parent class. |
---|
36 | * Cognitive Engines should be built by publically inherting from this class, |
---|
37 | * and overloading the 'Perform*' functions - thus creating new and specific |
---|
38 | * cognitive engine functionality, without the need to rewrite or copy/paste the |
---|
39 | * rest of the code. Other functions that need to be overloaded include: |
---|
40 | * 1 |
---|
41 | * 2 |
---|
42 | * 3 |
---|
43 | * |
---|
44 | * Note, however, that all functions are virtual. Any function may be |
---|
45 | * overloaded by the child class, if desired. |
---|
46 | */ |
---|
47 | class CognitiveEngine : public Engine |
---|
48 | { |
---|
49 | public: |
---|
50 | /*! Default constructor. */ |
---|
51 | CognitiveEngine(); |
---|
52 | |
---|
53 | /*! Default destructor. */ |
---|
54 | ~CognitiveEngine(); |
---|
55 | |
---|
56 | /*! \brief Preferred constructor. |
---|
57 | * |
---|
58 | * Overloaded constructor that creates a cognitive engine object and |
---|
59 | * connects it to either the shell or an SML, depening on the SML bool. |
---|
60 | * |
---|
61 | * The 'numFields' parameter sets how large the parameter, observable, |
---|
62 | * and utility arrays should be upon instantiation. |
---|
63 | */ |
---|
64 | CognitiveEngine(const char* serverName, const char* serverPort, \ |
---|
65 | const int32_t numFields, const bool SML); |
---|
66 | |
---|
67 | virtual void SendComponentType(); |
---|
68 | virtual void ConnectToRemoteComponent(const char* serverName, \ |
---|
69 | const char* serverPort, const bool SML); |
---|
70 | virtual void WaitForSignal(); |
---|
71 | virtual void Shutdown(); |
---|
72 | virtual void Reset(); |
---|
73 | virtual void RegisterComponent(); |
---|
74 | virtual void DeregisterComponent(); |
---|
75 | |
---|
76 | /*! \brief Receive radio XML configuration. |
---|
77 | * |
---|
78 | * Receive the transmitted radio configuration from the radio itself |
---|
79 | * (the CE will not always be local to the radio). This gets passed |
---|
80 | * through either the Shell or the SML. */ |
---|
81 | virtual void ReceiveRadioConfiguration(); |
---|
82 | |
---|
83 | /*! \brief Receive an 'experience' report from the radio. |
---|
84 | * |
---|
85 | * An experience report can be used to build the transmission history |
---|
86 | * for a CE just starting up so that it has a moving start regarding |
---|
87 | * parameter optimization. */ |
---|
88 | virtual void ReceiveExperience(); |
---|
89 | |
---|
90 | /*! \brief Request that the CE optimize a set of parameters. |
---|
91 | * |
---|
92 | * Find the most optimal set of transmission parameters given certain |
---|
93 | * observables and possibly a service if the SML component is present |
---|
94 | * and active. */ |
---|
95 | virtual Parameter *GetSolution(Observable *observables, \ |
---|
96 | Parameter *currentParameters, Utility *utilities); |
---|
97 | |
---|
98 | |
---|
99 | /*! \brief Receive feedback from the radio |
---|
100 | * |
---|
101 | * Receive a feedback from the radio regarding the performance of a |
---|
102 | * certain set of parameters, possibly associated with a service. |
---|
103 | * |
---|
104 | * Feedback is a single set of performance statistics that is achieved |
---|
105 | * corresponding to a specific set of transmission parameters. Feedback |
---|
106 | * helps a Cognitive Engine make better future decisions based upon |
---|
107 | * more accurate performance statistics. |
---|
108 | */ |
---|
109 | virtual void ReceiveFeedback(Observable *observables,Parameter *parameters, Utility *utilities); |
---|
110 | |
---|
111 | |
---|
112 | /*! \brief Initialize the CE and prepare it for operation. |
---|
113 | * |
---|
114 | * BuildCognitiveEngine performs the CE implementation specific work |
---|
115 | * that defines the internals of a CE. For example, a CBR CE engine |
---|
116 | * would build the case-base reasoner or create the database, a neural |
---|
117 | * network based CE may perform the initial training, a GA based CE |
---|
118 | * may build the chromosome structure. |
---|
119 | */ |
---|
120 | virtual void BuildCognitiveEngine(); |
---|
121 | |
---|
122 | /*! \brief Each of these functions responds to a specific command. |
---|
123 | * |
---|
124 | * These functions are left principally un-implemented. It is the duty |
---|
125 | * of child classes to implement these functions, as they define the |
---|
126 | * cognitive engine's functionality. |
---|
127 | */ |
---|
128 | virtual void PerformUpdatePerformance(); |
---|
129 | virtual void PerformRequestOptimization(); |
---|
130 | virtual void PerformResetEngineCognitive(); |
---|
131 | virtual void PerformShutdownEngineCognitive(); |
---|
132 | |
---|
133 | /*! \brief Keept track of what this CE is connected to. |
---|
134 | * |
---|
135 | * The SML_present bool reflects whether or not the remote component |
---|
136 | * this object is connected to is an SML. If it isn't, then it must be |
---|
137 | * a shell. The socketFD stores the socket file descriptor for this |
---|
138 | * connection. |
---|
139 | */ |
---|
140 | bool SML_present; |
---|
141 | int32_t commandSocketFD; |
---|
142 | |
---|
143 | // TODO Need a description for these fields. Are these radio utilites, |
---|
144 | // parameters, and observables global to the whole system? |
---|
145 | Utility *uList; |
---|
146 | Parameter *pList; |
---|
147 | Observable *oList; |
---|
148 | |
---|
149 | //////// NEW ADDITION /////////////////// |
---|
150 | struct Radio_Info *radioInfo; |
---|
151 | struct Opt_List { |
---|
152 | float * Pweights; |
---|
153 | float * Uweights; |
---|
154 | float (*Status)[10]; |
---|
155 | // the max utilities that it can accept is 10 |
---|
156 | |
---|
157 | float (*Trend)[10]; |
---|
158 | // the max utilities that it can accept is 10 |
---|
159 | |
---|
160 | int * Slope; |
---|
161 | float PoC; |
---|
162 | int Ptune; |
---|
163 | |
---|
164 | |
---|
165 | }*optList; |
---|
166 | //////////////////////////////////////// |
---|
167 | |
---|
168 | }; |
---|
169 | |
---|
170 | #endif |
---|