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

📄 garepresentationinterfaces.h

📁 遗传算法做的排课系统
💻 H
字号:

#ifndef __GA_REPRESENTATION_INTERFACES_H__
#define __GA_REPRESENTATION_INTERFACES_H__

#include <vector>
#include "..\GaChromosome.h"
#include "..\..\CallConvention.h"
#include "GaCodeValuesBuffer.h"
#include "GaValueSets.h"

using namespace std;
using namespace Chromosome;
using namespace Chromosome::Representation;

namespace Chromosome
{
	namespace Representation
	{

		// Interface for elements (or parts) of chromosome's code
		class GaCodeValue
		{

		public:

			// Initialize data
			virtual void GACALL Initialize()=0;

			// Gets value from buffer
			virtual void GACALL FromBuffer(const GaCodeValuesBuffer& buffer,
				int pos)=0;

		};// END INTERFACE DEFINITION GaCodeValue

		// Interface for chromosome's representations which parts of the code can be randomly muteted or inverted.
		class GaMutableCode
		{

		public:

			// Randomly change the values of selected part of chromosome's code
			virtual void GACALL Flip(int start,
				int size)=0;

			// Inverts data in selected part of chromosome's code
			virtual void GACALL Invert(int start,
				int size)=0;

		};// END INTERFACE DEFINITION GaMutableCode

		// Interface for chromosome's representations which part of the code can be swapped
		class GaSwapableCode
		{

		public:

			// Swap parts of chromosome's code
			virtual void GACALL Swap(int start1,
				int size1,
				int start2,
				int size2)=0;

		};// END INTERFACE DEFINITION GaSwapableCode

		// Interface for chromosome's representations which code can be varible length.
		class GaSizableCode
		{

		public:

			// Removes part of chromosome's code
			virtual void GACALL Remove(int start,
				int size)=0;

			// Inserts information int chromosome's code
			virtual void GACALL Insert(int start,
				GaCodeValue* data,
				int size)=0;

		};// END INTERFACE DEFINITION GaSizableCode

		// Interface for chromosomes which codes are representet with multiple values
		class GaMultiValueCode
		{

		public:

			// Makes new buffer for manupulatin parts of chromosome's code
			virtual GaCodeValuesBuffer* GACALL MakeBuffer(int size) const=0;

			// Fills buffer with part of chromosome's code
			virtual void GACALL FillBuffer(int pos,
				int size,
				GaCodeValuesBuffer& buffer) const=0;

			// Makes chromosome's code from buffer of values
			virtual void GACALL FromBuffer(const GaCodeValuesBuffer& buffer)=0;

		};// END INTERFACE DEFINITION GaMultiValueCode

		// Interface for chromosomes having code which can be used by arithmetical operations
		class GaArithmeticalCode
		{

		public:

			// Returns new chromosome with code whic is made by adding values in two givne chromosomes' codes
			virtual GaChromosomePtr GACALL operator +(const GaArithmeticalCode& rhs) const=0;

			// Returns new chromosome with code whic is made by substracting values in two givne chromosomes' codes
			virtual GaChromosomePtr GACALL operator -(const GaArithmeticalCode& rhs) const=0;

			// Returns new chromosome with code whic is made by multiplying values in two givne chromosomes' codes
			virtual GaChromosomePtr GACALL operator *(const GaArithmeticalCode& rhs) const=0;

			// Returns new chromosome with code whic is made by dividing values in two givne chromosomes' codes
			virtual GaChromosomePtr GACALL operator /(const GaArithmeticalCode& rhs) const=0;

			// Returns new chromosome with code whic is midpoint between two givne chromosomes
			virtual GaChromosomePtr GACALL Midpoint(const GaArithmeticalCode& c) const=0;

		};// END INTERFACE DEFINITION GaArithmeticalCode

	} // Representation
} // Chromosome

#endif // __GA_REPRESENTATION_INTERFACES_H__

⌨️ 快捷键说明

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