📄 gfdlg.h
字号:
// GFDlg.h : header file
//
#if !defined(AFX_GFDLG_H__711210A6_1765_4296_AAA7_B6837679F86A__INCLUDED_)
#define AFX_GFDLG_H__711210A6_1765_4296_AAA7_B6837679F86A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////
///////////////////定义///////////////////////////////////
/* 全局变量 */
typedef struct{
char c;
int m_l;
float m_min;
float m_max;
int l;
}p_member;
struct individual /* 个体*/
{
unsigned *chrom; /* 染色体 */
double fitness; /* 个体适应度*/
double varible[7]; /* 个体对应的变量值*/
int xsite; /* 交叉位置 */
int parent[2]; /* 父个体 */
int *utility; /* 特定数据指针变量 */
};
struct bestever /* 最佳个体*/
{
unsigned *chrom; /* 最佳个体染色体*/
double fitness; /* 最佳个体适应度 */
double varible[7]; /* 最佳个体对应的变量值 */
int generation; /* 最佳个体生成代 */
};
/////////////////////////////////////////////////////////////////////////////
// CGFDlg dialog
class CGFDlg : public CDialog
{
////////////////////////////////////////参数定义/////////////////////
public:
struct individual *oldpop; /* 当前代种群 */
struct individual *newpop; /* 新一代种群 */
struct bestever bestfit; /* 最佳个体 */
struct bestever bestfit_min;
double sumfitness; /* 种群中个体适应度累计 */
double max; /* 种群中个体最大适应度 */
double avg; /* 种群中个体平均适应度 */
double min; /* 种群中个体最小适应度 */
float pcross; /* 交叉概率 */
float pmutation; /* 变异概率 */
int popsize; /* 种群大小 */
int lchrom; /* 染色体长度*/
int chromsize; /* 存储一染色体所需字节数 */
int gen; /* 当前世代数 */
int maxgen; /* 最大世代数 */
int run; /* 当前运行次数 */
int maxruns; /* 总运行次数 */
int printstrings; /* 输出染色体编码的判断,0 -- 不输出, 1 -- 输出 */
int nmutation; /* 当前代变异发生次数 */
int ncross; /* 当前代交叉发生次数 */
int lchrom_x,lchrom_y,lchrom_z;
float save_x,save_x_sum;
float save_y,save_y_sum;
float save_z,save_z_sum;
CString m_function_s;
p_member chanshu[7];
/* 随机数发生器使用的静态变量 */
double oldrand[55];
int jrand;
double rndx2;
int rndcalcflag;
public:
/* 函数定义 */
void advance_random();
int flip(float);rnd(int, int);
void randomize();
double randomnormaldeviate();
float randomperc(),rndreal(float,float);
void warmup_random(float);
void initialize(),initdata(),initpop();
void initreport(),generation(),initmalloc();
void freeall(),nomemory(char *);
void writepop();
CString writechrom(unsigned *);
void preselect();
void statistics(struct individual *);
void title(),repchar (FILE *,char *,int);
void skip(FILE *,int);
int select();
void objfunc(struct individual *);
int crossover (unsigned *, unsigned *, unsigned *, unsigned *);
void mutation(unsigned *);
// Construction
public:
CGFDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CGFDlg)
enum { IDD = IDD_GF_DIALOG };
CButton m_help;
CListBox m_output3;
CListBox m_output4;
CComboBox m_change;
CEdit m_output1;
CListBox m_output2;
CString m_function;
float m_pc;
float m_pm;
int m_maxgen;
int m_popsize;
int m_l;
float m_min;
float m_max;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGFDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CGFDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnChange_function();
afx_msg void OnChange_pc();
afx_msg void OnChange_pm();
afx_msg void OnChange_maxgen();
afx_msg void OnChange_popsize();
afx_msg void OnChange_xmin();
afx_msg void OnChange_xmax();
afx_msg void OnChange_xl();
afx_msg void OnChange_ymin();
afx_msg void OnChange_ymax();
afx_msg void OnChange_yl();
afx_msg void OnChange_zmin();
afx_msg void OnChange_zmax();
afx_msg void OnChange_zl();
afx_msg void OnChange_output1();
afx_msg void OnSelchange_output2();
afx_msg void OnChange_xls();
afx_msg void OnChange_yls();
afx_msg void OnChange_zls();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnEditchangeCombo_chanshu();
afx_msg void OnChangeEdit_l();
afx_msg void OnChangeEdit_min();
afx_msg void OnChangeEdit_max();
afx_msg void OnSelchangeList_change();
afx_msg void OnSelchangeCombo_chanshu();
afx_msg void OnSelchangeList_mls();
afx_msg void OnButton_help();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GFDLG_H__711210A6_1765_4296_AAA7_B6837679F86A__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -