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

📄 evaluationop.cpp

📁 非常好的进化算法EC 实现平台 可以实现多种算法 GA GP
💻 CPP
字号:
/* *  Open BEAGLE *  Copyright (C) 2001-2005 by Christian Gagne and Marc Parizeau * *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public *  License as published by the Free Software Foundation; either *  version 2.1 of the License, or (at your option) any later version. * *  This library is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with this library; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * *  Contact: *  Laboratoire de Vision et Systemes Numeriques *  Departement de genie electrique et de genie informatique *  Universite Laval, Quebec, Canada, G1K 7P4 *  http://vision.gel.ulaval.ca * *//*! *  \file   beagle/GP/src/EvaluationOp.cpp *  \brief  Source code of class GP::EvaluationOp. *  \author Christian Gagne *  \author Marc Parizeau *  $Revision: 1.7 $ *  $Date: 2005/10/04 16:25:10 $ */#include "beagle/GP.hpp"#include <string>using namespace Beagle;/*! *  \brief Construct a evaluation operator. *  \param inName Name of the operator. */GP::EvaluationOp::EvaluationOp(Beagle::string inName) :  Beagle::EvaluationOp(inName){ }/*! *  \brief Evaluate the fitness of the given GP individual. *  \param inIndividual Current individual to evaluate. *  \param ioContext Evolutionary context. *  \return Handle to the fitness value of the GP individual. */Fitness::Handle GP::EvaluationOp::evaluate(Beagle::Individual& inIndividual,                                           Beagle::Context& ioContext){  Beagle_StackTraceBeginM();  return evaluate(castObjectT<GP::Individual&>(inIndividual), castObjectT<GP::Context&>(ioContext));  Beagle_StackTraceEndM("Fitness::Handle GP::EvaluationOp::evaluate(Beagle::Individual& inIndividual, Beagle::Context& ioContext)");}/*! *  \brief Set the value of the named GP primitive of the primitive sets. *  \param inName Name of the variable to set. *  \param inValue Value of the primitive. *  \param ioContext Context of the evaluation. *  \throw Beagle::RunTimeException If the named primitive is not found in any sets. */void GP::EvaluationOp::setValue(Beagle::string inName,                                const Object& inValue,                                GP::Context& ioContext) const{  Beagle_StackTraceBeginM();  GP::PrimitiveSuperSet& lSuperSet = ioContext.getSystem().getPrimitiveSuperSet();  bool lValueFound = false;  Beagle_LogDebugM(    ioContext.getSystem().getLogger(),    "evaluation", "Beagle::GP::EvaluationOp",    string("Setting the primitives named \"")+inName+    string("\" to the value: ")+inValue.serialize()  );  for(unsigned int i=0; i<lSuperSet.size(); i++) {    Primitive::Handle lPrimitive = lSuperSet[i]->getPrimitiveByName(inName);    if(!lPrimitive) continue;    lValueFound = true;    lPrimitive->setValue(inValue);  }  if(lValueFound == false) {    string lMessage = "The primitive named \"";    lMessage += inName;    lMessage += "\" was not found in any ";    lMessage += "of the primitive sets. Maybe the primitive was not properly inserted ";    lMessage += "or the name is mispelled.";    throw Beagle_RunTimeExceptionM(lMessage);  }  Beagle_StackTraceEndM("void GP::EvaluationOp::setValue(string inName, const Object& inValue, GP::Context& ioContext) const");}

⌨️ 快捷键说明

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