public MakeSymTri ( Matrix mtxQ, Matrix mtxT, double dblB, double dblC ) : bool | ||
mtxQ | Matrix | |
mtxT | Matrix | |
dblB | double | |
dblC | double | |
리턴 | bool |
public bool CalculateAssessment() { dgAssessment.Refresh(); try { int Rows, Columns;//��¼����Ԫ�ص����������� Rows = dgAssessment.Rows.Count - 1; Columns = dgAssessment.Columns.Count - 1; lbState.Visible = true; pgBar.Visible = true; double[,] X = new double[Rows, Columns]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Columns; j++) { if (isNumberic(dgAssessment.Rows[i + 1].Cells[j + 1].Value.ToString(), out X[i, j])) ; else return false; } } //��һ�� double[,] S = new double[Rows, Columns]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Columns; j++) { //object a=dgChooseSmallIndex.Rows[j].Cells[0].Value; if (dgChooseSmallIndex.Rows[j].Cells[0].Value.ToString().Equals("True")) { S[i, j] = 1 / X[i, j]; } else S[i, j] = X[i, j]; } } lbState.Text = "���ڶ�ԭʼ���ݽ��й淶��"; pgBar.Value = 10; //�ڶ��� double[,] R = new double[Rows, Columns]; double[] M = new double[Columns]; double[] m = new double[Columns]; for (int j = 0; j < Columns; j++) { M[j] = S[0, j]; m[j] = S[0, j]; for (int i = 0; i < Rows; i++) { //object a=dgChooseSmallIndex.Rows[j].Cells[0].Value; if (S[i, j] > M[j]) { M[j] = S[i, j]; } if (S[i, j] < m[j]) { m[j] = S[i, j]; } } } for (int i = 0; i < Rows; i++) { for (int j = 0; j < Columns; j++) { //object a=dgChooseSmallIndex.Rows[j].Cells[0].Value; R[i, j] = S[i, j] / m[j]; } } lbState.Text = "���ڼ����ۺ�����ֵ��ȡֵ��Χ"; pgBar.Value = 25; //������ double ��1 = dbInputFactor��1.Value; double[,] T = new double[Rows, Columns]; double[] wu = new double[Columns]; T = (double [,])R.Clone(); for (int j = 0; j < Rows; j++) { for (int i = 0; i < Columns; i++) { for (int k = i + 1; k < Columns; k++) { if (T[j, i] < T[j, k]) { double temp = T[j, k]; T[j, k] = T[j, i]; T[j, i] = temp; } } } } if (radioButton1.Checked) { //���ڡ�ǿȨ���Ƕ������������� double temp = 0; for (int i = 0; i < Columns - 2; i++) { wu[i] = Math.Pow(0.5, i + 1); temp += wu[i]; } wu[Columns - 2] = wu[Columns - 1] = 0.5 - 0.5 * temp; } else {//���ڡ���Ȩ���Ƕ������������� wu[0] = 0.5; wu[1] = 0.5 - (Columns - 2) * Math.Pow(0.5, Columns - 1); for (int i = 2; i < Columns; i++) { wu[i] = Math.Pow(0.5, Columns - 1); } } double[,] y = new double[Rows, 2]; for (int i = 0; i < Rows; i++) { double temp0 = 0, temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 1, temp5= 1; for (int j = 0; j < Columns; j++) { temp2 += wu[j] * T[i, Columns - j - 1]; temp3 += wu[j] * T[i, j]; //temp4 *= Math.Pow(); temp4 *= Math.Pow(T[i, Columns - j - 1], 1 / Columns); temp5 *= Math.Pow(T[i, j], 1 / Columns); } temp0 = (��1 * temp2 + (1-��1) * temp4); temp1 = (��1 * temp3 + (1-��1) * temp5); y[i, 0] = temp0; y[i, 1] = temp1; } lbState.Text = "���ڼ�������̷����ľ�����Ұ"; pgBar.Value = 45; //���IJ� double[,] C_L = new double[Rows, Rows]; double[,] C_U = new double[Rows, Rows]; for (int i = 0; i < Rows; i++) { for (int j = i; j < Rows; j++) { intersection(y[i, 0], y[i, 1], y[j, 0], y[j, 1], out C_L[i, j], out C_U[i, j]); } } double[,] d = new double[Rows, Rows]; for (int i = 0; i < Rows; i++) { for (int j = i; j < Rows; j++) { if (i == j) { d[i, j] = 0;//���ﲻ֪��������ʲô��˼�����Ұ���0������ } else { d[i, j] = d[j, i] = (C_U[i, j] - C_L[i, j]) / (Math.Max(y[i, 1], y[j, 1]) - Math.Min(y[i, 0], y[j, 0])); } } } lbState.Text = "���ڼ�������̷����ľ���ǿ��"; pgBar.Value = 70; //���岽 double[,] u = new double[Rows, Rows]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Rows; j++) { if (i == j) { u[i, j] = 0; } else { double temp = 0; for (int k = 0; k < Rows; k++) { temp += d[i, k]; } u[i, j] = d[i, j] / temp; } } } lbState.Text = "���ڼ��㾺������עϵ������"; pgBar.Value = 80; //������ double �� = dbInputFactor��.Value; double[,] w = new double[Rows, Columns]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Columns; j++) { double temp = 0; for (int k = 0; k < Rows; k++) { if (k != i) { temp += R[k, j] * u[i, k]; } } w[i, j] = �� * R[i, j] - (1 - ��) * temp; } } //���߲� lbState.Text = "���ڹ���滮���Ⲣ���"; pgBar.Value = 90; double[,] wx = new double[Rows, Columns];//wx��ʾw*:xΪ�ǵ���˼ //���ڡ�ǿȨ���Ƕ������������͡�ǿȨ���Ƕ�����������������һ���ģ� //��Ϊ��wx����wu��õģ���wu�Ѿ�ͨ������������á� ToBeOrdered[] orderNumber = new ToBeOrdered[Columns]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Columns; j++) {//�ȸ�ֵ orderNumber[j].Index = j; orderNumber[j].Value = w[i, j]; } for (int j = 0; j < Columns; j++) {//������ for (int k = j + 1; k < Columns; k++) { if (orderNumber[j].Value < orderNumber[k].Value) { ToBeOrdered temp = orderNumber[k]; orderNumber[k] = orderNumber[j]; orderNumber[j] = temp; } } } for (int j = 0; j < Columns; j++) {//������ wx[i, orderNumber[j].Index] = wu[j]; } } //�ڰ˲� double[,] Y = new double[Rows, Rows]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Rows; j++) { double temp = 0, temp6 = 0, temp7 = 1; for (int k = 0; k < Columns; k++) { //temp += wx[j, k] * R[i, k]; temp6 += wx[j, k] * R[i, k]; temp7 *= Math.Pow(R[i, k], 1 / Columns); } //Y[i, j] = temp; temp = (��1 * temp6 + (1-��1) * temp7); Y[i, j] = temp; } } //�ھŲ� //������������������ double[,] Y1 = new double[Rows, Rows];//��� double[,] Y2 = new double[Rows, Rows];//�Ҳ� double[,] Y3 = new double[Rows, Rows];//��� Y1 =(double [,]) Y.Clone(); for (int i = 0; i < Rows; i++) {//����ת�þ��� for (int j = 0; j < Rows; j++) { Y2[i, j] = Y1[j, i]; } } for (int i = 0; i < Rows; i++) {//����Գƾ��� for (int j = 0; j < Rows; j++) { double temp = 0; for (int k = 0; k < Rows; k++) { temp += Y1[i, k] * Y2[k, j]; } Y3[i, j] = temp; } } double[] Y4 = new double[Rows*Rows];//���ڼ������ for (int i = 0; i < Rows; i++) {//���Գƾ���ת��Ϊһά���� for (int j = 0; j < Rows; j++) { Y4[i*Rows+j] = Y3[i, j]; } } ////////////////////////////////////////// // ʵ�Գ����Խ����ȫ������ֵ�����������ļ��� Matrix mtx16 = new Matrix(Rows, Rows, Y4); Matrix mtxQ2 = new Matrix();//���غ�˹�ɶ��±任�ij˻�����Q Matrix mtxT2 = new Matrix();//������õĶԳ����Խ��� double[] bArray2 = new double[mtx16.GetNumColumns()];//���ضԳ����Խ�������Խ���Ԫ�� double[] cArray2 = new double[mtx16.GetNumColumns()];//ǰn-1��Ԫ�ط��ضԳ����Խ���ĴζԽ���Ԫ�� double[] resultArray = new double[mtx16.GetNumColumns()];//��Ŧ˵Ľ��ֵ // 1: Լ���Գƾ���Ϊ�Գ����Խ���: ��˹�ɶ��±任�� if (mtx16.MakeSymTri(mtxQ2, mtxT2, bArray2, cArray2)) { // 2: ����ȫ������ֵ���������� //bArray2:����Գ����Խ�������Խ���Ԫ��,����ʱ���ȫ������ֵ�� //cArray2:ǰn-1��Ԫ�ش���Գ����Խ���ĴζԽ���Ԫ�� //mtxQ2:���ؾ���A������ֵ�����������е�i��Ϊ������dblB�е�i������ֵ��Ӧ������������ //60:�������� //0.0001:���㾫�� if (mtx16.ComputeEvSymTri(bArray2, cArray2, mtxQ2, 60, 0.0001)) { int tempi = 0; double tempNum = bArray2[0]; for (int i = 0; i < mtxQ2.GetNumColumns(); ++i) {//��������ֵ�������Ǹ� if (tempNum < bArray2[i]) { tempi = i; tempNum = bArray2[i]; } } for (int i = 0; i < mtxQ2.GetNumRows(); ++i) { if(mtxQ2.GetElement(i,tempi)<0) {//ȡ��ֵ resultArray[i]=-mtxQ2.GetElement(i,tempi); } else { resultArray[i]=mtxQ2.GetElement(i,tempi); } } } else { return false; } } else { return false; } ////////////////////////////////////////// //��ʮ�� double[,] x = new double[Rows, Rows]; ToBeOrdered[] orderNumber2 = new ToBeOrdered[Rows]; for (int i = 0; i < Rows; i++) { for (int j = 0; j < Rows; j++) {//�ȸ�ֵ orderNumber2[j].Index = j; orderNumber2[j].Value = Y[j, i];//ע���Ƕ��н��в��� } for (int j = 0; j < Rows; j++) {//������ for (int k = j + 1; k < Rows; k++) { if (orderNumber2[j].Value < orderNumber2[k].Value) { ToBeOrdered temp = orderNumber2[k]; orderNumber2[k] = orderNumber2[j]; orderNumber2[j] = temp; } } } for (int j = 0; j < Rows; j++) {//������ x[orderNumber2[j].Index, i] = j + 1;//ע��ֵԽ�����ԽС } } // //��ʮһ�� int[] orderResult = new int[Rows];//��Ŧ˵�����ֵ ToBeOrdered[] orderNumber3 = new ToBeOrdered[Rows]; for (int j = 0; j < Rows; j++) {//�ȸ�ֵ orderNumber3[j].Index = j; orderNumber3[j].Value = resultArray[j]; } for (int j = 0; j < Rows; j++) {//������ for (int k = j + 1; k < Rows; k++) { if (orderNumber3[j].Value < orderNumber3[k].Value) { ToBeOrdered temp = orderNumber3[k]; orderNumber3[k] = orderNumber3[j]; orderNumber3[j] = temp; } } } for (int j = 0; j < Rows; j++) {//������ orderResult[orderNumber3[j].Index] = j + 1;//ע��ֵԽ�����ԽС } // lbState.Text = "������ɣ�"; pgBar.Value = 100; lbState.Visible = false; pgBar.Visible = false; FrmAssessResultshow result = new FrmAssessResultshow(x,orderResult); result.ShowDialog(); } catch { return false; } return true; }