?? gachromosomeoperations.h
字號:
#ifndef __GA_CHROMOSOME_OPERATIONS_H__
#define __GA_CHROMOSOME_OPERATIONS_H__
#include "..\ExportImport.h"
#include "..\CallConvention.h"
#include "..\Common\GaCatalogue.h"
#include "..\Common\GaOperation.h"
#include "GaChromosome.h"
using namespace Common;
using namespace Chromosome;
namespace Chromosome
{
// Interface for dynamically changable crossover operations.
class GaCrossoverOperation : public GaOperation
{
public:
// Performs crossover operation and make new child from two given parents.
DLL_EXPORT
GaChromosomePtr GACALL operator ()(GaChromosomePtr parent1,
GaChromosomePtr parent2) const;
// Performs crossover operation and make new child from two given parents.
virtual GaChromosomePtr GACALL operator ()(const GaChromosome* parent1,
const GaChromosome* parent2) const=0;
};// END CLASS DEFINITION GaCrossoverOperation
// Catalogue of crossover operations
typedef GaCatalogue<GaCrossoverOperation> GaCrossoverCatalogue;
// Interface for dynamically changable mutation operations.
class GaMutationOperation : public GaOperation
{
public:
// Performs mutation operation on given chromosome.
DLL_EXPORT
void GACALL operator ()(GaChromosomePtr chromosome) const;
// Performs mutation operation on given chromosome.
virtual void GACALL operator ()(GaChromosome* chromosome) const=0;
};// END CLASS DEFINITION GaMutationOperation
// Catalogue of mutation operations
typedef GaCatalogue<GaMutationOperation> GaMutationCatalogue;
// Interface for dynamically changable fitness value calculation operations.
class GaFitnessOperation : public GaOperation
{
public:
// Calculates fitness value of the given chromosome.
DLL_EXPORT
float GACALL operator ()(GaChromosomePtr chromosome) const;
// Calculates fitness value of the given chromosome.
virtual float GACALL operator ()(const GaChromosome* chromosome) const=0;
};// END CLASS DEFINITION GaFitnessOperation
// Compares two fitness values
class GaFitnessComparator : public GaOperation
{
public:
// Compares two fitness values and returns:
// a, -1 if the first fitness value lower then the second
// b. 0 if the fitness values are equal
// c. 1 if the first fitness value is greater then the second
virtual int GACALL operator ()(float fitness1,
float fitness2) const=0;
// Allocates memory and makes instance of parameters.
// Caller is responsible for allocated memory.
DLL_EXPORT
virtual GaParameters* GACALL MakeParameters() const;
// Check passed parameters. Returns TRUE if everything correct.
DLL_EXPORT
virtual bool GACALL CheckParameters(const GaParameters& parameters) const;
};// END CLASS DEFINITION GaFitnessComparator
// Catalogue of fitness comparators
typedef GaCatalogue<GaFitnessComparator> GaFitnessComparatorCatalogue;
} // Chromosome
#endif // __GA_CHROMOSOME_OPERATIONS_H__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -