📄 symbreg.h
字号:
// symbreg.h/* ---------------------------------------------------------------Symbolic RegressionAn example for how to use gpc++ - The Genetic Programming KernelThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 1, or (at your option)any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.Copyright 1996, 1997 Thomas WeinbrennerFor comments, improvements, additions (or even money !?) contact:Thomas WeinbrennerGrauensteinstr. 2635789 LaimbachGermanyE-mail: thomasw@emk.e-technik.th-darmstadt.deWWW: http://www.emk.e-technik.th-darmstadt/~thomasw--------------------------------------------------------------- */// We are now inheriting the classes we want to change. These are the// three classes GPGene, GP and GPPopulation. Read the documentation// for what has to be done here. Remember it makes not a lot of sense// to implement Load/Save here, otherwise we should definitely have to// provide for the isA(), load(), save() and createObject() functions.class MyGP;class MyGene : public GPGene{public: MyGene (GPNode& gpo) : GPGene (gpo) {} MyGene (const MyGene& gpo) : GPGene (gpo) { } virtual GPObject& duplicate () { return *(new MyGene(*this)); } virtual GPGene* createChild (GPNode& gpo) { return new MyGene (gpo); } virtual void printOn (ostream& os); void printMathStyle (ostream& os, int lastPrecedence=0); void printTeXStyle (ostream& os, int lastPrecedence=0); MyGene* NthMyChild (int n) { return (MyGene*) GPContainer::Nth (n); } double evaluate (double x, MyGP& gp, double arg0, double arg1);};class MyGP : public GP {public: MyGP (int genes) : GP (genes) {} MyGP (MyGP& gpo) : GP (gpo) { } virtual GPObject& duplicate () { return *(new MyGP(*this)); } virtual GPGene* createGene (GPNode& gpo) { return new MyGene (gpo); } virtual void printOn (ostream& os); MyGene* NthMyGene (int n) { return (MyGene*) GPContainer::Nth (n); } virtual void evaluate ();};class MyPopulation : public GPPopulation{public: MyPopulation (GPVariables& GPVar_, GPAdfNodeSet& adfNs_) : GPPopulation (GPVar_, adfNs_) {} MyPopulation (MyPopulation& gpo) : GPPopulation(gpo) {} virtual GPObject& duplicate () { return *(new MyPopulation(*this)); } // Don't check for ultimate diversity as it takes a long time. // Accept every created GP virtual int checkForValidCreation (GP&) { return 1; } virtual GP* createGP (int numOfGenes) { return new MyGP (numOfGenes); }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -