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