模糊综合评判c#代码.doc

上传人:豆**** 文档编号:27119537 上传时间:2022-07-22 格式:DOC 页数:46 大小:435.50KB
返回 下载 相关 举报
模糊综合评判c#代码.doc_第1页
第1页 / 共46页
模糊综合评判c#代码.doc_第2页
第2页 / 共46页
点击查看更多>>
资源描述

《模糊综合评判c#代码.doc》由会员分享,可在线阅读,更多相关《模糊综合评判c#代码.doc(46页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-date模糊综合评判c#代码模糊综合评判c#代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Win

2、dows.Forms;using System.Data.OleDb;using System.Web;namespace FuzzyJudge public partial class Form1 : Form public static int MatrixRows = 4; public static int MatrixCols = 6; double, a = new doubleMatrixRows, MatrixCols; double b = new doubleMatrixCols; double myResult = new doubleMatrixRows; double

3、 myweight = new doubleMatrixCols; double, mysort = new doubleMatrixRows, MatrixCols; double, myLiShuDu = new doubleMatrixCols, MatrixRows; string, s = new stringMatrixRows, MatrixCols; string t = new stringMatrixCols; int i, j; public Form1() InitializeComponent(); private void Button3_Click(object

4、sender, EventArgs e) string sql = select * from 评判集$; DataTable da = DB.GetDataTable(sql); for (int m = 0; m 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,

5、4; label6.Text = s0, 5; label7.Text = s1, 0; label8.Text = s1, 1; label9.Text = s1, 2; label10.Text = 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 =

6、s3, 0; label20.Text = s3, 1; label21.Text = s3, 2; label22.Text = s3, 3; label23.Text = s3, 4; label24.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 (

7、read.Read() for (i = 0; i MatrixCols; i+) ti = readi.ToString(); TextBox1.Text = 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 MatrixCo

8、ls; i+) / for (j = 0; j MatrixRows; j+) / / myLiShuDui, 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;

9、 for (i = 0; i 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); ETo

10、tal = 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; for (j = 0

11、; j MatrixCols; j+) for (i = 0; i 3; i+) for (k = i; k 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, LSDResult = new doubleMatrixCols, MatrixRows; int i, j, k; f

12、or (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, j & bj = ck + 1, j) LSDResultj, i = 0; if (k = 1 | k = 2) if (bj = ck - 1, j & bj = c

13、k, j & bj = ck + 1, j) LSDResultj, i = 0; if (k = 3) if (bj = ck - 1, j & 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 doubleMatrixRow

14、s; int i, j; for (i = 0; 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(

15、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.00); TextBox11.Text = myweight4.ToString(0.00);

16、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); TextBox15.Text = myResult2.ToString(0.00); TextBox16.Text = myResult3.ToString(0.00); private void Butto

17、n2_Click(object sender, EventArgs e) this.Close(); private void Button4_Click(object sender, EventArgs e) string filename = Application.StartupPath + computing result.xls; string connstr = Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source= + filename + ;Extended Properties=E

18、xcel 8.0;HDR=Yes;/这个链接字符串是excel2003的 OleDbConnection oleConn = new OleDbConnection(connstr); try oleConn.Open(); string sqlStr,sqlStr1; DataTable dt = oleConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, null); bool existTable = false; foreach (DataRow dr in dt.Rows)/检查是否有信息表 if (drTABLE_NAME.To

19、String() = 指标权重表$ & drTABLE_NAME.ToString() = 评判结果表$)/要加个$号 existTable = true; if (!existTable) sqlStr = create table 指标权重表(完成质量确认_40 char(15),完成质量确认_80 nvarchar(10),施工方案变更确认 char(8),野外验收日期和结论 nvarchar(20),年度工作报告 varchar(30),监理评语 nvarchar(50); sqlStr1 = create table 评判结果表(好 char(15),较好 nvarchar(10),

20、一般 char(8),较差 nvarchar(20); OleDbCommand oleCmd = 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.T

21、ext; 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.Text; /下面的代码用OleDbCommand的parameter添加参数sqlStr = insert into 指标权重表 va

22、lues( + quality_40 + , + quality_80 + , + changeconfirm + , + datediscuss + , + workreport + , + comment + ); OleDbCommand Cmd = new OleDbCommand(sqlStr, oleConn); Cmd.ExecuteNonQuery(); sqlStr1 = insert into 评判结果表 values( + good + , + littlegood + , + common + , + bad + ); OleDbCommand Cmd1 = new OleDbCommand(sqlStr1, oleConn); Cmd1.ExecuteNonQuery(); MessageBox.Show(数据导出成功!); catch (Exception te) MessageBox.Show(te.Message); finally oleConn.Close(); -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁