⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadsave.cc

📁 用C++编写的遗传算法
💻 CC
字号:
// loadsave.cc/* -------------------------------------------------------------------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 1993, 1994 Adam P. Fraser and 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  or (Address may be out of date)Adam Fraser, Postgraduate Section, Dept of Elec & Elec Eng,Maxwell Building, University Of Salford, Salford, M5 4WT, United Kingdom.E-mail: a.fraser@eee.salford.ac.ukTel:    (UK) 061 745 5000 x3633Fax:    (UK) 061 745 5999------------------------------------------------------------------- */#include <stdio.h>#include "gp.h"#define MAXIMUMCLASSNUM 30   // Hope it won't be more. Otherwise change itstatic int ids[MAXIMUMCLASSNUM];static GPObject* loadSaveObjects[MAXIMUMCLASSNUM];static int registered=0;// Create an object and return it.  If the ID is not registered,// report an errorGPObject* GPCreateRegisteredClassObject (int ID){  // Loop through all registered objects  for (int i=0; i<registered; i++)    {      if (ids[i]==ID)	// Found!  Now call the virtual function createObject() to	// create an object of same class.	return loadSaveObjects[i]->createObject ();    }#if GPINTERNALCHECK  GPExitSystem ("GPCreateRegisteredClassObject", 		"Can't create object of class not registered");#endif  return NULL;}// Register a single classvoid GPRegisterClass (GPObject* gpo){#if GPINTERNALCHECK  if (registered==MAXIMUMCLASSNUM)    GPExitSystem ("GPRegisterClass", 		  "No more classes allowed. Increase MAXIMUMCLASSNUM");#endif  // Save ID and pointer to object  ids[registered]=gpo->isA();  loadSaveObjects[registered++]=gpo;}// Register all classes of GP kernelvoid GPRegisterKernelClasses (){  GPRegisterClass (new GPContainer());  GPRegisterClass (new GPNode());  GPRegisterClass (new GPNodeSet());  GPRegisterClass (new GPAdfNodeSet());  GPRegisterClass (new GPVariables());  GPRegisterClass (new GPGene());  GPRegisterClass (new GP());  GPRegisterClass (new GPPopulation());}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -