HOG2
FunctionApproximator.h
Go to the documentation of this file.
1 /*
2  * FunctionApproximator.h
3  * games
4  *
5  * Created by Adam White on Mon Apr 04 2005.
6  * Copyright (c) 2005 __MyCompanyName__. All rights reserved.
7  *
8  */
9 
10 //#include "LearningPlayer.h"
11 #include <ctime>
12 #include <vector>
13 #include <stdio.h>
14 //#include "random.h"
15 
16 #ifndef FUNCTIONAPPROXIMATOR_H
17 #define FUNCTIONAPPROXIMATOR_H
18 
23 };
24 
26 public:
28  virtual ~FunctionApproximator() {};
29 
30  //virtual FunctionApproximator *clone() const = 0;
31 
32  virtual void save(const char *) = 0;
33  virtual void save(FILE *) = 0;
34  virtual void load(const char *) = 0;
35  virtual void load(FILE *) = 0;
36  virtual void load(const FunctionApproximator *) = 0;
37 
38  // these fucntions are for training with the list of all features and their (arbitrary) values
39  virtual double train(std::vector<double> &input, std::vector<double> &output2) = 0;
40  virtual double *test(const std::vector<double> &input) = 0;
41  // these functions are for training with a list of binary features that are on
42  virtual double train(std::vector<unsigned int> &input, std::vector<double> &output2) = 0;
43  virtual double *test(const std::vector<unsigned int> &input) = 0;
44  // Given a target output (fixed internal weights), return the intput that would
45  // lead to the output. (May require more than one call to converge.)
46  virtual double GetInput(std::vector<double> &input, const std::vector<double> &target) = 0;
47 
48  virtual void setLearnRate(double);
49  virtual double getLearnRate();
50 
52  { outputActivation = t; }
54  { return outputActivation; }
55 
56  virtual int getNumInputs() { return 0; }
57  virtual double getInputWeight(int inp, int outp=0) { return 0; }
58 
59  virtual void Print() = 0;
60 protected:
61  double rate;
63 };
64 
65 #endif
FunctionApproximator::train
virtual double train(std::vector< double > &input, std::vector< double > &output2)=0
FunctionApproximator::setLearnRate
virtual void setLearnRate(double)
Definition: FunctionApproximator.cpp:17
FunctionApproximator::setOutputActivation
void setOutputActivation(tActivation t)
Definition: FunctionApproximator.h:51
FunctionApproximator::save
virtual void save(const char *)=0
FunctionApproximator::~FunctionApproximator
virtual ~FunctionApproximator()
Definition: FunctionApproximator.h:28
FunctionApproximator::getOutputActivation
tActivation getOutputActivation()
Definition: FunctionApproximator.h:53
FunctionApproximator::getLearnRate
virtual double getLearnRate()
Definition: FunctionApproximator.cpp:12
FunctionApproximator::rate
double rate
Definition: FunctionApproximator.h:61
kExponential
@ kExponential
Definition: FunctionApproximator.h:22
FunctionApproximator
Definition: FunctionApproximator.h:25
FunctionApproximator::test
virtual double * test(const std::vector< double > &input)=0
kStep
@ kStep
Definition: FunctionApproximator.h:21
kLinear
@ kLinear
Definition: FunctionApproximator.h:20
FunctionApproximator::getInputWeight
virtual double getInputWeight(int inp, int outp=0)
Definition: FunctionApproximator.h:57
FunctionApproximator::FunctionApproximator
FunctionApproximator()
Definition: FunctionApproximator.h:27
FunctionApproximator::load
virtual void load(const char *)=0
tActivation
tActivation
Definition: FunctionApproximator.h:19
FunctionApproximator::getNumInputs
virtual int getNumInputs()
Definition: FunctionApproximator.h:56
FunctionApproximator::outputActivation
tActivation outputActivation
Definition: FunctionApproximator.h:62
FunctionApproximator::Print
virtual void Print()=0
FunctionApproximator::GetInput
virtual double GetInput(std::vector< double > &input, const std::vector< double > &target)=0