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

📄 couplingoperations.h

📁 遗传算法做图像的模式匹配
💻 H
📖 第 1 页 / 共 2 页
字号:
			///
			/// This method is thread-safe.</summary>
			/// <returns>Method returns new instance of <see cref="GaMulitpleCrossoverCouplingParams" /> class.</returns>
			virtual GaParameters* GACALL MakeParameters() const { return new GaMulitpleCrossoverCouplingParams(); }

			/// <summary>Valid parameters must have number of offspring for production and number of produced children per parent pair grater then 0.
			///
			/// More details are given in specification of <see cref="GaOperation::CheckParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			virtual bool GACALL CheckParameters(const GaParameters& parameters) const
			{
				return ( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetNumberOfOffsprings() > 0 &&
					( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetOffspringsPerParentPair() > 0;
			}

		};// END CLASS DEFINITION GaCrossCoupling

		/// <summary><c>GaInverseCoupling</c> coupling takes first parents sequentially from selection results, and second parents are the ones who are at
		/// the distance from the last chromosome in selection results which is equal to distance of first parent form first chromosome in result set.
		/// If all parents are used, but more children should be produced, this coupling operation wraps-around parent counter and starts from beginning
		/// until enough children is produced. When two parents are chosen this operation produces specified number of children using crossover operation and
		/// then it chooses child with best fitness value among produced children and first parent is bound to it.
		/// This coupling use <see cref="GaMultipleCrossoverCouplingParams" /> class for parameters. 
		///
		/// <img src="graphic/i_cp.png"></img>
		///
		/// This class has no built-in synchronizator, so <c>LOCK_OBJECT</c> and <c>LOCK_THIS_OBJECT</c> macros cannot be used with instances of this class.
		/// Because this genetic operation is stateless all public method are thread-safe.</summary>
		class GaInverseCoupling : public GaCouplingOperation
		{

		public:

			/// <summary>More details are given in specification of <see cref="GaCouplingOperation::operator ()" /> method.
			///
			/// This method is thread-safe.</summary>
			GAL_API
			virtual void GACALL operator ()(const GaPopulation& population,
				GaCouplingResultSet& output,
				const GaCouplingParams& parameters,
				int workerId,
				int numberOfWorkers) const;

			/// <summary>More details are given in specification of <see cref="GaOperation::MakeParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			/// <returns>Method returns new instance of <see cref="GaMulitpleCrossoverCouplingParams" /> class.</returns>
			virtual GaParameters* GACALL MakeParameters() const { return new GaMulitpleCrossoverCouplingParams(); }

			/// <summary>Valid parameters must have number of offspring for production and number of produced children per parent pair grater then 0.
			///
			/// More details are given in specification of <see cref="GaOperation::CheckParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			virtual bool GACALL CheckParameters(const GaParameters& parameters) const
			{
				return ( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetNumberOfOffsprings() > 0 &&
					( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetOffspringsPerParentPair() > 0;
			}

		};// END CLASS DEFINITION GaInverseCoupling

		/// <summary><c>GaRandomCoupling</c> coupling takes first parents sequentially from selection result set, and second parents are chosen randomly.
		/// If all parents are used as firs parent, but more children should be produced, this coupling operation wraps-around parent counter for the first parent
		/// and starts from beginning until enough children is produced. When two parents are chosen this operation produces specified number of children
		/// using crossover operation and then it chooses child with best fitness value among produced children and first parent is bound to it.
		/// This coupling use <see cref="GaMultipleCrossoverCouplingParams" /> class for parameters.
		///
		/// <img src="graphic/r_cp.png"></img>
		///
		/// This class has no built-in synchronizator, so <c>LOCK_OBJECT</c> and <c>LOCK_THIS_OBJECT</c> macros cannot be used with instances of this class.
		/// Because this genetic operation is stateless all public method are thread-safe.</summary>
		class GaRandomCoupling : public GaCouplingOperation
		{

		public:

			/// <summary>More details are given in specification of <see cref="GaCouplingOperation::operator ()" /> method.
			///
			/// This method is thread-safe.</summary>
			GAL_API
			virtual void GACALL operator ()(const GaPopulation& population,
				GaCouplingResultSet& output,
				const GaCouplingParams& parameters,
				int workerId,
				int numberOfWorkers) const;

			/// <summary>More details are given in specification of <see cref="GaOperation::MakeParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			/// <returns>Method returns new instance of <see cref="GaMulitpleCrossoverCouplingParams" /> class.</returns>
			virtual GaParameters* GACALL MakeParameters() const { return new GaMulitpleCrossoverCouplingParams(); }

			/// <summary>Valid parameters must have number of offspring for production and number of produced children per parent pair grater then 0.
			///
			/// More details are given in specification of <see cref="GaOperation::CheckParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			virtual bool GACALL CheckParameters(const GaParameters& parameters) const
			{
				return ( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetNumberOfOffsprings() > 0 &&
					( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetOffspringsPerParentPair() > 0;
			}

		};// END CLASS DEFINITION GaRandomCoupling

		/// <summary><c>GaBestAlwaysCoupling</c> coupling always takes chromosome with the best fitness value from selection result set, and the second parents
		/// are sequentially taken from. If all parents are used, but more children should be produced, this coupling operation wraps-around parent counter
		/// for second the parents and starts from beginning until enough children is produced. When two parents are chosen this operation produces
		/// specified number of children using crossover operation and then it chooses child with best fitness value among produced children and the second parent
		/// is bound to it. This coupling use <see cref="GaMultipleCrossoverCouplingParams" /> class for parameters.
		///
		/// <img src="graphic/ab_cp.png"></img>
		///
		/// This class has no built-in synchronizator, so <c>LOCK_OBJECT</c> and <c>LOCK_THIS_OBJECT</c> macros cannot be used with instances of this class.
		/// Because this genetic operation is stateless all public method are thread-safe.</summary>
		class GaBestAlwaysCoupling : public GaCouplingOperation
		{

		public:

			/// <summary>More details are given in specification of <see cref="GaCouplingOperation::operator ()" /> method.
			///
			/// This method is thread-safe.</summary>
			GAL_API
			virtual void GACALL operator ()(const GaPopulation& population,
				GaCouplingResultSet& output,
				const GaCouplingParams& parameters,
				int workerId,
				int numberOfWorkers) const;

			/// <summary>More details are given in specification of <see cref="GaOperation::MakeParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			/// <returns>Method returns new instance of <see cref="GaMulitpleCrossoverCouplingParams" /> class.</returns>
			virtual GaParameters* GACALL MakeParameters() const { return new GaMulitpleCrossoverCouplingParams(); }

			/// <summary>Valid parameters must have number of offspring for production and number of produced children per parent pair grater then 0.
			///
			/// More details are given in specification of <see cref="GaOperation::CheckParameters" /> method.
			///
			/// This method is thread-safe.</summary>
			virtual bool GACALL CheckParameters(const GaParameters& parameters) const
			{
				return ( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetNumberOfOffsprings() > 0 &&
					( (const GaMulitpleCrossoverCouplingParams& ) parameters ).GetOffspringsPerParentPair() > 0;
			}
		};

	} // CouplingOperations
} // Population

#endif // __GA_COUPLING_OPERATION_H__

⌨️ 快捷键说明

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