/*!
	 *  \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)");
	}
Example #2
0
	/*!
	 *  \brief Insert an operator in the negative set of the if-then-else operator.
	 *  \param inOperator Operator to insert.
	 *  \warning Insert your operators before the initialization!
	 */
	void insertNegativeOp(Beagle::Operator::Handle inOperator) {
		Beagle_StackTraceBeginM();
		mNegativeOpSet.push_back(inOperator);
		Beagle_StackTraceEndM();
	}
Example #3
0
	/*!
	 *  \brief Set parameter value of condition to use.
	 */
	inline void setConditionValue(std::string inValue) {
		Beagle_StackTraceBeginM();
		mConditionValue = inValue;
		Beagle_StackTraceEndM();
	}
Example #4
0
 /*!
  *  \brief Validate the fitness.
  */
 inline void setValid() {
     Beagle_StackTraceBeginM();
     mValid = true;
     Beagle_StackTraceEndM();
 }
Example #5
0
	/*!
	 *  \brief Return a constant reference to the positive operator set.
	 *  \return Positive operator set constant reference.
	 */
	inline const Beagle::Operator::Bag& getPositiveSet() const {
		Beagle_StackTraceBeginM();
		return mPositiveOpSet;
		Beagle_StackTraceEndM();
	}
Example #6
0
	/*!
	 *  \brief Get the wrapped type value.
	 *  \return A constant reference to the wrapped value.
	 */
	inline const T& getWrappedValue() const {
		Beagle_StackTraceBeginM();
		return mWrappedValue;
		Beagle_StackTraceEndM();
	}
Example #7
0
 /*!
  *  \brief Return validity of the fitness.
  *  \return True if fitness is valid, false if not.
  */
 inline bool isValid() const {
     Beagle_StackTraceBeginM();
     return mValid;
     Beagle_StackTraceEndM();
 }
/*!
 *  \brief  Test whether an string is not equal to another.
 *  \param  inLeftString  Left string compared.
 *  \param  inRightString Right string compared.
 *  \return True if left string is not equal to the right one, false if it is.
 *  \par Note:
 *    The operator is defined relatively to the function isEqual of Beagle::String.
 */
inline bool operator!=(const Beagle::String& inLeftString, const Beagle::String& inRightString)
{
	Beagle_StackTraceBeginM();
	return ( inLeftString.isEqual(inRightString) == false);
	Beagle_StackTraceEndM("bool operator!=(const String& inLeftString, const String& inRightString)");
}
/*!
 *  \brief  Test whether an string is more than another.
 *  \param  inLeftString  Left string compared.
 *  \param  inRightString Right string compared.
 *  \return True if left string is more than the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the function isLess of Beagle::String.
 */
inline bool operator>(const Beagle::String& inLeftString, const Beagle::String& inRightString)
{
	Beagle_StackTraceBeginM();
	return inRightString.isLess(inLeftString);
	Beagle_StackTraceEndM("bool operator>(const String& inLeftString, const String& inRightString)");
}
	/*!	\brief Set the number of threads that OpenMP will use in the parallel sections.
	 *	\param iNumThreads is the number of threads to use.
	 */
	inline virtual void	setNumThreads(unsigned int inNumThreads){
		Beagle_StackTraceBeginM();
		omp_set_num_threads(inNumThreads);
		Beagle_StackTraceEndM("unsigned int OpenMP::setNumThreads(unsigned int)");
	}
	/*!	\brief
	 *	\return
	 */
	inline unsigned int getThreadNum() const{
		Beagle_StackTraceBeginM();
		return omp_get_thread_num();
		Beagle_StackTraceEndM("unsigned int OpenMP::getThreadNum() const");
	}
	/*!	\brief
	 *	\return
	 */
	inline bool	inParallelSection() const{
		Beagle_StackTraceBeginM();
		return (omp_in_parallel()>0)?true:false;
		Beagle_StackTraceEndM("unsigned int OpenMP::inParallelSection() const");
	}
	/*!	\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 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)");
	}
	/*!
	 *  \brief Return number of emigrants available in current migration buffer.
	 *  \return Number of emigrants available in current migration buffer.
	 */
	inline unsigned int getNumberOfEmigrants() const
	{
		Beagle_StackTraceBeginM();
		return mEmigrants.size();
		Beagle_StackTraceEndM("unsigned int MigrationBuffer::getNumberOfEmigrants() const");
	}
Example #16
0
/*!
 *  \brief  Test whether an unsigned long is less than, or equal to another.
 *  \param  inLeftULong  Left unsigned long compared.
 *  \param  inRightULong Right unsigned long compared.
 *  \return True if left unsigned long is less than, or equal to the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the functions isLess and isEqual of Beagle::ULong.
 */
inline bool operator<=(const Beagle::ULong& inLeftULong, const Beagle::ULong& inRightULong)
{
	Beagle_StackTraceBeginM();
	return ( inLeftULong.isLess(inRightULong) || inLeftULong.isEqual(inRightULong) );
	Beagle_StackTraceEndM("bool operator<=(const ULong& inLeftULong, const ULong& inRightULong)");
}
Example #17
0
	/*!
	 *  \brief Cast the actual wrapper type into the wrapped type.
	 *  \return A reference to the wrapped value.
	 */
	inline operator T() const {
		Beagle_StackTraceBeginM();
		return mWrappedValue;
		Beagle_StackTraceEndM();
	}
 /*!
  *  \brief Return a constant reference to the positive operator set.
  *  \return Positive operator set constant reference.
  */
 inline const Operator::Bag& getPositiveSet() const
 {
     Beagle_StackTraceBeginM();
     return mPositiveOpSet;
     Beagle_StackTraceEndM("const Operator::Bag& IfThenElseOp::getPositiveSet() const");
 }
Example #19
0
	/*!
	 *  \brief Set the wrapped type value.
	 *  \param inNewValue Set the wrapped value.
	 */
	inline void setWrappedValue(const T& inNewValue) {
		Beagle_StackTraceBeginM();
		mWrappedValue = inNewValue;
		Beagle_StackTraceEndM();
	}
 /*!
  *  \brief Return a reference to the negative operator set.
  *  \return Negative operator set reference.
  */
 inline Operator::Bag& getNegativeSet()
 {
     Beagle_StackTraceBeginM();
     return mNegativeOpSet;
     Beagle_StackTraceEndM("Operator::Bag& IfThenElseOp::getNegativeSet()");
 }
Example #21
0
 /*!
  *  \brief Invalidate the fitness.
  */
 inline void setInvalid() {
     Beagle_StackTraceBeginM();
     mValid = false;
     Beagle_StackTraceEndM();
 }
 /*!
  *  \brief Insert an operator in the positive set of the if-then-else operator.
  *  \param inOperator Operator to insert.
  *  \warning Insert your operators before the initialization!
  */
 inline void insertPositiveOp(Operator::Handle inOperator)
 {
     Beagle_StackTraceBeginM();
     mPositiveOpSet.push_back(inOperator);
     Beagle_StackTraceEndM("void insertPositiveOp(Operator::Handle)");
 }
/*!
 *  \brief Mate two indice integer vector GA individuals for partialy matched crossover.
 *  \param ioIndiv1   First individual to mate.
 *  \param ioContext1 Evolutionary context of the first individual.
 *  \param ioIndiv2   Second individual to mate.
 *  \param ioContext2 Evolutionary context of the second individual.
 *  \return True if the individuals are effectively mated, false if not.
 */
bool Beagle::GA::CrossoverPMXOp::mate(Beagle::Individual& ioIndiv1,
									  Beagle::Context&    ioContext1,
									  Beagle::Individual& ioIndiv2,
									  Beagle::Context&    ioContext2)
{
	Beagle_StackTraceBeginM();
	unsigned int lNbGenotypes = minOf<unsigned int>(ioIndiv1.size(), ioIndiv2.size());
	if(lNbGenotypes == 0) return false;
	
	Beagle_LogDebugM(
					 ioContext1.getSystem().getLogger(),
					 "crossover", "Beagle::GA::CrossoverPMXOp",
					 "Individuals mated (before GA partily matched crossover)"
					 );
	Beagle_LogObjectDebugM(
						   ioContext1.getSystem().getLogger(),
						   "crossover", "Beagle::GA::CrossoverPMXOp",
						   ioIndiv1
						   );
	Beagle_LogObjectDebugM(
						   ioContext1.getSystem().getLogger(),
						   "crossover", "Beagle::GA::CrossoverPMXOp",
						   ioIndiv2
						   );
	
	for(unsigned int i=0; i<lNbGenotypes; ++i) {
		GA::IntegerVector::Handle lIndividual1 = castHandleT<IntegerVector>(ioIndiv1[i]);
		GA::IntegerVector::Handle lIndividual2 = castHandleT<IntegerVector>(ioIndiv2[i]);
		
		std::deque<int> lIndividual1Copy(lIndividual1->begin(), lIndividual1->end());
		std::deque<int> lIndividual2Copy(lIndividual2->begin(), lIndividual2->end());
		
		unsigned int lSize = minOf<unsigned int>(lIndividual1->size(), lIndividual2->size());
		unsigned int a = ioContext1.getSystem().getRandomizer().rollInteger(0, lSize-1);
		unsigned int b = ioContext1.getSystem().getRandomizer().rollInteger(0, lSize-1);
		
		if(a > b){std::swap(a, b);}
		for(unsigned int j = a; j <= b; ++j){
			for(unsigned int k = 0; k < lSize; ++k){
				if((*lIndividual1)[k] == lIndividual1Copy[j])
					(*lIndividual1)[k] = lIndividual2Copy[j];
				else if((*lIndividual1)[k] == lIndividual2Copy[j])
					(*lIndividual1)[k] = lIndividual1Copy[j];
				
				if((*lIndividual2)[k] == lIndividual1Copy[j])
					(*lIndividual2)[k] = lIndividual2Copy[j];
				else if((*lIndividual2)[k] == lIndividual2Copy[j])
					(*lIndividual2)[k] = lIndividual1Copy[j];
			}
		}
	}
	
	Beagle_LogDebugM(
					 ioContext1.getSystem().getLogger(),
					 "crossover", "Beagle::GA::CrossoverPMXOp",
					 "Individuals mated (after GA partialy matched crossover)"
					 );
	Beagle_LogObjectDebugM(
						   ioContext1.getSystem().getLogger(),
						   "crossover",
						   "Beagle::GA::CrossoverPMXOp",
						   ioIndiv1
						   );
	Beagle_LogObjectDebugM(
						   ioContext1.getSystem().getLogger(),
						   "crossover",
						   "Beagle::GA::CrossoverPMXOp",
						   ioIndiv2
						   );
	
	return true;
	Beagle_StackTraceEndM("bool GA::CrossoverPMXOp::mate(Individual& ioIndiv1, Context& ioContext1, Individual& ioIndiv2, Context& ioContext2)");
}
 /*!
  *  \brief Set parameter tag of condition to use.
  */
 inline void setConditionTag(std::string inTag)
 {
     Beagle_StackTraceBeginM();
     mConditionTag = inTag;
     Beagle_StackTraceEndM("void IfThenElseOp::setConditionTag(std::string inTag)");
 }
Example #25
0
	/*!
	 *  \brief Return a reference to the negative operator set.
	 *  \return Negative operator set reference.
	 */
	inline Beagle::Operator::Bag& getNegativeSet() {
		Beagle_StackTraceBeginM();
		return mNegativeOpSet;
		Beagle_StackTraceEndM();
	}
 /*!
  *  \brief Set parameter value of condition to use.
  */
 inline void setConditionValue(std::string inValue)
 {
     Beagle_StackTraceBeginM();
     mConditionValue = inValue;
     Beagle_StackTraceEndM("void IfThenElseOp::setConditionValue(std::string inValue)");
 }
Example #27
0
	/*!
	 *  \brief Set parameter tag of condition to use.
	 */
	inline void setConditionTag(std::string inTag) {
		Beagle_StackTraceBeginM();
		mConditionTag = inTag;
		Beagle_StackTraceEndM();
	}
 /*!
  *  \return Condition value tested for positive condition in if-then-else operator.
  */
 inline std::string getConditionValue() const
 {
     Beagle_StackTraceBeginM();
     return mConditionValue;
     Beagle_StackTraceEndM("std::string IfThenElseOp::getConditionValue() const");
 }
Example #29
0
	/*!
	 *  \return Condition value tested for positive condition in if-then-else operator.
	 */
	inline std::string getConditionValue() const {
		Beagle_StackTraceBeginM();
		return mConditionValue;
		Beagle_StackTraceEndM();
	}
	//! Return a handle to the register.
	inline Register::Handle getRegisterHandle(void)
	{
		Beagle_StackTraceBeginM();
		return mRegister;
		Beagle_StackTraceEndM("Register::Handle System::getRegisterHandle(void)");
	}