?? genericalgorithm.h
字號:
//GennericAlgorithm.h
//
#pragma once
// const
const double DOUBLE_MAX = 999999999999;
const double DOUBLE_MIN = -DOUBLE_MAX;
const size_t MAXGENERATION = 100000;
const size_t MAXUNCHANGE = 1000; // 當最優值持續MAXUNCHANGE代不發生變化,停止
const double MINDIFF = 0.0001; // 所能分辨的適應值函數的最小差值
const size_t POPULATION = 50; // 樣本的大小
const size_t SAMPLELENGTH = 22; // 每一個樣本的長度
// for x belong to [-1, 2]
const double LOWBOUNARY = -1;
const double ZOOMSCALE = 3;
typedef char MyBit;
typedef MyBit BinBits[SAMPLELENGTH];
// action to do in next step
enum Action{STAY, MUTATE , CROSSOVER, DONE};
class MySample
{
private:
// initialize samples
void Init();
BinBits _bits; // binary string
double _fitvalue;
double _prop; // probability to stay
Action _action; // what to do in next step
public:
MySample()
{
Init();
};
MySample(const MySample& rhs);
MySample& operator = (const MySample& rhs);
double Fitness();
// get probability to STAY
// double Probability() const;
inline Action NextAction() const
{
return _action;
}
// calulate probability of current sample
void CalcuPro(double sumfit);
void CrossOver(MySample& rhs);
void Mutate();
};
// Binary string parse
double BinaryParse(const BinBits& bits);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -