• Main Page
  • Modules
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/ECF/xcs/ClassifierParams.h

00001 #ifndef ClassifierParams_h
00002 #define ClassifierParams_h
00003 
00004 #include "../Genotype.h"
00005 #include<sstream>
00006 
00011 class ClassifierParams : public Genotype {
00012 private:
00013 
00014 public:
00015     double p_; //reward prediction
00016     double eps_; //reward prediction error
00017     double F_; //fitness
00018     
00019     double as_; //action set size estimate
00020     unsigned long long int ts_; //time stamp
00021     double exp_; //experience
00022     int num_; //numerosity
00023 
00024     ClassifierParams(double p, double eps, double F) {  
00025         this->p_ = p;
00026         this->eps_ = eps;
00027         this->F_ = F;
00028 
00029         this->as_ = 1;
00030         this->num_ = 1;
00031         this->exp_ = 0;
00032         this->ts_ = 0;
00033         name_ = "ClassifierParams";
00034     }
00035     virtual ~ClassifierParams()
00036     {   }
00037 
00038     void registerParameters(StateP state)
00039     {
00040         registerParameter(state, "fitness", (voidP) new double(0), ECF::DOUBLE);
00041         registerParameter(state, "error", (voidP) new double(0), ECF::DOUBLE);
00042         registerParameter(state, "prediction", (voidP) new double(0), ECF::DOUBLE);
00043 
00044     }
00045 
00046     virtual bool initialize(StateP state) {
00047         
00048         voidP vp = getParameterValue(state, "fitness");
00049         F_ = *((double*) vp.get());
00050         vp = getParameterValue(state, "prediction");
00051         p_ = *((double*) vp.get());
00052         vp = getParameterValue(state, "error");
00053         eps_ = *((double*) vp.get());
00054         
00055         return true;
00056     }
00057 
00058     virtual Genotype* copy() {
00059         
00060         ClassifierParams *newObject = new ClassifierParams(*this);
00061         return newObject;
00062     }
00063 
00064     virtual std::vector<CrossoverOpP> getCrossoverOp() {
00065         std::vector<CrossoverOpP> vCrossOp;
00066         return vCrossOp;
00067     }
00068 
00069     virtual std::vector<MutationOpP> getMutationOp() {
00070         std::vector<MutationOpP> vMutOp;
00071         return vMutOp;
00072     }   
00073 
00074     virtual void read(XMLNode& node) {
00075         std::stringstream ss;
00076         ss << node.getAttribute("prediction");
00077         ss >> p_;
00078         
00079         ss.str("");
00080         ss << node.getAttribute("fitness");
00081         ss >> F_;
00082 
00083         ss.str("");
00084         ss << node.getAttribute("error");
00085         ss >> eps_;
00086 
00087         ss.str("");
00088         ss << node.getAttribute("as");
00089         ss >> as_;
00090 
00091         ss.str("");
00092         ss << node.getAttribute("num");
00093         ss >> num_;
00094 
00095         ss.str("");
00096         ss << node.getAttribute("exp");
00097         ss >> exp_;
00098 
00099         ss.str("");
00100         ss << node.getAttribute("ts");
00101         ss >> ts_;
00102     }
00103 
00104     virtual void write(XMLNode& node) {
00105         node = XMLNode::createXMLTopNode("ClassifierParams");
00106         
00107         std::stringstream sValue;
00108         sValue << p_;
00109         node.addAttribute("prediction", sValue.str().c_str());
00110 
00111         sValue.str("");
00112         sValue << F_;
00113         node.addAttribute("fitness", sValue.str().c_str());
00114 
00115         sValue.str("");
00116         sValue << eps_;
00117         node.addAttribute("error", sValue.str().c_str());
00118 
00119         sValue.str("");
00120         sValue << num_;
00121         node.addAttribute("num", sValue.str().c_str());
00122 
00123         sValue.str("");
00124         sValue << ts_;
00125         node.addAttribute("ts", sValue.str().c_str());
00126 
00127         sValue.str("");
00128         sValue << as_;
00129         node.addAttribute("as", sValue.str().c_str());
00130 
00131         sValue.str("");
00132         sValue << exp_;
00133         node.addAttribute("exp", sValue.str().c_str());
00134     }
00135 
00136 };
00137 typedef boost::shared_ptr<ClassifierParams> ClassifierParamsP;
00138 
00139 #endif 

Generated on Tue Nov 4 2014 13:04:31 for ECF by  doxygen 1.7.1