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

📄 context.hpp

📁 非常好的进化算法EC 实现平台 可以实现多种算法 GA GP
💻 HPP
📖 第 1 页 / 共 2 页
字号:
   *  \brief Return a reference to the actual GP tree.   *  \return Actual GP tree reference.   */  inline GP::Tree& getGenotype()  {    Beagle_StackTraceBeginM();#ifndef BEAGLE_NDEBUG    if(mGenotypeHandle == NULL) throw Beagle_RunTimeExceptionM(      "The context does not have a handle to a genotype.  Consider Beagle::Context::setGenotypeHandle().");#endif // BEAGLE_NDEBUG    return castObjectT<GP::Tree&>(*mGenotypeHandle);    Beagle_StackTraceEndM("GP::Tree& GP::Context::getGenotype()");  }  /*!   *  \brief Return a handle to the actual GP tree.   *  \return Actual GP tree handle.   */  GP::Tree::Handle getGenotypeHandle()  {    Beagle_StackTraceBeginM();    return castHandleT<GP::Tree>(mGenotypeHandle);    Beagle_StackTraceEndM("GP::Tree::Handle GP::Context::getGenotypeHandle()");  }  /*!   *  \brief Return a constant reference to the actual individual.   *  \return Actual individual constant reference.   */  inline const GP::Individual& getIndividual() const  {    Beagle_StackTraceBeginM();    return castObjectT<const GP::Individual&>(Beagle::Context::getIndividual());    Beagle_StackTraceEndM("const GP::Individual& GP::Context::getIndividual() const");  }  /*!   *  \brief Return a reference to the actual GP individual.   *  \return Actual GP individual reference.   */  inline GP::Individual& getIndividual()  {    Beagle_StackTraceBeginM();    return castObjectT<GP::Individual&>(Beagle::Context::getIndividual());    Beagle_StackTraceEndM("GP::Individual& GP::Context::getIndividual()");  }  /*!   *  \brief Return a handle to the actual GP individual.   *  \return Actual GP individual handle.   */  inline GP::Individual::Handle getIndividualHandle()  {    Beagle_StackTraceBeginM();    return castHandleT<GP::Individual>(mIndividualHandle);    Beagle_StackTraceEndM("GP::Individual::Handle GP::Context::getIndividualHandle()");  }  /*!   *  \brief Return value of execution counter, used to interrupt individuals evaluation.   *  \return Number of nodes evaluated.   */  inline unsigned int getNodesExecutionCount() const  {    Beagle_StackTraceBeginM();    return mNodesExecutionCount;    Beagle_StackTraceEndM("unsigned int GP::Context::getNodesExecutionCount() const");  }  /*!   *  \brief Return a constant reference to the GP system.   *  \return Evolution GP system constant reference.   */  inline const GP::System& getSystem() const  {    Beagle_StackTraceBeginM();    return castObjectT<const GP::System&>(Beagle::Context::getSystem());    Beagle_StackTraceEndM("const GP::System& GP::Context::getSystem() const");  }  /*!   *  \brief Return a reference to the GP system.   *  \return Evolution GP system reference.   */  inline GP::System& getSystem()  {    Beagle_StackTraceBeginM();    return castObjectT<GP::System&>(Beagle::Context::getSystem());    Beagle_StackTraceEndM("GP::System& GP::Context::getSystem()");  }  /*!   *  \brief Return a handle to the GP system.   *  \return Evolution GP system handle.   */  inline GP::System::Handle getSystemHandle()  {    Beagle_StackTraceBeginM();    return castHandleT<GP::System>(mSystemHandle);    Beagle_StackTraceEndM("GP::System::Handle GP::Context::getSystemHandle()");  }  /*!   *  \brief Return a constant reference to the actual vivarium.   *  \return Actual vivarium constant reference.   */  inline const GP::Vivarium& getVivarium() const  {    Beagle_StackTraceBeginM();    return castObjectT<const GP::Vivarium&>(Beagle::Context::getVivarium());    Beagle_StackTraceEndM("const GP::Vivarium& GP::Context::getVivarium() const");  }  /*!   *  \brief Return a reference to the actual GP vivarium.   *  \return Actual GP vivarium reference.   */  inline GP::Vivarium& getVivarium()  {    Beagle_StackTraceBeginM();    return castObjectT<GP::Vivarium&>(Beagle::Context::getVivarium());    Beagle_StackTraceEndM("GP::Vivarium& GP::Context::getVivarium()");  }  /*!   *  \brief Return a handle to the actual GP vivarium.   *  \return Actual GP vivarium handle.   */  inline GP::Vivarium::Handle getVivariumHandle()  {    Beagle_StackTraceBeginM();    return castHandleT<GP::Vivarium>(mVivariumHandle);    Beagle_StackTraceEndM("GP::Vivarium::Handle GP::Context::getVivariumHandle()");  }  /*!   *  \brief Increment executed nodes counter.   *  \throw GP::MaxNodesExecutionException If the maximum number of nodes execution is exceeded.   */  inline void incrementNodesExecuted()  {    Beagle_StackTraceBeginM();    if((++mNodesExecutionCount) > mAllowedNodesExecution) {      throw Beagle::GP::MaxNodesExecutionException(        string("Number of GP nodes executed exceeded maximum allowed"),        mNodesExecutionCount,         mAllowedNodesExecution      );    }    Beagle_StackTraceEndM("void GP::Context::incrementNodesExecuted()");  }  /*!   *  \brief Pop the call stack.   *  \throw Beagle::AssertException If the call stack is empty.   */  inline void popCallStack()  {    Beagle_StackTraceBeginM();    Beagle_AssertM(mCallStack.empty() == false);    mCallStack.pop_back();    Beagle_StackTraceEndM("void GP::Context::popCallStack()");  }  /*!   *  \brief Push a node index on the call stack.   *  \param inNodeIndex Node index to push.   */  inline void pushCallStack(unsigned int inNodeIndex)  {    Beagle_StackTraceBeginM();    mCallStack.push_back(inNodeIndex);    Beagle_StackTraceEndM("void GP::Context::pushCallStack(unsigned int inNodeIndex)");  }  /*!   *  \brief Set the execution time allowed for an individual execution.   *    Allowed execution time of 0 means there is no execution time limit.   *  \param inAllowedExecutionTime Allowed execution time (in seconds).   */  inline void setAllowedExecutionTime(double inAllowedExecutionTime)  {    Beagle_StackTraceBeginM();    mAllowedExecutionTime = inAllowedExecutionTime;    Beagle_StackTraceEndM("void GP::Context::setAllowedExecutionTime(double inAllowedExecutionTime)");  }  /*!   *  \brief Set the limits on the number of nodes executed.   *  \param inAllowedNodesExecution Maximum number of nodes execution allowed.   */  inline void setAllowedNodesExecution(unsigned int inAllowedNodesExecution)  {    Beagle_StackTraceBeginM();    mAllowedNodesExecution = inAllowedNodesExecution;    Beagle_StackTraceEndM("void GP::Context::setAllowedNodesExecution(unsigned int inAllowedNodesExecution)");  }  /*!   *  \brief Set an handle to the actual GP deme.   *  \param inDemeHandle Actual GP deme handle.   */  inline void setDemeHandle(GP::Deme::Handle inDemeHandle)  {    Beagle_StackTraceBeginM();    mDemeHandle = inDemeHandle;    Beagle_StackTraceEndM("void GP::Context::setDemeHandle(GP::Deme::Handle inDemeHandle)");  }  /*!   *  \brief Set an handle to the actual GP tree.   *  \param inTreeHandle Actual GP tree handle.   */  inline void setGenotypeHandle(GP::Tree::Handle inTreeHandle)  {    Beagle_StackTraceBeginM();    mGenotypeHandle = inTreeHandle;    Beagle_StackTraceEndM("void GP::Context::setGenotypeHandle(GP::Tree::Handle inTreeHandle)");  }  /*!   *  \brief Set an handle to the actual GP individual.   *  \param inIndividualHandle Actual GP individual handle.   */  inline void setIndividualHandle(GP::Individual::Handle inIndividualHandle)  {    Beagle_StackTraceBeginM();    mIndividualHandle = inIndividualHandle;    Beagle_StackTraceEndM("void GP::Context::setIndividualHandle(GP::Individual::Handle inIndividualHandle)");  }  /*!   *  \brief Set number of nodes executed value.   *  \param inNodesExecutionCount Count of the number of nodes executed.   */  inline void setNodesExecutionCount(unsigned int inNodesExecutionCount)  {    Beagle_StackTraceBeginM();    mNodesExecutionCount = inNodesExecutionCount;    Beagle_StackTraceEndM("void GP::Context::setNodesExecutionCount(unsigned int inNodesExecutionCount)");  }  /*!   *  \brief Set the GP system handle.   *  \param inSystemHandle GP handle to the system.   */  inline void setSystemHandle(GP::System::Handle inSystemHandle)  {    Beagle_StackTraceBeginM();    mSystemHandle = inSystemHandle;    Beagle_StackTraceEndM("void GP::Context::setSystemHandle(GP::System::Handle inSystemHandle)");  }  /*!   *  \brief Set an handle to the actual GP vivarium.   *  \param inVivariumHandle Actual GP vivarium handle.   */  inline void setVivariumHandle(GP::Vivarium::Handle inVivariumHandle)  {    Beagle_StackTraceBeginM();    mVivariumHandle = inVivariumHandle;    Beagle_StackTraceEndM("void GP::Context::setVivariumHandle(GP::Vivarium::Handle inVivariumHandle)");  }protected:  std::vector< unsigned int,BEAGLE_STLALLOCATOR<unsigned int> >                     mCallStack;             //!< The GP execution call stack.  PACC::Timer        mExecutionTimer;        //!< Individual execution timer.  double             mAllowedExecutionTime;  //!< Allowed execution time for ind. execution.  unsigned int       mNodesExecutionCount;   //!< Count the number of GP nodes executed.  unsigned int       mAllowedNodesExecution; //!< Maximum allowed of GP nodes execution.};}}#endif // Beagle_GP_Context_hpp

⌨️ 快捷键说明

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