/*! * \return Maximum execution time allowed (in seconds). */ inline double getMaxTimeAllowed() const { Beagle_StackTraceBeginM(); return mMaxTimeAllowed; Beagle_StackTraceEndM("double GP::MaxTimeExecutionException::getMaxTimeAllowed() const"); }
//! Return a handle to the register. inline Register::Handle getRegisterHandle(void) { Beagle_StackTraceBeginM(); return mRegister; Beagle_StackTraceEndM("Register::Handle System::getRegisterHandle(void)"); }
/*! * \brief Set the line number in the file where the exception is detected (throwed). * \param inLineNumber Line number in the file where the exception is detected. */ inline void setLineNumber(unsigned int inLineNumber) { Beagle_StackTraceBeginM(); mLineNumber = inLineNumber; Beagle_StackTraceEndM("void TargetedException::setLineNumber(unsigned int inLineNumber)"); }
//! Return a reference to the logger. inline Logger& getLogger(void) { Beagle_StackTraceBeginM(); return *mLogger; Beagle_StackTraceEndM("Logger& System::getLogger(void)"); }
//! Return a const reference to the register. inline const Register& getRegister(void) const { Beagle_StackTraceBeginM(); return *mRegister; Beagle_StackTraceEndM("const Register& System::getRegister(void) const"); }
const std::type_info* Beagle::GP::DivideT<T>::getReturnType(Beagle::GP::Context& ioContext) const { Beagle_StackTraceBeginM(); return &typeid(T); Beagle_StackTraceEndM(); }
//! Return a reference to the factory. inline Factory& getFactory(void) { Beagle_StackTraceBeginM(); return *mFactory; Beagle_StackTraceEndM("Factory& System::getFactory(void)"); }
/*! * \return The history traces. */ inline const Beagle::HistoryTrace::Bag& Beagle::History::getTraces() const { Beagle_StackTraceBeginM(); return mTraces; Beagle_StackTraceEndM(); }
/*! * \return The first history trace ID among currently stored traces. */ inline unsigned int Beagle::History::getFirstID() const { Beagle_StackTraceBeginM(); return mTracesFirst; Beagle_StackTraceEndM(); }
bool Beagle::GP::MutationEphemeralOpT<T>::mutate(Beagle::Individual& ioIndividual, Beagle::Context& ioContext) { Beagle_StackTraceBeginM(); Beagle_LogDetailedM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", std::string("Mutating ")+uint2ordinal(ioContext.getGenotypeIndex()+1)+ std::string(" individual with GP::MutationEphemeralOpT") ); GP::Individual& lIndividual = castObjectT<GP::Individual&>(ioIndividual); GP::Context& lContext = castObjectT<GP::Context&>(ioContext); // Get index of potential primitives with parameters that can be selected for mutation. std::vector< std::pair<unsigned int,unsigned int> > lPotentialParam; for(unsigned int i=0; i<lIndividual.size(); ++i) { GP::Tree& lTree = *lIndividual[i]; for(unsigned int j=0; j<lTree.size(); ++j) { if(lTree[j].mPrimitive->getName() == *mEphemeralName) { lPotentialParam.push_back(std::make_pair(i,j)); } } } // Return if there is not potential parameters. if(lPotentialParam.empty()) return false; // Mutating a primitive Beagle_LogDebugM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", "Individual before GP parameters mutation" ); Beagle_LogObjectDebugM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", ioIndividual ); // Store original context values unsigned int lOldGenotypeIndex = lContext.getGenotypeIndex(); GP::Tree::Handle lOldGenotypeHandle = lContext.getGenotypeHandle(); // Get reference to primitive to mutate and other objects. const unsigned int lSelectedParam = lContext.getSystem().getRandomizer().rollInteger(0,lPotentialParam.size()-1); GP::Tree::Handle lSelectedTree = lIndividual[lPotentialParam[lSelectedParam].first]; lContext.setGenotypeIndex(lPotentialParam[lSelectedParam].first); lContext.setGenotypeHandle(lSelectedTree); Beagle_LogVerboseM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", std::string("Mutating the parameter of the ")+ uint2ordinal(lPotentialParam[lSelectedParam].second+1)+ std::string(" node in the ")+uint2ordinal(lPotentialParam[lSelectedParam].first+1)+ std::string(" tree") ); // Mutate parameter value. GP::Primitive::Handle lSelectedPrimit = (*lSelectedTree)[lPotentialParam[lSelectedParam].second].mPrimitive; typename GP::EphemeralT<T>::Handle lSelectedEphemeral = castHandleT<typename GP::EphemeralT<T> >(lSelectedPrimit); GP::Primitive::Handle lGeneratedPrimit = lSelectedEphemeral->generate(mEphemeralName->getWrappedValue(), lContext); (*lSelectedTree)[lPotentialParam[lSelectedParam].second].mPrimitive = lGeneratedPrimit; Beagle_LogVerboseM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", std::string("Changing the ephemeral from ")+lSelectedPrimit->serialize()+ std::string(" to ")+lGeneratedPrimit->serialize() ); // Restore original context values lContext.setGenotypeIndex(lOldGenotypeIndex); lContext.setGenotypeHandle(lOldGenotypeHandle); Beagle_LogDebugM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", "Individual after GP parameters mutation" ); Beagle_LogObjectDebugM( ioContext.getSystem().getLogger(), "mutation", "Beagle::GP::MutationEphemeralOpT", ioIndividual ); return true; Beagle_StackTraceEndM("bool GP::MutationEphemeralOpT<T>::mutate(Individual& ioIndividual, Context& ioContext)"); }
/*! * \return Number of towns in the map. */ inline unsigned int getNumberOfTowns() const { Beagle_StackTraceBeginM(); return mNumberOfTowns->getWrappedValue(); Beagle_StackTraceEndM("unsigned int getNumberOfTowns() const"); }
/*! * \return Index of the tree invoked. */ inline unsigned int getIndex() const { Beagle_StackTraceBeginM(); return mIndex; Beagle_StackTraceEndM(); }
/*! * \return Name of the argument primitives associated to the invoker. */ inline std::string getArgsName() const { Beagle_StackTraceBeginM(); return mArgsName; Beagle_StackTraceEndM(); }
/*! * \brief Standard operator for accessing elements by index. * \param inN Index of element (first is 0). * \return Smart pointer to element. */ inline Object::Handle& operator[](unsigned int inN) { Beagle_StackTraceBeginM(); Beagle_UpperBoundCheckAssertM(inN,size()-1); return std::vector<Pointer>::operator[](inN); Beagle_StackTraceEndM(); }
/*! * \brief Get a member by its name. * \param inName Name of the member to obtain. * \return Reference to the member, a NULL pointer if there is no member with given name. */ inline Member::Handle getMember(const std::string& inName) { Beagle_StackTraceBeginM(); MemberMap::iterator lIterMap = mMemberMap.find(inName); return (lIterMap == mMemberMap.end()) ? NULL : castHandleT<Member>(lIterMap->second); Beagle_StackTraceEndM(); }
/*! * \return First child to the breeder. */ inline PointerT<BreederNode,Object::Handle> getFirstChild() const { Beagle_StackTraceBeginM(); return mChild; Beagle_StackTraceEndM("PointerT<BreederNode,Object::Handle> BreederNode::getFirstChild() const"); }
/*! * \brief Get an handle to the statistics. * \return Handle to the statistics, a NULL handle if no statistics is present. */ inline Stats::Handle getStats() { Beagle_StackTraceBeginM(); MemberMap::iterator lIterMap = mMemberMap.find("Stats"); return (lIterMap == mMemberMap.end()) ? NULL : castHandleT<Stats>(lIterMap->second); Beagle_StackTraceEndM(); }
/*! * \return Next sibbling to the breeder. */ inline PointerT<BreederNode,Object::Handle> getNextSibling() const { Beagle_StackTraceBeginM(); return mSibling; Beagle_StackTraceEndM("PointerT<BreederNode,Object::Handle> BreederNode::getNextSibling() const"); }
//! Return a const reference to the factory. inline const Factory& getFactory(void) const { Beagle_StackTraceBeginM(); return *mFactory; Beagle_StackTraceEndM("const Factory& System::getFactory(void) const"); }
/*! * \brief Set breeder operator associated to actual node. * \param inBreederOp New breeder operator associated to breeder node. */ inline void setBreederOp(PointerT<BreederOp,Operator::Handle> inBreederOp) { Beagle_StackTraceBeginM(); mBreederOp = inBreederOp; Beagle_StackTraceEndM("void BreederNode::setBreederOp(PointerT<BreederOp,Operator::Handle> inBreederOp)"); }
//! Return a handle to the factory. inline Factory::Handle getFactoryHandle(void) { Beagle_StackTraceBeginM(); return mFactory; Beagle_StackTraceEndM("Register::Handle System::getFactoryHandle(void)"); }
/*! * \brief Set first child of the breeder. * \param inChild New first child. */ inline void setFirstChild(PointerT<BreederNode,Object::Handle> inChild) { Beagle_StackTraceBeginM(); mChild = inChild; Beagle_StackTraceEndM("void BreederNode::setFirstChild(PointerT<BreederNode,Object::Handle> inChild)"); }
//! Return a handle to the logger. inline Logger::Handle getLoggerHandle(void) { Beagle_StackTraceBeginM(); return mLogger; Beagle_StackTraceEndM("Logger::Handle System::getLoggerHandle(void)"); }
/*! * \brief Set next sibbling of the breeder. * \param inSibling New next sibling. */ inline void setNextSibling(PointerT<BreederNode,Object::Handle> inSibling) { Beagle_StackTraceBeginM(); mSibling = inSibling; Beagle_StackTraceEndM("void BreederNode::setNextSibling(PointerT<BreederNode,Object::Handle> inSibling)"); }
//! Return a reference to the register. inline Register& getRegister(void) { Beagle_StackTraceBeginM(); return *mRegister; Beagle_StackTraceEndM("Register& System::getRegister(void)"); }
/*! * \return Breeder operator associated to node. */ inline PointerT<BreederOp,Operator::Handle> getBreederOp() const { Beagle_StackTraceBeginM(); return mBreederOp; Beagle_StackTraceEndM("PointerT<BreederOp,Operator::Handle> BreederNode::getBreederOp() const"); }
/*! * \brief Set the file name where the exception is detected (throwed). * \param inFileName File name where the exception is detected. */ inline void setFileName(const std::string& inFileName) { Beagle_StackTraceBeginM(); mFileName = inFileName; Beagle_StackTraceEndM("void TargetedException::setFileName(const std::string& inFileName)"); }
/*! * \brief Get an handle to the hall-of-fame. * \return Handle to the hall-of-fame, a NULL handle if no hall-of-fame is present. */ inline HallOfFame::Handle getHallOfFame() { Beagle_StackTraceBeginM(); MemberMap::const_iterator lIterMap = mMemberMap.find("HallOfFame"); return (lIterMap == mMemberMap.end()) ? NULL : castHandleT<HallOfFame>(lIterMap->second); Beagle_StackTraceEndM(); }
/*! \brief Ask OpenMP how many processors are available. * \return The number of processors on this machine. */ inline unsigned int getNumProcs() const{ Beagle_StackTraceBeginM(); return omp_get_num_procs(); Beagle_StackTraceEndM("unsigned int OpenMP::getNumProcs() const"); }
/*! * \brief Set the history variation of the individual. */ inline void Beagle::HistoryEntry::setIndividualVar(unsigned int inIndividualVar) { Beagle_StackTraceBeginM(); mIndividualVar = inIndividualVar; Beagle_StackTraceEndM(); }