📄 histstop.cpp
字号:
// HistStop.cpp: implementation of the HistStop class.
//
//////////////////////////////////////////////////////////////////////
#include <stdafx.h> // Added 980901 by Aleksander 踙rn.
#include "../copyright.h" // Added 000323 by Aleksander 豩rn.
#include "HistStop.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
HistStop::HistStop(Context &cont, int gap, bool fStop, bool kStop)
: c(cont), gen_gap(gap), use_fs(fStop), use_ks(kStop), max_fitness(0.0),
f_generation(0), k_generation(0), fit_stop(false), keep_stop(false)
{
}
HistStop::~HistStop()
{
}
bool HistStop::stop(Population & p, int generation)
{
if(p.size() == 0)
return true;
if(use_fs){
if(p.avg_fitness > max_fitness){
max_fitness = p.avg_fitness;
f_generation = generation;
fit_stop = false;
}
if(generation - f_generation > gen_gap){
fit_stop = true;
}
}
if(use_ks){
if(c.keep_changed){ // check if the keep list has changed...
k_generation = generation;
keep_stop = false;
}
// reset context's check for next run
c.keep_changed = false;
if(generation - k_generation > gen_gap){
keep_stop = true;
}
}
return keep_stop && fit_stop;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -