-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunThread.cpp
More file actions
147 lines (116 loc) · 3.61 KB
/
Copy pathRunThread.cpp
File metadata and controls
147 lines (116 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// RunThread.cpp : implementation file
//
#include "stdafx.h"
#include "SOM_Cluster.h"
#include "RunThread.h"
#include "DotMatrix.h"
#include "Son.h"
#define PATTERN 1000
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRunThread
IMPLEMENT_DYNCREATE(CRunThread, CWinThread)
CRunThread::CRunThread()
{
}
CRunThread::~CRunThread()
{
}
BOOL CRunThread::InitInstance()
{
// TODO: perform and per-thread initialization here
return TRUE;
}
int CRunThread::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(CRunThread, CWinThread)
//{{AFX_MSG_MAP(CRunThread)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRunThread message handlers
void CRunThread::SetOwner(CSOM_ClusterDlg *pDlg)
{
m_pDlg = pDlg;
}
int CRunThread::Run()
{
CDotMatrix* m_DotMatrix = (CDotMatrix*)m_pDlg->m_LearnDotMatrix;
CString Str;
long iteration;
double initial_learning_rate, final_learning_rate;
int initial_neigh_size;
int neighborhood_decrement_interval;
long num_iterations;
int display_interval;
int frame_rate;
int input_nodes, output_nodes, x_size, y_size;
int class_num;
if(m_pDlg->m_Mode == FALSE)
{
// m_pDlg->GetDlgItemText(IDC_EDIT_INPUT_FILE, Str);
// m_pDlg->GetDlgItemText(IDC_EDIT_NETWORK_FILE, Str);
// m_pDlg->GetDlgItemText(IDC_EDIT_OUTPUT_FILE, Str);
m_pDlg->GetDlgItemText(IDC_EDIT_START_LEARNING_RATE, Str);
initial_learning_rate = atof((LPTSTR)(LPCTSTR)Str);
m_pDlg->GetDlgItemText(IDC_EDIT_END_LEARNING_RATE, Str);
final_learning_rate = atof((LPTSTR)(LPCTSTR)Str);
input_nodes = m_pDlg->GetDlgItemInt(IDC_EDIT_INPUT_NODE);
output_nodes = m_pDlg->GetDlgItemInt(IDC_EDIT_OUTPUT_NODE);
x_size = m_pDlg->GetDlgItemInt(IDC_EDIT_LAYER_X);
y_size = m_pDlg->GetDlgItemInt(IDC_EDIT_LAYER_Y);
initial_neigh_size = m_pDlg->GetDlgItemInt(IDC_EDIT1_NEIGH);
neighborhood_decrement_interval = m_pDlg->GetDlgItemInt(IDC_EDIT1_DECREMENT_ITERATION);
num_iterations = m_pDlg->GetDlgItemInt(IDC_EDIT1_END_ITERATION);
display_interval = m_pDlg->GetDlgItemInt(IDC_EDIT1_VIEW_INTERVAL);
frame_rate = m_pDlg->GetDlgItemInt(IDC_EDIT1_SAVE_INTERVAL);
m_pDlg->GetDlgItemText(IDC_EDIT_NETWORK_FILE, Str);
SON_Network SONnet((LPTSTR)(LPCTSTR)Str);
input_nodes = SONnet.Get_Input_Count();
Pattern *input_data;
m_pDlg->GetDlgItemText(IDC_EDIT_INPUT_FILE, Str);
ifstream infile((LPTSTR)(LPCTSTR)Str);
ASSERT(infile);
while(!infile.eof() && !infile.fail())
{
input_data = new Pattern(input_nodes, output_nodes, infile);
SONnet.Set_Value(input_data);
SONnet.Run();
cout << input_data->Get_ID() << " ";
// for(int i = 0; i < input_nodes; i++)
// {
// cout << input_data->In(i) << " ";
// }
for(int i = 0; i < output_nodes; i++)
{
if(input_data->Out(0) == 1)
class_num = 1;
else if(input_data->Out(1) == 1)
class_num = 2;
else
class_num = 3;
}
// cout << " " << SONnet.Get_Value(COMPOSITE) << " "
// << SONnet.Get_Value(ROW) << " " << SONnet.Get_Value(COL) << endl;
m_DotMatrix->UpdateCircle(SONnet.Get_Value(ROW), SONnet.Get_Value(COL), class_num);
delete input_data;
}
infile.close();
}
else
{
AfxMessageBox("Train/Run Mode¿¡ FALSEÀÎÁö È®ÀÎÇØ ÁÖ¼¼¿ä");
}
m_pDlg->GetDlgItem(IDC_BUTTON_RUN)->EnableWindow(TRUE);
m_pDlg->GetDlgItem(IDC_CHECK_MODE)->EnableWindow(TRUE);
AfxEndThread(0);
return CWinThread::Run();
}