- Timestamp:
- 03/04/10 12:21:27 (14 years ago)
- Location:
- vtcross/trunk/src/cognitive_engines
- Files:
-
- 3 added
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/cognitive_engines/CBR_CE/CBR_CE.cpp
r534 r545 19 19 */ 20 20 21 #include <cstdlib> 22 #include <cstring> 23 #include <stdint.h> 24 #include <cmath> 25 #include <string> 26 27 #include "vtcross/cbr.h" 28 #include "vtcross/cognitive_engine.h" 29 #include "vtcross/common.h" 30 #include "vtcross/containers.h" 31 #include "vtcross/debug.h" 32 #include "vtcross/error.h" 33 #include "vtcross/socketcomm.h" 21 #include "CBR_CE.h" 34 22 35 23 … … 37 25 38 26 39 class CBR_CE : public CognitiveEngine 40 { 41 public: 42 /*! Default constructor. */ 43 CBR_CE() : CognitiveEngine(){}; 44 45 /*! Default destructor. */ 46 ~CBR_CE(){}; 47 48 /*! \brief Preferred constructor. 49 * 50 * Overloaded constructor that creates a cognitive engine object and 51 * connects it to either the shell or an SML, depening on the SML bool. 52 * 53 * The 'numFields' parameter sets how large the parameter, observable, 54 * and utility arrays should be upon instantiation. 55 */ 56 CBR_CE(const char* serverName, const char* serverPort, \ 57 const int32_t numFields, const bool SML) \ 58 : CognitiveEngine(serverName, serverPort, numFields, SML){} 59 60 61 void RegisterServices(); 62 void DeregisterServices(); 63 64 /*! \brief Request that the CE optimize a set of parameters. 65 * 66 * Find the most optimal set of transmission parameters given certain 67 * observables and possibly a service if the SML component is present 68 * and active. */ 69 Parameter *GetSolution(Observable *observables, \ 70 Parameter *currentParameters); 71 Parameter *GetSolution(Observable *observables, \ 72 Parameter *currentParameters, std::string service); 73 74 /*! \brief Receive feedback from the radio 75 * 76 * Receive a feedback from the radio regarding the performance of a 77 * certain set of parameters, possibly associated with a service. 78 * 79 * Feedback is a single set of performance statistics that is achieved 80 * corresponding to a specific set of transmission parameters. Feedback 81 * helps a Cognitive Engine make better future decisions based upon 82 * more accurate performance statistics. 83 */ 84 void ReceiveFeedback(Observable *observables,Parameter *parameters); 85 void ReceiveFeedback(Observable *observables, Parameter *parameters, \ 86 std::string service); 87 88 89 /*! \brief Initialize the CE and prepare it for operation. 90 * 91 * BuildCognitiveEngine performs the CE implementation specific work 92 * that defines the internals of a CE. For example, a CBR CE engine 93 * would build the case-base reasoner or create the database, a neural 94 * network based CE may perform the initial training, a GA based CE 95 * may build the chromosome structure. 96 */ 97 void BuildCognitiveEngine(); 98 99 /*! \brief Each of these functions responds to a specific command. 100 * 101 * These functions are left principally un-implemented. It is the duty 102 * of child classes to implement these functions, as they define the 103 * cognitive engine's functionality. 104 */ 105 void PerformUpdatePerformance(); 106 void PerformRequestOptimizationService(); 107 void PerformRequestOptimization(); 108 void PerformQueryComponentType(); 109 void PerformConnectSML(); 110 void PerformDisconnectSML(); 111 void PerformResetEngineCognitive(); 112 void PerformShutdownEngineCognitive(); 113 114 CBR *myCBR; 115 }; 27 CBR_CE::CBR_CE(const char* serverName, const char* serverPort, \ 28 const int32_t numFields, const bool SML) \ 29 : CognitiveEngine(serverName, serverPort, numFields, SML) 30 { 31 BuildCognitiveEngine(); 32 } 116 33 117 34 -
vtcross/trunk/src/cognitive_engines/CBR_CE/Makefile.am
r532 r545 22 22 23 23 cbr_demo_SOURCES = CBR_CE.cpp cbr_demo.cpp 24 cbr_demo_DEPENDENCIES = ../libce.a 25 cbr_demo_LDADD = -lsqlite3 ../libce.a $(CROSS_SOCKETCOMM_LA)24 cbr_demo_DEPENDENCIES = ../libce.a ../libcbr.a 25 cbr_demo_LDADD = -lsqlite3 ../libce.a ../libcbr.a $(CROSS_SOCKETCOMM_LA) 26 26 -
vtcross/trunk/src/cognitive_engines/CBR_CE/cbr_demo.cpp
r532 r545 27 27 #include <stdint.h> 28 28 29 #include "vtcross/cognitive_engine.h" 30 #include "vtcross/common.h" 31 #include "vtcross/containers.h" 29 30 #include "CBR_CE.h" 32 31 #include "vtcross/debug.h" 33 32 #include "vtcross/error.h" 34 #include "vtcross/socketcomm.h"35 33 36 34 … … 41 39 ERROR(1, "Usage: %s hostname port\n", argv[0]); 42 40 43 C ognitiveEnginecognitiveEngine(argv[1], argv[2], 10, false);41 CBR_CE cognitiveEngine(argv[1], argv[2], 10, false); 44 42 45 43 LOG("Waiting for signal...\n"); -
vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp
r533 r545 19 19 */ 20 20 21 #include <cstdlib> 22 #include <cstring> 23 #include <stdint.h> 24 #include <cmath> 25 #include <string> 26 27 #include "vtcross/cbr.h" 28 #include "vtcross/cognitive_engine.h" 29 #include "vtcross/common.h" 30 #include "vtcross/components.h" 31 #include "vtcross/containers.h" 32 #include "vtcross/debug.h" 33 #include "vtcross/error.h" 34 #include "vtcross/socketcomm.h" 35 36 37 #define INTERFERENCE 0 38 39 #define CHANNEL 1 40 41 #define ENERGY 0 42 #define COMMUNICATION_TIME 1 43 44 #define UTILITY 4 45 46 class DSA_CE : public CognitiveEngine 47 { 48 public: 49 /*! Default constructor. */ 50 DSA_CE(); 51 52 /*! Default destructor. */ 53 ~DSA_CE(); 54 55 /*! \brief Preferred constructor. 56 * 57 * Overloaded constructor that creates a cognitive engine object and 58 * connects it to either the shell or an SML, depening on the SML bool. 59 * 60 * The 'numFields' parameter sets how large the parameter, observable, 61 * and utility arrays should be upon instantiation. 62 */ 63 DSA_CE(const char* serverName, const char* serverPort, \ 64 const int32_t numFields, const bool SML); 65 66 void RegisterServices(); 67 void DeregisterServices(); 68 69 /*! \brief Request that the CE optimize a set of parameters. 70 * 71 * Find the most optimal set of transmission parameters given certain 72 * observables and possibly a service if the SML component is present 73 * and active. */ 74 Parameter *GetSolution(Observable *observables, \ 75 Parameter *currentParameters); 76 Parameter *GetSolution(Observable *observables, \ 77 Parameter *currentParameters, std::string service); 78 79 /*! \brief Receive feedback from the radio 80 * 81 * Receive a feedback from the radio regarding the performance of a 82 * certain set of parameters, possibly associated with a service. 83 * 84 * Feedback is a single set of performance statistics that is achieved 85 * corresponding to a specific set of transmission parameters. Feedback 86 * helps a Cognitive Engine make better future decisions based upon 87 * more accurate performance statistics. 88 */ 89 void ReceiveFeedback(Observable *observables,Parameter *parameters); 90 void ReceiveFeedback(Observable *observables, Parameter *parameters, \ 91 std::string service); 92 93 94 /*! \brief Initialize the CE and prepare it for operation. 95 * 96 * BuildCognitiveEngine performs the CE implementation specific work 97 * that defines the internals of a CE. For example, a CBR CE engine 98 * would build the case-base reasoner or create the database, a neural 99 * network based CE may perform the initial training, a GA based CE 100 * may build the chromosome structure. 101 */ 102 void BuildCognitiveEngine(); 103 104 /*! \brief Each of these functions responds to a specific command. 105 * 106 * These functions are left principally un-implemented. It is the duty 107 * of child classes to implement these functions, as they define the 108 * cognitive engine's functionality. 109 */ 110 void PerformUpdatePerformance(); 111 void PerformRequestOptimizationService(); 112 void PerformRequestOptimization(); 113 void PerformQueryComponentType(); 114 void PerformConnectSML(); 115 void PerformDisconnectSML(); 116 void PerformResetEngineCognitive(); 117 void PerformShutdownEngineCognitive(); 118 119 CBR *myCBR; 120 }; 21 #include "DSA_CognitiveEngine.h" 22 23 24 using namespace std; 25 121 26 122 27 DSA_CE::DSA_CE() … … 146 51 LOG("Creating Cognitive Engine.\n"); 147 52 srand ( time(NULL) ); 53 54 BuildCognitiveEngine(); 148 55 } 149 56 -
vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_Demo.cpp
r533 r545 27 27 #include <stdint.h> 28 28 29 #include "vtcross/cognitive_engine.h" 30 #include "vtcross/common.h" 31 #include "vtcross/containers.h" 29 #include "DSA_CognitiveEngine.h" 32 30 #include "vtcross/debug.h" 33 31 #include "vtcross/error.h" 34 #include "vtcross/socketcomm.h"35 32 36 33 … … 41 38 ERROR(1, "Usage: %s hostname port\n", argv[0]); 42 39 43 CognitiveEnginecognitiveEngine(argv[1], argv[2], 10, false);40 DSA_CE cognitiveEngine(argv[1], argv[2], 10, false); 44 41 45 42 LOG("Waiting for signal...\n"); -
vtcross/trunk/src/cognitive_engines/DSA_CE/Makefile.am
r533 r545 22 22 23 23 DSA_Demo_SOURCES = DSA_CognitiveEngine.cpp DSA_Demo.cpp 24 DSA_Demo_DEPENDENCIES = ../libce.a 25 DSA_Demo_LDADD = -lsqlite3 ../libce.a $(CROSS_SOCKETCOMM_LA)24 DSA_Demo_DEPENDENCIES = ../libce.a ../libcbr.a 25 DSA_Demo_LDADD = -lsqlite3 ../libce.a ../libcbr.a $(CROSS_SOCKETCOMM_LA) 26 26 -
vtcross/trunk/src/cognitive_engines/OSSIE_DEMO_CE/Makefile.am
r534 r545 22 22 23 23 OSSIE_Demo_SOURCES = OSSIE_CE.cpp OSSIE_Demo.cpp 24 OSSIE_Demo_DEPENDENCIES = ../libce.a 25 OSSIE_Demo_LDADD = -lsqlite3 ../libce.a $(CROSS_SOCKETCOMM_LA)24 OSSIE_Demo_DEPENDENCIES = ../libce.a ../libcbr.a 25 OSSIE_Demo_LDADD = -lsqlite3 ../libce.a ../libcbr.a $(CROSS_SOCKETCOMM_LA) 26 26 -
vtcross/trunk/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_CE.cpp
r534 r545 1 /* Virginia Tech Cognitive Radio Open Source Systems 2 * Virginia Tech, 2009 3 * 4 * LICENSE INFORMATION GOES HERE 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 CE was written to extend the functionality of a basic CBR-based CE for 18 * use with the OSSIE demonstration. This file contains the implementation for 19 * both the OSSIE CBR as well as the OSSIE Cognitive Engine. 5 20 */ 6 21 7 /*! This CE was written to extend the functionality of a basic CBR-based CE for 8 * use with the OSSIE demonstration. 9 */ 10 11 12 #include <cmath> 13 #include <cstdlib> 14 #include <cstring> 15 #include <stdint.h> 16 #include <string> 17 18 #include "vtcross/cbr.h" 19 #include "vtcross/cognitive_engine.h" 20 #include "vtcross/common.h" 21 #include "vtcross/containers.h" 22 #include "vtcross/debug.h" 23 #include "vtcross/error.h" 24 #include "vtcross/socketcomm.h" 25 26 27 #define TXPOWER 1 28 #define BER_ENV 1 29 #define BER_OBJ 1 30 31 #define DECREMENTSCALE 5 32 #define INCREMENTSCALE 5 33 34 #define EVF 20 35 36 37 /* ossieCBR Class 38 * 39 * Derives from the default VTCROSS CBR class to add the following functionality 40 * necessary for the OSSIE demo: 41 * 42 * TODO 43 */ 44 class ossieCBR : public CBR 45 { 46 public: 47 ossieCBR(); 48 49 ossieCBR(string _filename, string _tablename, string _cols[], uint32_t _len); 50 51 ~ossieCBR(){}; 52 53 int32_t Update(string _where[], string _set[], float *_wherevals, float *_setvals, \ 54 unsigned int _wherelen, unsigned int _setlen); 55 56 int32_t Search(string _names[], int32_t *_ops, float *_vals, uint32_t _n, \ 57 float *_retvals, int32_t evf); 58 }; 22 23 #include "OSSIE_CE.h" 24 25 26 using namespace std; 59 27 60 28 … … 166 134 167 135 168 class OSSIE_CE : public CognitiveEngine 169 { 170 public: 171 /*! Default constructor. */ 172 OSSIE_CE() : CognitiveEngine(){}; 173 174 /*! Default destructor. */ 175 ~OSSIE_CE(); 176 177 /*! \brief Preferred constructor. 178 * 179 * Overloaded constructor that creates a cognitive engine object and 180 * connects it to either the shell or an SML, depening on the SML bool. 181 * 182 * The 'numFields' parameter sets how large the parameter, observable, 183 * and utility arrays should be upon instantiation. 184 */ 185 OSSIE_CE(const char* serverName, const char* serverPort, \ 186 const int32_t numFields, const bool SML) \ 187 : CognitiveEngine(serverName, serverPort, numFields, SML){} 188 189 190 void RegisterServices(); 191 void DeregisterServices(); 192 193 /*! \brief Request that the CE optimize a set of parameters. 194 * 195 * Find the most optimal set of transmission parameters given certain 196 * observables and possibly a service if the SML component is present 197 * and active. */ 198 Parameter *GetSolution(Observable *observables, \ 199 Parameter *currentParameters); 200 Parameter *GetSolution(Observable *observables, \ 201 Parameter *currentParameters, std::string service); 202 203 /*! \brief Receive feedback from the radio 204 * 205 * Receive a feedback from the radio regarding the performance of a 206 * certain set of parameters, possibly associated with a service. 207 * 208 * Feedback is a single set of performance statistics that is achieved 209 * corresponding to a specific set of transmission parameters. Feedback 210 * helps a Cognitive Engine make better future decisions based upon 211 * more accurate performance statistics. 212 */ 213 void ReceiveFeedback(Observable *observables,Parameter *parameters); 214 void ReceiveFeedback(Observable *observables, Parameter *parameters, \ 215 std::string service); 216 217 218 /*! \brief Initialize the CE and prepare it for operation. 219 * 220 * BuildCognitiveEngine performs the CE implementation specific work 221 * that defines the internals of a CE. For example, a CBR CE engine 222 * would build the case-base reasoner or create the database, a neural 223 * network based CE may perform the initial training, a GA based CE 224 * may build the chromosome structure. 225 */ 226 void BuildCognitiveEngine(); 227 228 /*! \brief Each of these functions responds to a specific command. 229 * 230 * These functions are left principally un-implemented. It is the duty 231 * of child classes to implement these functions, as they define the 232 * cognitive engine's functionality. 233 */ 234 void PerformUpdatePerformance(); 235 void PerformRequestOptimizationService(); 236 void PerformRequestOptimization(); 237 void PerformQueryComponentType(); 238 void PerformConnectSML(); 239 void PerformDisconnectSML(); 240 void PerformResetEngineCognitive(); 241 void PerformShutdownEngineCognitive(); 242 243 ossieCBR *myCBR; 244 }; 136 OSSIE_CE::OSSIE_CE(const char* serverName, const char* serverPort, \ 137 const int32_t numFields, const bool SML) \ 138 : CognitiveEngine(serverName, serverPort, numFields, SML) 139 { 140 BuildCognitiveEngine(); 141 } 245 142 246 143 -
vtcross/trunk/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_Demo.cpp
r534 r545 17 17 #include <stdint.h> 18 18 19 #include "vtcross/cognitive_engine.h" 20 #include "vtcross/common.h" 21 #include "vtcross/containers.h" 19 #include "OSSIE_CE.h" 22 20 #include "vtcross/debug.h" 23 21 #include "vtcross/error.h" 24 #include "vtcross/socketcomm.h"25 22 26 23 … … 31 28 ERROR(1, "Usage: %s hostname port\n", argv[0]); 32 29 33 CognitiveEnginecognitiveEngine(argv[1], argv[2], 10, false);30 OSSIE_CE cognitiveEngine(argv[1], argv[2], 10, false); 34 31 35 32 LOG("Waiting for signal...\n");