📄 gadlg.h
字号:
// GADlg.h : header file
//
#if !defined(AFX_GADLG_H__CF3A2AB0_6B5E_4460_A131_39259A4213A9__INCLUDED_)
#define AFX_GADLG_H__CF3A2AB0_6B5E_4460_A131_39259A4213A9__INCLUDED_
#include "Genetic.h" // Added by ClassView
#include "vector"
#include "TaskListView.h"
#include "AgentListView.h"
#include "map"
#include "ResultView.h"
#include "engine.h"
using std::vector;
using std::map;
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CGADlg dialog
struct Param {
int popSize;
float pMutation;
float pCross;
int genTimes;
int retryTimes;
Param(){}
Param(int popsz, float pm, float pc, int gt, int rt)
{
init(popsz, pm, pc, gt, rt);
}
init(int popsz, float pm, float pc, int gt, int rt)
{
popSize = popsz;
pMutation = pm;
pCross = pc;
genTimes = gt;
retryTimes = rt;
}
};
struct Result
{
individual elitist;
};
typedef struct Result_Set
{
int cs_flag[MAX_NUM];
Result *res;
int bestIndex;
float useTime;
int genTimes;
Result_Set(){}
Result_Set(int gen){
init(gen);
}
void init(int gen)
{
genTimes = gen;
res = new Result[gen];
useTime = 0.0f;
bestIndex = -1;
}
~Result_Set()
{
delete [] res;
}
} Result_Set;
struct TestResult_Set
{
Result_Set *res_set;
int bestIndex;
int testNumber;
float totalUseTime;
TestResult_Set(){}
init(int testNum, int gen)
{
testNumber = testNum;
res_set = new Result_Set[testNum];
for (int i=0; i<testNum; i++)
{
res_set[i].init(gen);
}
bestIndex = -1;
totalUseTime = 0.0f;
}
TestResult_Set(int testNum, int gen){
init(testNum, gen);
}
~TestResult_Set()
{
delete [] res_set;
}
};
class CGADlg : public CDialog
{
public:
vector<CTasks *> m_tasksSet; //任务列表集合
vector<CTasks *>:: iterator m_iterTS;
vector<CAgents *> m_agentsSet; //agent列表集合
vector<CAgents *>:: iterator m_iterAS;
vector<Param *> m_pramSet; //遗传算法相关参数设置
vector<Param *>:: iterator m_iterPS;
int m_selectTS;
int m_selectAS;
int m_selectPS;
CTaskListView m_taskListView;
CAgentListView m_agentListView;
CListCtrl m_taskListCtrl;
CListCtrl m_agentListCtrl;
map<CString, int> m_mapTaskSet;
map<CString, int> m_mapAgentSet;
map<CString, int> m_mapParamSet;
CResultView m_ResultView;
TestResult_Set *m_testResSet;
engine * m_matlabEG;
char * m_rand_arr;
int * m_rand_cs_flag;
float m_rand_best_fitness;
int m_rand_start;
char * m_dfs_arr;
int * m_dfs_cs_flag;
float m_dfs_best_fitness;
int m_dfs_start;
CString m_strTitle ;
// Construction
public:
void viewResult();
void excute_DFS();
void excute_RA();
void excute_GA();
void update_param_view();
void init_param_set();
void update_agent_list_ctrl();
void update_task_list_ctrl();
void init_agents_set();
void init_tasks_set();
CGenetic *m_genetic;
CGADlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CGADlg)
enum { IDD = IDD_GA_DIALOG };
CComboBox m_comboParam;
CComboBox m_comboTask;
CComboBox m_comboAgent;
int m_abilityNum;
int m_agentNum;
int m_GenTimes;
int m_popSize;
int m_retryTimes;
int m_taskNum;
int m_radio1;
float m_crossP;
float m_mutationP;
int m_randTimes;
float m_timeDFS;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGADlg)
public:
virtual BOOL DestroyWindow();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void DFS_cpt(char *arr);
void DFS(int d, char *arr);
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CGADlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIco();
afx_msg void OnButtonExcute();
afx_msg void OnSelendokComboTask();
afx_msg void OnRadio1();
afx_msg void OnRadio2();
afx_msg void OnRadio3();
afx_msg void OnButtonTaskView();
afx_msg void OnButtonAgentView();
afx_msg void OnSelendokComboAgent();
afx_msg void OnSelendokCOMBOParamSet();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GADLG_H__CF3A2AB0_6B5E_4460_A131_39259A4213A9__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -