private tableau2 fuzzy2(tableau2 tab, int type, int cons, int vars, float[,,] tabb) { int pc = tab.getPC(); int pr = tab.getPR(pc); float pe = tab.getPE(pc, pr); tab.setSide(); //creating a new tableau instance tableau2 _tb = new tableau2(tabb, type, cons, vars, side2); //then the instance is used to generate a new table, i.e tableau 2 // and is assigned to the public tab1 _tb.getNewTableau(tabb, pc, pr, pe); _tb.rank(); return(_tb); }
private void eq23go_Click(object sender, RoutedEventArgs e) { cons = 2; vars = 3; string[,,] text = new string[3, 4, 4] { { //first row { eq23000.Text, eq23001.Text, eq23002.Text, eq23003.Text }, { eq23010.Text, eq23011.Text, eq23012.Text, eq23013.Text }, { eq23020.Text, eq23021.Text, eq23022.Text, eq23023.Text }, { eq23030.Text, eq23031.Text, eq23032.Text, eq23033.Text } }, { //second row { eq23100.Text, eq23101.Text, eq23102.Text, eq23103.Text }, { eq23110.Text, eq23111.Text, eq23112.Text, eq23113.Text }, { eq23120.Text, eq23121.Text, eq23122.Text, eq23123.Text }, { eq23130.Text, eq23131.Text, eq23132.Text, eq23133.Text } }, { //z-row { eq23z00.Text, eq23z01.Text, eq23z02.Text, eq23z03.Text }, { eq23z10.Text, eq23z11.Text, eq23z12.Text, eq23z13.Text }, { eq23z20.Text, eq23z21.Text, eq23z22.Text, eq23z23.Text }, { "0", "0", "0", "0" } } }; // Validation string[] tiers = new string[12]; string[] tier = new string[12]; int n = 0; bool ans; bool status = false; for (int x = 0; x < 3; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { eqn23[x, y, z] = isValid(text[x, y, z]) ? float.Parse(text[x, y, z]) : 0; } tiers[n] = eqn23[x, y, 0] + "-" + eqn23[x, y, 1] + "-" + eqn23[x, y, 2] + "-" + eqn23[x, y, 3]; List <float> temp = new List <float> { eqn23[x, y, 0], eqn23[x, y, 1], eqn23[x, y, 2], eqn23[x, y, 3] }; temp.Sort(); tier[n] = temp[0] + "-" + temp[1] + "-" + temp[2] + "-" + temp[3]; n = n + 1; } } for (int i = 0; i < 12; i++) { ans = isArranged(tiers[i], tier[i]); if (ans == true) { status = true; err2.Visibility = Visibility.Visible; err2.Foreground = Brushes.Green; err2.Content = "Inputs are Ok."; } else if (ans == false) { status = false; err2.Visibility = Visibility.Visible; err2.Foreground = Brushes.Red; err2.Content = "Inputs are not Ok."; break; } } if (status == true) { // Assigning the float[,,] eqn_23 = { //row 1 { { eqn23[0, 0, 0], eqn23[0, 0, 1], eqn23[0, 0, 2], eqn23[0, 0, 3], 0 }, { eqn23[0, 1, 0], eqn23[0, 1, 1], eqn23[0, 1, 2], eqn23[0, 1, 3], 0 }, { eqn23[0, 2, 0], eqn23[0, 2, 1], eqn23[0, 2, 2], eqn23[0, 2, 3], 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { eqn23[0, 3, 0], eqn23[0, 3, 1], eqn23[0, 3, 2], eqn23[0, 3, 3], 0 } }, //row 2 { { eqn23[1, 0, 0], eqn23[1, 0, 1], eqn23[1, 0, 2], eqn23[1, 0, 3], 0 }, { eqn23[1, 1, 0], eqn23[1, 1, 1], eqn23[1, 1, 2], eqn23[1, 1, 3], 0 }, { eqn23[1, 2, 0], eqn23[1, 2, 1], eqn23[1, 2, 2], eqn23[1, 2, 3], 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { eqn23[1, 3, 0], eqn23[1, 3, 1], eqn23[1, 3, 2], eqn23[1, 3, 3], 0 } }, //z-row { { eqn23[2, 0, 0], eqn23[2, 0, 1], eqn23[2, 0, 2], eqn23[2, 0, 3], 0 }, { eqn23[2, 1, 0], eqn23[2, 1, 1], eqn23[2, 1, 2], eqn23[2, 1, 3], 0 }, { eqn23[2, 2, 0], eqn23[2, 2, 1], eqn23[2, 2, 2], eqn23[2, 2, 3], 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } } }; //Major //initialize the draw segment int offset = 20; tableGrid page = new tableGrid(stacky, offset); page.clear(); tableau2 tb23 = new tableau2(eqn_23, type, cons, vars, side2); tb23.toCompForm(); tb23.rank(); //gives optimal the value of the isOptimal method of the current tableau optimal = tb23.isOptimal(); for (int i = 0; optimal == false; i++) { if (tb23.isOptimal()) { //stop tab2 = tb23.tab; pref.Visibility = Visibility.Collapsed; comm.Visibility = Visibility.Collapsed; page.draw2(tab2, "Tableau " + (i + 1), "Tableau is Optimal", 0, side2); optimal = true; page.statement("Z* = " + tab2[2, 5, 0] + " , " + tab2[2, 5, 1] + " , " + tab2[2, 5, 2] + " , " + tab2[2, 5, 3] + " | " + tab2[2, 5, 4] + "\n" + side2[0] + "* = " + tab2[0, 5, 0] + " , " + tab2[0, 5, 1] + " , " + tab2[0, 5, 2] + " , " + tab2[0, 5, 3] + " | " + tab2[0, 5, 4] + " , " + side2[1] + "* = " + tab2[1, 5, 0] + " , " + tab2[1, 5, 1] + " , " + tab2[1, 5, 2] + " , " + tab2[1, 5, 3] + " | " + tab2[1, 5, 4]); break; } else { tab2 = tb23.tab; pc = tb23.getPC(); pr = tb23.getPR(pc); float pe = tb23.getPE(pc, pr); int pos = getPeNum3(pr, pc); pref.Visibility = Visibility.Collapsed; comm.Visibility = Visibility.Collapsed; side2 = tb23.side; page.draw2(tab2, "Tableau " + (i + 1), "Tableau is not Optimal", pos, side2); tb23 = fuzzy2(tb23, type, cons, vars, tab2); optimal = false; offset = page.off; } } } }