ECF 1.5
XCSParams.cpp
1#include "XCSParams.h"
2
3void XCSParams::registerParams(RegistryP registry) {
4
5 //Default values taken from AlgXCS.cpp [1]
6
7 registerParameter(registry, "beta", (voidP) new double(0.15), ECF::DOUBLE);
8 registerParameter(registry, "alpha", (voidP) new double(0.1), ECF::DOUBLE);
9 registerParameter(registry, "eps0", (voidP) new double(10), ECF::DOUBLE);
10 registerParameter(registry, "accExp", (voidP) new double(5), ECF::DOUBLE);
11 registerParameter(registry, "gama", (voidP) new double(0.71), ECF::DOUBLE);
12 registerParameter(registry, "thresholdGA", (voidP) new uint(30), ECF::UINT);
13 registerParameter(registry, "thresholdDel", (voidP) new double(20), ECF::DOUBLE);
14 registerParameter(registry, "delta", (voidP) new double(0.1), ECF::DOUBLE);
15 registerParameter(registry, "thresholdSub", (voidP) new double(20), ECF::DOUBLE);
16 registerParameter(registry, "pDontCare", (voidP) new double(0.33), ECF::DOUBLE);
17 registerParameter(registry, "pExplore", (voidP) new double(0.5), ECF::DOUBLE);
18 registerParameter(registry, "mna", (voidP) new uint(1), ECF::UINT);
19 registerParameter(registry, "maxPopSize", (voidP) new uint(1000), ECF::UINT);
20
21 registerParameter(registry, "pCrossover", (voidP) new double(0.7), ECF::DOUBLE);
22 registerParameter(registry, "pMutation", (voidP) new double(0.03), ECF::DOUBLE);
23}
24
25void XCSParams::readParams(RegistryP registry) {
26
27 voidP vP = getParameterValue(registry, "mna");
28 mna_ = *((uint*) vP.get());
29
30 vP = getParameterValue(registry, "pExplore");
31 p_explore_ = *((double*) vP.get());
32 vP = getParameterValue(registry, "beta");
33 beta_ = *((double*) vP.get());
34 vP = getParameterValue(registry, "thresholdGA");
35 thresholdGA_ = *((uint*) vP.get());
36 vP = getParameterValue(registry, "gama");
37 gama_ = *((double*) vP.get());
38
39 vP = getParameterValue(registry, "eps0");
40 eps0_ = *((double*) vP.get());
41 vP = getParameterValue(registry, "alpha");
42 alpha_ = *((double*) vP.get());
43 vP = getParameterValue(registry, "accExp");
44 accExp_ = *((double*) vP.get());
45 vP = getParameterValue(registry, "pDontCare");
46 pdc_ = *((double*) vP.get());
47
48 vP = getParameterValue(registry, "thresholdDel");
49 thresholdDel_ = *((double*) vP.get());
50 vP = getParameterValue(registry, "delta");
51 delta_ = *((double*) vP.get());
52 vP = getParameterValue(registry, "thresholdSub");
53 thresholdSub_ = *((double*) vP.get());
54 vP = getParameterValue(registry, "maxPopSize");
55 popSize_ = *((uint*) vP.get());
56 vP = getParameterValue(registry, "pCrossover");
57 pCrossover_ = *((double*) vP.get());
58 vP = getParameterValue(registry, "pMutation");
59 pMutation_ = *((double*) vP.get());
60}
61
62XMLNode XCSParams::getXMLNode() {
63
64 XMLNode node = XMLNode::createXMLTopNode(name_.c_str(),0);
65 XMLNode child = XMLNode::createXMLTopNode(NODE_ENTRY);
66
67 std::stringstream ss;
68 ss << alpha_; child.addAttribute("key", "alpha"); child.addText(ss.str().c_str());
69 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
70 ss << beta_; child.addAttribute("key", "beta"); child.addText(ss.str().c_str());
71 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
72 ss << gama_; child.addAttribute("key", "gama"); child.addText(ss.str().c_str());
73 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
74 ss << delta_; child.addAttribute("key", "delta"); child.addText(ss.str().c_str());
75 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
76 ss << p_explore_; child.addAttribute("key", "pExplore"); child.addText(ss.str().c_str());
77 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
78 ss << thresholdGA_; child.addAttribute("key", "thresholdGA"); child.addText(ss.str().c_str());
79 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
80 ss << thresholdDel_; child.addAttribute("key", "thresholdDel"); child.addText(ss.str().c_str());
81 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
82 ss << thresholdSub_; child.addAttribute("key", "thresholdSub"); child.addText(ss.str().c_str());
83 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
84 ss << eps0_; child.addAttribute("key", "eps0"); child.addText(ss.str().c_str());
85 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
86 ss << accExp_; child.addAttribute("key", "accExp"); child.addText(ss.str().c_str());
87 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
88 ss << pdc_; child.addAttribute("key", "pDontCare"); child.addText(ss.str().c_str());
89 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
90 ss << popSize_; child.addAttribute("key", "maxPopSize"); child.addText(ss.str().c_str());
91 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
92 ss << mna_; child.addAttribute("key", "mna"); child.addText(ss.str().c_str());
93 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
94
95 ss << pCrossover_; child.addAttribute("key", "pCrossover"); child.addText(ss.str().c_str());
96 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
97 ss << pMutation_; child.addAttribute("key", "pMutation"); child.addText(ss.str().c_str());
98 node.addChild(child); ss.str(""); child = XMLNode::createXMLTopNode(NODE_ENTRY);
99
100 return node;
101}
Definition: nodes.h:92