?? gafitnesscriteria.h
字號:
#ifndef __GA_FITNESS_CRITERIA_H__
#define __GA_FITNESS_CRITERIA_H__
#include "..\..\ExportImport.h"
#include "..\..\CallConvention.h"
#include "..\..\Common\GaStatistics.h"
#include "..\GaStopCriteria.h"
#include "GaFitnessCriteriaComparation.h"
using namespace Common;
using namespace Algorithm;
namespace Algorithm
{
namespace StopCriterias
{
// Parameters for fitness value stop criteria
class GaFitnessCriteriaParams : public GaStopCriteriaParams
{
private:
// Fitness value limit
float _fitnessLimit;
// Type of comparation between fitness value and limit
GaFitnessCriteriaComparation _comparation;
// Type of fitness values (best chromosome, avarge or worst chromosome) is used for comparation
GaStatValueType _valueType;
public:
// Initialization of the parameters
DLL_EXPORT
GaFitnessCriteriaParams(float fitnessLimit,
GaFitnessCriteriaComparation comparation,
GaStatValueType valueType);
// Initialization of the parameters with default values
DLL_EXPORT
GaFitnessCriteriaParams();
// Virtual copy constructor
DLL_EXPORT
virtual GaParameters* GACALL Clone() const;
// Returns fitness value limit
DLL_EXPORT
float GACALL GetFitnessLimit() const;
// Sets fitness value limit
DLL_EXPORT
void GACALL SetFitnessLimit(float limit);
// Returns type of comparation between fitness value and limit
DLL_EXPORT
GaFitnessCriteriaComparation GACALL GetComparation() const;
// Sets type of comparation between fitness value and limit
DLL_EXPORT
void GACALL SetComparation(GaFitnessCriteriaComparation comparation);
// Returns type of fitness values (best chromosome, avarge or worst chromosome) is used for comparation
DLL_EXPORT
GaStatValueType GACALL GetValueType() const;
// Sets type of fitness values (best chromosome, avarge or worst chromosome) is used for comparation
DLL_EXPORT
void GACALL SetValueType(GaStatValueType type);
};// END CLASS DEFINITION GaFitnessCriteriaParams
// Stop criteria based on fitness value of chromosome(s) in population(s)
class GaFitnessCriteria : public Algorithm::GaStopCriteria
{
public:
// Compares the state of the algorithm against given stopping condition and given paremeters,
// and returns TRUE if that condition is reached.
virtual bool GACALL Evaluate(const GaAlgorithm& algorithm,
const GaStopCriteriaParams& parameters) const;
// Allocates memory and makes instance of parameters.
// Caller is responsible for allocated memory.
virtual GaParameters* GACALL MakeParameters() const;
// Check passed parameters. Returns TRUE if everything correct.
virtual bool GACALL CheckParameters(const GaParameters& parameters) const;
};// END CLASS DEFINITION GaFitnessCriteria
} // StopCriterias
} // Algorithm
#endif // __GA_FITNESS_CRITERIA_H__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -