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

📄 forecastdlg.h

📁 vc编程实现bp神经网络
💻 H
字号:
//{{AFX_INCLUDES()
#include "mschart.h"
//}}AFX_INCLUDES

#if !defined(AFX_FORECASTDLG_H__FE3AC8EB_C28F_47CC_822E_28682A64187D__INCLUDED_)
#define AFX_FORECASTDLG_H__FE3AC8EB_C28F_47CC_822E_28682A64187D__INCLUDED_

#include "afxdao.h"

#include "Matrix.h"//zdh

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ForecastDlg.h : header file
//


/////////////////////////////////////////////////////////////////////////////
// CForecastDlg dialog
//***************************************************************************zdh
/////////////////////////////////////////////////////////////////////////////
//	Levenberg-Marquart		---->	第一次前向计算初始化				   //
/////////////////////////////////////////////////////////////////////////////




__declspec (dllimport) void LMForwardCalculateInit( int nInputLayerNumber,
													int nHideLayerNumber,
													int nOutputLayerNumber,
													CMatrix &matrixDemoDataInput,
													CMatrix &matrixInputLayerValue,
													CMatrix &matrixInputToHideWeightValue,
													CMatrix &matrixHideLayerValveValue,
													CMatrix &matrixHideToOutputWeightValue,
													CMatrix &matrixOutputLayerValveValue
													);

/////////////////////////////////////////////////////////////////////////////
//	Levenberg-Marquart		---->		前向计算						   //
/////////////////////////////////////////////////////////////////////////////
__declspec(dllimport) void LMForwardCalculate ( int nInputLayerNumber,
												int nHideLayerNumber,
												int nOutputLayerNumber,
												bool bSimulateDataFlag,
												int nComboFunc,
												CMatrix &matrixDemoDataInput,
												CMatrix &matrixInputLayerValue,
												CMatrix &matrixInputToHideWeightValue,
												CMatrix &matrixHideLayerValveValue,
												CMatrix &matrixHideLayerOutput,
												CMatrix &matrixHideToOutputWeightValue,
												CMatrix &matrixOutputLayerOutput,
												CMatrix &matrixOutputLayerValveValue
											   );

/////////////////////////////////////////////////////////////////////////////
//	Levenberg-Marquart		---->		反馈计算						   //
/////////////////////////////////////////////////////////////////////////////
__declspec(dllimport) bool LMDemoDataTrainRepeat (	int nInputLayerNumber,
													int nHideLayerNumber,
													int nOutputLayerNumber,
													bool bSimulateDataFlag,
													int nComboFunc,
													double nSystemErrorOld,
													double nSystemErrorNew,
													double nSystemErrorLevel,
													double nSystemError,
													double nStep,
													UINT nMaxTrainTimes,
													UINT nTrainTimes,
													DWORD ID_SYSTEM_ERROR,
													DWORD ID_TRAIN_TIMES,
													HWND  hWnd,
													CMatrix &matrixDemoDataInput,
													CMatrix &matrixInputLayerValue,
													CMatrix &matrixInputToHideWeightValue,
													CMatrix &matrixHideLayerValveValue,
													CMatrix &matrixHideLayerOutput,
													CMatrix &matrixHideToOutputWeightValue,
													CMatrix &matrixOutputLayerOutput,
													CMatrix &matrixOutputLayerValveValue
												 );

/////////////////////////////////////////////////////////////////////////////
//	Back propagation		---->		前向计算(Only for Training)		   //
/////////////////////////////////////////////////////////////////////////////
__declspec(dllexport) void BPForwardCalculate ( int nInputLayerNumber,
												int nHideLayerNumber,
												int nOutputLayerNumber,
												bool bSimulateDataFlag,
												int nComboFunc,
												CMatrix &matrixDemoDataInput,
												CMatrix &matrixInputLayerValue,
												CMatrix &matrixInputToHideWeightValue,
												CMatrix &matrixHideLayerValveValue,
												CMatrix &matrixHideLayerOutput,
												CMatrix &matrixHideToOutputWeightValue,
												CMatrix &matrixOutputLayerOutput,
												CMatrix &matrixOutputLayerValveValue,
												CMatrix &cMatrixExHideLayerValveValue,
												CMatrix &cMatrixExOutputLayerValveValue
											   );

/////////////////////////////////////////////////////////////////////////////
//	Back propagation		---->		前向计算(Only for Simulating)	   //
/////////////////////////////////////////////////////////////////////////////
__declspec(dllimport) void BPForwardCalculate2( int nInputLayerNumber,
												int nHideLayerNumber,
												int nOutputLayerNumber,
												bool bSimulateDataFlag,
												int nComboFunc,
												CMatrix &matrixDemoDataInput,
												CMatrix &matrixInputLayerValue,
												CMatrix &matrixInputToHideWeightValue,
												CMatrix &matrixHideLayerValveValue,
												CMatrix &matrixHideLayerOutput,
												CMatrix &matrixHideToOutputWeightValue,
												CMatrix &matrixOutputLayerOutput,
												CMatrix &matrixOutputLayerValveValue
											   );

/////////////////////////////////////////////////////////////////////////////
//	Back propagation		---->		反馈计算						   //
/////////////////////////////////////////////////////////////////////////////
__declspec(dllimport) bool BPDemoDataTrainRepeat (	int nInputLayerNumber,
													int nHideLayerNumber,
													int nOutputLayerNumber,
													bool bSimulateDataFlag,
													int nComboFunc,
													double nSystemErrorOld,
													double nSystemErrorNew,
													double nSystemErrorLevel,
													double nSystemError,
													double nStep,
													UINT nMaxTrainTimes,
													UINT nTrainTimes,
													DWORD ID_SYSTEM_ERROR,
													DWORD ID_TRAIN_TIMES,
													HWND  hWnd,
													CMatrix &matrixDemoDataInput,
													CMatrix &matrixInputLayerValue,
													CMatrix &matrixInputToHideWeightValue,
													CMatrix &matrixHideLayerValveValue,
													CMatrix &matrixHideLayerOutput,
													CMatrix &matrixHideToOutputWeightValue,
													CMatrix &matrixOutputLayerOutput,
													CMatrix &matrixOutputLayerValveValue
												 );

//class CForecastDlg;
//using namespace std;

//***************************************************************************zdh



class CForecastDlg : public CDialog
{

	// Construction
public:
	bool LoadDataFromFile(CString& strFileName);
	CString GetVariantString(COleVariant var);
	void ShowTable(HTREEITEM hi);
	void ShowFieldInfo(HTREEITEM hi);
	void ShowDatabaseInfo();
	CForecastDlg(CWnd* pParent = NULL);   // standard constructor

//	CDaoRecordset m_set;  //记录集对象;
//	CDaoDatabase m_Db;    //DAO数据库对象;
    short m_Nt;           //表的数目;
	HTREEITEM m_hTr;      //树状控件根节点句柄;
// Dialog Data
	//{{AFX_DATA(CForecastDlg)
	enum { IDD = IDD_FORECASTDLG };
	CListCtrl	m_ForecastList;
	CTreeCtrl	m_Tree1;
	CListCtrl	m_List1;
	UINT	m_ColStart;
	UINT	m_ColEnd;
	BOOL	m_Check;
	UINT	m_ResultCol;
	CMSChart	m_Chart;
	//}}AFX_DATA
    double *LineCo;
	double *Result;
	double *RealResult;
	bool LoadTag;
	bool ForecastTag;
	UINT ColCnt;
	UINT ItemCnt;

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CForecastDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	void InitChart();

	// Generated message map functions
	//{{AFX_MSG(CForecastDlg)
	afx_msg void OnBrowse();
	afx_msg void OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSetfocusTree1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBrowsemodel();
	virtual void OnOK();
	virtual void OnCancel();
	virtual BOOL OnInitDialog();
	afx_msg void OnCancelMode();
	afx_msg void OnResultcheck();
	afx_msg void OnCurve();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

//******************************************zdh

private:



   
	
	// 前向计算初始化
	void ForwardCalculateInit();
	
	// 反复训练
	bool DemoDataTrainRepeat();


	// 用于存储输入的样本数据的矩阵
	CMatrix		m_matrixDemoDataInput;

	// 样本的输入层的数值矩阵
	CMatrix		m_matrixInputLayerValue;

	// 输入层到隐含层的权值矩阵
	CMatrix		m_matrixInputToHideWeightValue;

	// 隐含层的阀值矩阵
	CMatrix		m_matrixHideLayerValveValue;

	// 隐含层到输出层的权值矩阵
	CMatrix		m_matrixHideToOutputWeightValue;

	// 输出层的阀值矩阵
	CMatrix		m_matrixOutputLayerValveValue;

	// 隐含层的输出值的矩阵
	CMatrix		m_matrixHideLayerOutput;

	// 输出层的输出值的矩阵
	CMatrix		m_matrixOutputLayerOutput;

	// 用来仿真时输入的网络参数矩阵
	CMatrix		m_matrixSimuNetwork;

	// 用来存放仿真数据结果的矩阵
	CMatrix		m_matrixSimuResult;
public:
//***************************************zdh
	UINT      m_nInputLayerNumber;
    UINT      m_nHideLayerNumber;
    UINT      m_nOutputLayerNumber;
    int       m_nComboArithmetic;
	int       m_nComboFunc;	
   // 是样本训练还是数据仿真?
	bool		m_bSimulateDataFlag;
//**************************************DrawCurve
    CPen Pen[9];
    CBitmap *m_pBitmap;
    CDC *m_pMemDC;
    CRect LineRect;
    int RowGridNum;
    int YLength;
    int ColGridNum;
    int XLength;
//    int m_day;//天数即线的条数

//  double m_NRdata[2][93];
//  double m_CSdata[2][93];
//  double m_ASdata[2][93];
//  double m_H2Odata[93];

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FORECASTDLG_H__FE3AC8EB_C28F_47CC_822E_28682A64187D__INCLUDED_)

⌨️ 快捷键说明

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