59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
//-------------------------------------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TGAPopulation 类
|
|
// = Version : ver2.0
|
|
// = Author : wlw
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: TGAPopulation 声明
|
|
// = Maintainers:
|
|
//
|
|
//-------------------------------------------------------------------------------------------------------+
|
|
#ifndef _TGAPOPULATION_H_
|
|
#define _TGAPOPULATION_H_
|
|
|
|
#ifndef _TPDLIST_H_
|
|
#include "TPDList.h"
|
|
#endif
|
|
|
|
#ifndef _TGAINDIVIDUAL_H_
|
|
#include "TGAIndividual.h"
|
|
#endif
|
|
|
|
class GEOAPI TGAPopulation : public TPDList<TGAIndividual>
|
|
{
|
|
public:
|
|
TGAPopulation();
|
|
|
|
virtual ~TGAPopulation();
|
|
|
|
virtual bool IsContinue();
|
|
|
|
virtual void Step();
|
|
|
|
//种群进化单元,后代仍然有序
|
|
virtual void Evolve();
|
|
|
|
void SetMaxNum(long num);
|
|
|
|
long GetMaxNum() const;
|
|
|
|
void SetMutationRatio(long r);
|
|
|
|
long GetMutationRatio();
|
|
|
|
//增加新个体,排序,果总数超限,淘汰最后一个。
|
|
void Append(TGAIndividual* pNew);
|
|
|
|
protected:
|
|
//允许最大数量
|
|
long m_iMaxNum;
|
|
|
|
//变异百分比
|
|
long m_iMutationRatio;
|
|
|
|
//进化计数
|
|
long m_iEvolution;
|
|
|
|
};
|
|
|
|
#endif |