📄 gavaluesets.h
字号:
#ifndef __GA_VALUE_SETS_H__
#define __GA_VALUE_SETS_H__
#include <vector>
#include "..\..\CallConvention.h"
#include "..\..\Common\GaGlobalRandomGenerator.h"
#include "..\..\Threading\GaThreading.h"
using namespace std;
namespace Chromosome
{
namespace Representation
{
// Interface for value sets
template <typename T>
class GaValueSet
{
DEFINE_SYNC_CLASS
protected:
// Indicates that when inverted value is inverted the new value is original value
bool _viceVersa;
public:
// Initialize set
GaValueSet(bool viceVersa) : _viceVersa(viceVersa) { }
// Initialize set
GaValueSet() : _viceVersa(true) { }
// Virtual destructor
virtual ~GaValueSet() { }
// Returns random value from set
virtual T GACALL GenerateRandom() const=0;
// Returns TRUE if given value belongs to set and saves inverted value
virtual bool GACALL Inverse(const T& value,
T& inverted) const=0;
// Returns TRUE if given value belongs to set
virtual bool GACALL Belongs(const T& value) const=0;
// Returns colosest value to given value
virtual const T& GACALL ClosestValue(const T& value) const=0;
// Returns TRUE if inversing the inverted value returns original value, otherwise return FALSE.
bool GACALL GetViceVersa() const
{
return _viceVersa;
}
// Sets to TRUE if inversing the inverted value returns original value.
void GACALL SetViceVersa(bool viceVersa)
{
_viceVersa = viceVersa;
}
};// END CLASS DEFINITION GaValueSet
} // Representation
} // Chromosome
#endif // __GA_VALUE_SETS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -