home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 08 Manslow / CConditionalDistribution.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-01  |  3.0 KB  |  89 lines

  1. //Tanks
  2. //Copyright John Manslow
  3. //29/09/2001
  4. #ifndef _CConditionalDistribution_
  5. #define _CConditionalDistribution_
  6.  
  7. class CConditionalDistribution
  8. {
  9. public:
  10.     CConditionalDistribution(
  11.         const unsigned long,        //Number of inputs
  12.         const unsigned long,        //Number of hidden neurons
  13.         const unsigned long            //Number of bins
  14.         );
  15.  
  16.     ~CConditionalDistribution();
  17.  
  18.     //Used to reset the perturbation search and set the 
  19.     //weights in the neural network component to random values
  20.     void Reset(void);                
  21.  
  22.     //This function must be called repeatedly (perhaps many thousands of times) in order to accurately model
  23.     //the distribution that describes the exemplar data. The function is passed the quantity and location of the 
  24.     //exemplar data and returns a measure of the network's current performance
  25.     double dTrainingStep(
  26.         const unsigned long,        //The number of samples in the exemplar data
  27.         double ** const,            //A pointer to the array of input samples
  28.         double * const                //A pointer to the array of target outputs
  29.         );
  30.  
  31.     //Returns a single random sample from the distribution computed in response to the inputs provided
  32.     double dGetOutputs(
  33.         const double * const        //A pointer to an array of inputs
  34.         );
  35.  
  36.     //Returns a vector of probabiltiies that are to be associated with the distribution's bins given the input provided
  37.     double *pdGetBinProbabilities(
  38.         const double * const        //A pointer to an array of inputs
  39.         );
  40.  
  41.     //Returns the performance of the network on the exemplar data.
  42.     double dGetPerformance(void);
  43.  
  44.     //Computes the performance of the network on the data set indicated in the function's
  45.     //parameters. Used internally. Should only be called from outside the class if
  46.     //the network's performance on a data set different to that passed to dTrainingStep is
  47.     //required.
  48.     double dGetPerformance(
  49.         const unsigned long,        //The number of samples in the data set
  50.         double** const,                //A pointer to the array of inputs
  51.         double* const                //A pointer to the array of target outputs
  52.         );
  53.  
  54.     //Functions used to allocate and deallocate memory
  55.     void AllocateMemory(void);        
  56.     void DeallocateMemory(void);
  57.  
  58.     int Save(const char * const);    //Used to load and save the model
  59.     int Load(const char * const);
  60.  
  61. //A couple of the member variables are accessed from outside the class to aid visualisation 
  62. //private:
  63.     //These variables contain information about the model's structure
  64.     unsigned long ulNumberOfInputs;
  65.     unsigned long ulNumberOfHiddenNodes;
  66.     unsigned long ulNumberOfOutputs;                //(Note, ulNumberOfOutputs = number of bins in the model)
  67.  
  68.     //This is the step size currently used in the perturbation search
  69.     double dStepSize;
  70.  
  71.     //The performance of the model measured during the dTrainingStep function
  72.     double dBestError;
  73.  
  74.     //Pointers to the model's weights
  75.     double **ppdwih;
  76.     double **ppdwho;
  77.  
  78.     //Pointers to the best weights found during learning
  79.     double **ppdBestwih;
  80.     double **ppdBestwho;
  81.  
  82.     //Used to store the time and date when training started
  83.     char *pTrainingStartTime;
  84.     char *pTrainingStartDate;
  85. };
  86.  
  87. #endif
  88.  
  89.