Show
Ignore:
Timestamp:
03/04/10 12:21:27 (14 years ago)
Author:
bhilburn
Message:

Updated all cognitive engine examples to use new CBR structure.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp

    r533 r545  
    1919 */ 
    2020 
    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 
     24using namespace std; 
     25 
    12126 
    12227DSA_CE::DSA_CE() 
     
    14651    LOG("Creating Cognitive Engine.\n"); 
    14752    srand ( time(NULL) ); 
     53 
     54    BuildCognitiveEngine(); 
    14855} 
    14956