⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paramdlg.cpp

📁 用C编的遗传算法求函数极值
💻 CPP
字号:
// ParamDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SGA.h"
#include "ParamDlg.h"
#include "GA.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// ParamDlg dialog


ParamDlg::ParamDlg(CWnd* pParent /*=NULL*/)
	: CDialog(ParamDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(ParamDlg)
	m_nPopSize = 0;
	m_nMaxGen = 0;
	m_nChromLen = 0;
	m_fPc = 0.0f;
	m_fPm = 0.0f;
	//}}AFX_DATA_INIT
}


void ParamDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ParamDlg)
	DDX_Text(pDX, IDC_POPSIZE, m_nPopSize);
	DDV_MinMaxUInt(pDX, m_nPopSize, 2, 200);
	DDX_Text(pDX, IDC_MAXGEN, m_nMaxGen);
	DDV_MinMaxUInt(pDX, m_nMaxGen, 1, 65535);
	DDX_Text(pDX, IDC_CHROMLEN, m_nChromLen);
	DDV_MinMaxUInt(pDX, m_nChromLen, 2, 63);
	DDX_Text(pDX, IDC_PCROSS, m_fPc);
	DDV_MinMaxFloat(pDX, m_fPc, 0.f, 1.f);
	DDX_Text(pDX, IDC_PMUTATION, m_fPm);
	DDV_MinMaxFloat(pDX, m_fPm, 0.f, 1.f);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ParamDlg, CDialog)
	//{{AFX_MSG_MAP(ParamDlg)
	ON_BN_CLICKED(IDRESET, OnReset)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ParamDlg message handlers

BOOL ParamDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_nPopSize=50;
	m_nChromLen=22;
	m_nMaxGen=100;
	m_fPc=0.25;
	m_fPm=0.01f;
	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void ParamDlg::OnOK() 
{
	// TODO: Add extra validation here
	CDialog::OnOK();
}

void ParamDlg::OnReset() 
{
	// TODO: Add your control notification handler code here
	m_nPopSize=DEFPOPSIZ;
	m_nChromLen=DEFCHRLEN;
	m_nMaxGen=DEFMAXGEN;
	m_fPc=DEFPC;
	m_fPm=DEFPM;
	UpdateData(FALSE);	
}

void ParamDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -