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 | #ifndef DSA_COGNITIVEENGINE_H |
---|
18 | #define DSA_COGNITIVEENGINE_H |
---|
19 | |
---|
20 | |
---|
21 | /*! Declares a CE based on the default CBR for example purposes. */ |
---|
22 | |
---|
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/common.h" |
---|
33 | #include "vtcross/components.h" |
---|
34 | #include "vtcross/containers.h" |
---|
35 | #include "vtcross/debug.h" |
---|
36 | #include "vtcross/error.h" |
---|
37 | #include "vtcross/socketcomm.h" |
---|
38 | |
---|
39 | |
---|
40 | #define INTERFERENCE 0 |
---|
41 | #define CHANNEL 1 |
---|
42 | #define ENERGY 0 |
---|
43 | #define COMMUNICATION_TIME 1 |
---|
44 | #define UTILITY 4 |
---|
45 | |
---|
46 | |
---|
47 | class DSA_CE : public CognitiveEngine |
---|
48 | { |
---|
49 | public: |
---|
50 | /*! Default constructor. */ |
---|
51 | DSA_CE(); |
---|
52 | |
---|
53 | /*! Default destructor. */ |
---|
54 | ~DSA_CE(); |
---|
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 | DSA_CE(const char* serverName, const char* serverPort, \ |
---|
65 | const int32_t numFields, const bool SML); |
---|
66 | |
---|
67 | void RegisterServices(); |
---|
68 | void DeregisterServices(); |
---|
69 | |
---|
70 | /*! \brief Request that the CE optimize a set of parameters. |
---|
71 | * |
---|
72 | * Find the most optimal set of transmission parameters given certain |
---|
73 | * observables and possibly a service if the SML component is present |
---|
74 | * and active. */ |
---|
75 | Parameter *GetSolution(Observable *observables, \ |
---|
76 | Parameter *currentParameters); |
---|
77 | Parameter *GetSolution(Observable *observables, \ |
---|
78 | Parameter *currentParameters, std::string service); |
---|
79 | |
---|
80 | /*! \brief Receive feedback from the radio |
---|
81 | * |
---|
82 | * Receive a feedback from the radio regarding the performance of a |
---|
83 | * certain set of parameters, possibly associated with a service. |
---|
84 | * |
---|
85 | * Feedback is a single set of performance statistics that is achieved |
---|
86 | * corresponding to a specific set of transmission parameters. Feedback |
---|
87 | * helps a Cognitive Engine make better future decisions based upon |
---|
88 | * more accurate performance statistics. |
---|
89 | */ |
---|
90 | void ReceiveFeedback(Observable *observables,Parameter *parameters); |
---|
91 | void ReceiveFeedback(Observable *observables, Parameter *parameters, \ |
---|
92 | std::string service); |
---|
93 | |
---|
94 | |
---|
95 | /*! \brief Initialize the CE and prepare it for operation. |
---|
96 | * |
---|
97 | * BuildCognitiveEngine performs the CE implementation specific work |
---|
98 | * that defines the internals of a CE. For example, a CBR CE engine |
---|
99 | * would build the case-base reasoner or create the database, a neural |
---|
100 | * network based CE may perform the initial training, a GA based CE |
---|
101 | * may build the chromosome structure. |
---|
102 | */ |
---|
103 | void BuildCognitiveEngine(); |
---|
104 | |
---|
105 | /*! \brief Each of these functions responds to a specific command. |
---|
106 | * |
---|
107 | * These functions are left principally un-implemented. It is the duty |
---|
108 | * of child classes to implement these functions, as they define the |
---|
109 | * cognitive engine's functionality. |
---|
110 | */ |
---|
111 | void PerformUpdatePerformance(); |
---|
112 | void PerformRequestOptimizationService(); |
---|
113 | void PerformRequestOptimization(); |
---|
114 | void PerformQueryComponentType(); |
---|
115 | void PerformConnectSML(); |
---|
116 | void PerformDisconnectSML(); |
---|
117 | void PerformResetEngineCognitive(); |
---|
118 | void PerformShutdownEngineCognitive(); |
---|
119 | |
---|
120 | CBR *myCBR; |
---|
121 | }; |
---|
122 | |
---|
123 | #endif |
---|