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/CBR_CE/CBR_CE.cpp

    r534 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/containers.h" 
    31 #include "vtcross/debug.h" 
    32 #include "vtcross/error.h" 
    33 #include "vtcross/socketcomm.h" 
     21#include "CBR_CE.h" 
    3422 
    3523 
     
    3725 
    3826 
    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 }; 
     27CBR_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} 
    11633 
    11734