模糊綜合評判c#代碼(共9頁)_第1頁
模糊綜合評判c#代碼(共9頁)_第2頁
模糊綜合評判c#代碼(共9頁)_第3頁
模糊綜合評判c#代碼(共9頁)_第4頁
模糊綜合評判c#代碼(共9頁)_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、精選優(yōu)質文檔-傾情為你奉上using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;using System.Web;namespace FuzzyJudge public partial class Form1 : Form public static i

2、nt MatrixRows = 4; public static int MatrixCols = 6; double, a = new doubleMatrixRows, MatrixCols; double b = new doubleMatrixCols; double myResult = new doubleMatrixRows; double myweight = new doubleMatrixCols; double, mysort = new doubleMatrixRows, MatrixCols; double, myLiShuDu = new doubleMatrixC

3、ols, MatrixRows; string, s = new stringMatrixRows, MatrixCols; string t = new stringMatrixCols; int i, j; public Form1() InitializeComponent(); private void Button3_Click(object sender, EventArgs e) string sql = "select * from 評判集$" DataTable da = DB.GetDataTable(sql); for (int m = 0; m &l

4、t; da.Rows.Count; m+) for (int n = 0; n < da.Columns.Count; n+) sm, n = da.Rowsmn.ToString(); Label1.Text = s0, 0; label2.Text = s0, 1; label3.Text = s0, 2; label4.Text = s0, 3; label5.Text = s0, 4; label6.Text = s0, 5; label7.Text = s1, 0; label8.Text = s1, 1; label9.Text = s1, 2; label10.Text =

5、 s1, 3; label11.Text = s1, 4; label12.Text = s1, 5; label13.Text = s2, 0; label14.Text = s2, 1; label15.Text = s2, 2; label16.Text = s2, 3; label17.Text = s2, 4; label18.Text = s2, 5; label19.Text = s3, 0; label20.Text = s3, 1; label21.Text = s3, 2; label22.Text = s3, 3; label23.Text = s3, 4; label2

6、4.Text = s3, 5; for (i = 0; i < MatrixRows; i+) for (j = 0; j < MatrixCols; j+) ai, j = Convert.ToDouble(si, j); string sql1 = "select * from 評價指標值$" OleDbDataReader read = DB.ExecuteReader(sql1); while (read.Read() for (i = 0; i < MatrixCols; i+) ti = readi.ToString(); TextBox1.T

7、ext = t0; TextBox2.Text = t1; TextBox3.Text = t2; TextBox4.Text = t3; TextBox5.Text = t4; textBox6.Text = t5; for (i = 0; i < MatrixCols; i+) bi = Convert.ToDouble(ti); / Console.Write("評判集和評判因子的關系矩陣:n"); / for (i = 0; i < MatrixCols; i+) / for (j = 0; j < MatrixRows; j+) / / myLi

8、ShuDui, j = Lishudu(i, j, a, b); / / for (i = 0; i < MatrixCols; i+) / / for (j = 0; j < MatrixRows; j+) / / Console.Write("0:F, ", myLiShuDui, j); / / Console.Write("n"); / static double CalculateAverage(int m, double, a) double myResult; int i; myResult = 0; for (i = 0; i

9、 < MatrixRows; i+) myResult = myResult + ai, m; myResult = myResult / MatrixRows; return myResult; static double EWeight(int m, double, a, double b) double Aver = new doubleMatrixCols; double EResult; int i; double ETotal; for (i = 0; i < MatrixCols; i+) Averi = CalculateAverage(i, a); ETotal

10、= 0; for (i = 0; i < MatrixCols; i+) ETotal += (bi / Averi); EResult = (bm / Averm) / ETotal; return EResult; static double Sort(int m, int n, double, a) double, b = new doubleMatrixRows, MatrixCols; int i, j, k; for (i = 0; i < MatrixRows; i+) for (j = 0; j < MatrixCols; j+) bi, j = ai, j;

11、 for (j = 0; j < MatrixCols; j+) for (i = 0; i < 3; i+) for (k = i; k < MatrixRows; k+) if (bi, j > bk, j) double tmp; tmp = bi, j; bi, j = bk, j; bk, j = tmp; return bm, n; static double Lishudu(int m, int n, double, a, double b) double, c = new doubleMatrixRows, MatrixCols; double, LSD

12、Result = new doubleMatrixCols, MatrixRows; int i, j, k; for (i = 0; i < MatrixRows; i+) for (j = 0; j < MatrixCols; j+) ci, j = Sort(i, j, a); for (j = 0; j < MatrixCols; j+) for (i = 0; i < MatrixRows; i+) for (k = 0; k < MatrixRows; k+) if (ai, j = ck, j) if (k = 0) if (bj < ck,

13、j) LSDResultj, i = 1; if (bj >= ck, j && bj < ck + 1, j) LSDResultj, i = (ck + 1, j - bj) / (ck + 1, j - ck, j); if (bj >= ck + 1, j) LSDResultj, i = 0; if (k = 1 | k = 2) if (bj < ck - 1, j) LSDResultj, i = 0; if (bj >= ck - 1, j && bj < ck, j) LSDResultj, i = (bj

14、- ck - 1, j) / (ck, j - ck - 1, j); if (bj >= ck, j && bj < ck + 1, j) LSDResultj, i = (ck + 1, j - bj) / (ck + 1, j - ck, j); if (bj >= ck + 1, j) LSDResultj, i = 0; if (k = 3) if (bj < ck - 1, j) LSDResultj, i = 0; if (bj >= ck - 1, j && bj < ck, j) LSDResultj, i

15、= (bj - ck - 1, j) / (ck, j - ck - 1, j); if (bj >= ck, j) LSDResultj, i = 1; return LSDResultm, n; static double FuzzyEvalution(int x, double, a, double b) double E = new doubleMatrixCols; double, R = new doubleMatrixCols, MatrixRows; double FEResult = new doubleMatrixRows; int i, j; for (i = 0;

16、 i < MatrixCols; i+) for (j = 0; j < MatrixRows; j+) Ri, j = Lishudu(i, j, a, b); for (i = 0; i < MatrixCols; i+) Ei = EWeight(i, a, b); for (i = 0; i < MatrixRows; i+) FEResulti = 0; for (j = 0; j < MatrixCols; j+) FEResulti += Ej * Rj, i; return FEResultx; private void Button1_Click

17、(object sender, EventArgs e) for (i = 0; i < MatrixCols; i+) myweighti = EWeight(i, a, b); TextBox7.Text = myweight0.ToString("0.00"); TextBox8.Text = myweight1.ToString("0.00"); TextBox9.Text = myweight2.ToString("0.00"); TextBox10.Text = myweight3.ToString("0.

18、00"); TextBox11.Text = myweight4.ToString("0.00"); TextBox12.Text = myweight5.ToString("0.00"); for (i = 0; i < MatrixRows; i+) myResulti = FuzzyEvalution(i, a, b); TextBox13.Text = myResult0.ToString("0.00"); TextBox14.Text = myResult1.ToString("0.00"

19、); TextBox15.Text = myResult2.ToString("0.00"); TextBox16.Text = myResult3.ToString("0.00"); private void Button2_Click(object sender, EventArgs e) this.Close(); private void Button4_Click(object sender, EventArgs e) string filename = Application.StartupPath + "computing res

20、ult.xls" string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" + filename + "Extended Properties='Excel 8.0;HDR=Yes'"/這個鏈接字符串是excel2003的 OleDbConnection oleConn = new OleDbConnection(connstr); try oleConn.Open(); string sqlStr

21、,sqlStr1; DataTable dt = oleConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, null); bool existTable = false; foreach (DataRow dr in dt.Rows)/檢查是否有信息表 if (dr"TABLE_NAME".ToString() = "指標權重表$" && dr"TABLE_NAME".ToString() = "評判結果表$")/要加個$號 existTabl

22、e = true; if (!existTable) sqlStr = "create table 指標權重表(完成質量確認_40 char(15),完成質量確認_80 nvarchar(10),施工方案變更確認 char(8),野外驗收日期和結論 nvarchar(20),年度工作報告 varchar(30),監(jiān)理評語 nvarchar(50)" sqlStr1 = "create table 評判結果表(好 char(15),較好 nvarchar(10),一般 char(8),較差 nvarchar(20)" OleDbCommand oleCmd

23、 = new OleDbCommand(sqlStr, oleConn); oleCmd.ExecuteNonQuery(); OleDbCommand oleCmd1 = new OleDbCommand(sqlStr1, oleConn); oleCmd1.ExecuteNonQuery(); string quality_40 = TextBox7.Text; string quality_80 = TextBox8.Text; string changeconfirm = TextBox9.Text; string datediscuss = TextBox10.Text; string workreport = TextBox11.Text; string comment = TextBox12.Text; string good = TextBox13.Text; string littlegood = TextBox14.Text; string common = TextBox15.Text; string bad = TextBox16

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論