gaincrementalalgorithm.h

来自「遗传算法做的排课系统」· C头文件 代码 · 共 92 行

H
92
字号

#ifndef __GA_INCREMENTAL_ALGORITHM_H__
#define __GA_INCREMENTAL_ALGORITHM_H__

#include <vector>
#include "..\..\ExportImport.h"
#include "..\..\CallConvention.h"
#include "..\..\Threading\GaThreading.h"
#include "..\GaMultithreadingAlgorithm.h"

namespace Population
{
	class GaPopulation;
}

using namespace std;
using namespace Threading;
using namespace Population;
using namespace Algorithm;

namespace Algorithm
{
	namespace SimpleAlgorithms
	{

		// Use overlapping population, only few chromosomes are repaced in single generation
		class GaIncrementalAlgorithm : public GaMultithreadingAlgorithm
		{

		private:

			// Algorithm's parameters
			GaMultithreadingAlgorithmParams _parameters;

			// Population
			GaPopulation* _population;

			// Buffer for selection and coupling operations
			GaCouplingResultSet* _buffer;

		public:

			// Initialize algorithm
			DLL_EXPORT
			GaIncrementalAlgorithm(GaPopulation* population,
				const GaMultithreadingAlgorithmParams& parameters);

			// Free resources
			DLL_EXPORT
			virtual ~GaIncrementalAlgorithm();

			// Returns current algorithm parameters
			DLL_EXPORT
			virtual const GaAlgorithmParams& GACALL GetAlgorithmParameters() const;

			// Sets new parameters for algorithm
			DLL_EXPORT
			virtual void GACALL SetAlgorithmParameters(const GaAlgorithmParams& parameters);

			// Returns referenct to population at given index.
			DLL_EXPORT
			virtual const GaPopulation& GACALL GetPopulation(int index) const;

			// Retruns statistical information about execution of the algorithm.
			DLL_EXPORT
			virtual const GaStatistics& GACALL GetAlgorithmStatistics() const;

		protected:

			// Initialize the algorithm
			DLL_EXPORT
			virtual void GACALL Initialize();

			// Step of control flow before workers start
			DLL_EXPORT
			virtual void GACALL BeforeWorkers();

			// One step of work flow
			DLL_EXPORT
			virtual void GACALL WorkStep(int workerId);

			// Step of control flow after workers finish
			DLL_EXPORT
			virtual void GACALL AfterWorkers();

		};// END CLASS DEFINITION GaIncrementalAlgorithm

	} // SimpleAlgorithms
} // Algorithm

#endif // __GA_INCREMENTAL_ALGORITHM_H__

⌨️ 快捷键说明

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