📄 mutateoperator.cpp
字号:
// MutateOperator.cpp: implementation of the MutateOperator class.
//
//////////////////////////////////////////////////////////////////////
#include <stdafx.h> // Added 980901 by Aleksander 踙rn.
#include "../copyright.h" // Added 000323 by Aleksander 豩rn.
#include "MutateOperator.h"
#include "EABitset.h"
#include "Rand.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MutateOperator::MutateOperator(int rounds) :times(rounds)
{
}
MutateOperator::~MutateOperator()
{
}
bool MutateOperator::apply(Individual & in, Individual & out)
{
EABitset * i = (EABitset *)∈
EABitset * o = (EABitset *)&out;
*o = *i;
if(i->size() <= 0)
return false;
for(int ii = 0; ii < times; ii++){
int point = Rand::i() % i->size();
o->setP(point, o->getP(point) ? false : true);
}
o->reeval = true;
o->age = 0; // newborn
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -