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

📄 recombineadd.cpp

📁 粗糙集应用软件
💻 CPP
字号:
// RecombineAdd.cpp: implementation of the RecombineAdd class.
//
//////////////////////////////////////////////////////////////////////

#include <stdafx.h> // Added 980901 by Aleksander 踙rn.
#include "../copyright.h" // Added 000323 by Aleksander 豩rn.

#include "RecombineAdd.h"
#include "RecombineReplaceParents.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

RecombineAdd::RecombineAdd(int max_pop_size) : limit(max_pop_size)
{

}

RecombineAdd::~RecombineAdd()
{

}

Population & RecombineAdd::apply(Population & p, int /*generation*/)
{
	if(p.offspring.size() == 0)
		return p;

	if(p.population.size() > limit){
		RecombineReplaceParents r;
		return r.apply(p);
	}

	for(unsigned int i = 0; i < p.offspring.size(); i++){
		if(p.offspring[i] != NULL)
			p.population.push_back(p.offspring[i]);
	}

	p.offspring.erase(p.offspring.begin(), p.offspring.end());
	p.parents.erase(p.parents.begin(), p.parents.end());
	p.parents_indices.erase(p.parents_indices.begin(), p.parents_indices.end());

	return p;
}

⌨️ 快捷键说明

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