private tableau3 fuzzy3(tableau3 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 tableau3 _tb = new tableau3(tabb, type, cons, vars, side3); //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 eq32go_Click(object sender, RoutedEventArgs e) { cons = 3; vars = 2; string[,,] text = new string[4, 3, 4] { { //first row { eq32000.Text, eq32001.Text, eq32002.Text, eq32003.Text }, { eq32010.Text, eq32011.Text, eq32012.Text, eq32013.Text }, { eq32020.Text, eq32021.Text, eq32022.Text, eq32023.Text } }, { //second row { eq32100.Text, eq32101.Text, eq32102.Text, eq32103.Text }, { eq32110.Text, eq32111.Text, eq32112.Text, eq32113.Text }, { eq32120.Text, eq32121.Text, eq32122.Text, eq32123.Text } }, { //third row { eq32200.Text, eq32201.Text, eq32202.Text, eq32203.Text }, { eq32210.Text, eq32211.Text, eq32212.Text, eq32213.Text }, { eq32220.Text, eq32221.Text, eq32222.Text, eq32223.Text } }, { //z-row { eq32z00.Text, eq32z01.Text, eq32z02.Text, eq32z03.Text }, { eq32z10.Text, eq32z11.Text, eq32z12.Text, eq32z13.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 < 4; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 4; z++) { eqn32[x, y, z] = isValid(text[x, y, z]) ? float.Parse(text[x, y, z]) : 0; } tiers[n] = eqn32[x, y, 0] + "-" + eqn32[x, y, 1] + "-" + eqn32[x, y, 2] + "-" + eqn32[x, y, 3]; List <float> temp = new List <float> { eqn32[x, y, 0], eqn32[x, y, 1], eqn32[x, y, 2], eqn32[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; err3.Visibility = Visibility.Visible; err3.Foreground = Brushes.Green; err3.Content = "Inputs are Ok."; } else if (ans == false) { status = false; err3.Visibility = Visibility.Visible; err3.Foreground = Brushes.Red; err3.Content = "Inputs are not Ok."; break; } } if (status == true) { // Assigning the float[,,] eqn_32 = { //row 1 { { eqn32[0, 0, 0], eqn32[0, 0, 1], eqn32[0, 0, 2], eqn32[0, 0, 3], 0 }, { eqn32[0, 1, 0], eqn32[0, 1, 1], eqn32[0, 1, 2], eqn32[0, 1, 3], 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { eqn32[0, 2, 0], eqn32[0, 2, 1], eqn32[0, 2, 2], eqn32[0, 2, 3], 0 } }, //row 2 { { eqn32[1, 0, 0], eqn32[1, 0, 1], eqn32[1, 0, 2], eqn32[1, 0, 3], 0 }, { eqn32[1, 1, 0], eqn32[1, 1, 1], eqn32[1, 1, 2], eqn32[1, 1, 3], 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { eqn32[1, 2, 0], eqn32[1, 2, 1], eqn32[1, 2, 2], eqn32[1, 2, 3], 0 } }, //row 3 { { eqn32[2, 0, 0], eqn32[2, 0, 1], eqn32[2, 0, 2], eqn32[2, 0, 3], 0 }, { eqn32[2, 1, 0], eqn32[2, 1, 1], eqn32[2, 1, 2], eqn32[2, 1, 3], 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { eqn32[2, 2, 0], eqn32[2, 2, 1], eqn32[2, 2, 2], eqn32[2, 2, 3], 0 } }, //z-row { { eqn32[3, 0, 0], eqn32[3, 0, 1], eqn32[3, 0, 2], eqn32[3, 0, 3], 0 }, { eqn32[3, 1, 0], eqn32[3, 1, 1], eqn32[3, 1, 2], eqn32[3, 1, 3], 0 }, { 0, 0, 0, 0, 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(); tableau3 tb32 = new tableau3(eqn_32, type, cons, vars, side3); tb32.toCompForm(); tb32.rank(); //gives optimal the value of the isOptimal method of the current tableau optimal = tb32.isOptimal(); for (int i = 0; optimal == false; i++) { if (tb32.isOptimal()) { //stop tab3 = tb32.tab; pref.Visibility = Visibility.Collapsed; comm.Visibility = Visibility.Collapsed; page.draw3(tab3, "Tableau " + (i + 1), "Tableau is Optimal", 0, side3); optimal = true; page.statement("Z* = " + tab3[3, 5, 0] + " , " + tab3[3, 5, 1] + " , " + tab3[3, 5, 2] + " , " + tab3[3, 5, 3] + " | " + tab3[3, 5, 4] + "\n" + side3[0] + "* = " + tab3[0, 5, 0] + " , " + tab3[0, 5, 1] + " , " + tab3[0, 5, 2] + " , " + tab3[0, 5, 3] + " | " + tab3[0, 5, 4] + " , " + side3[1] + "* = " + tab3[1, 5, 0] + " , " + tab3[1, 5, 1] + " , " + tab3[1, 5, 2] + " , " + tab3[1, 5, 3] + " | " + tab3[1, 5, 4] + " , " + side3[2] + "* = " + tab3[2, 5, 0] + " , " + tab3[2, 5, 1] + " , " + tab3[2, 5, 2] + " , " + tab3[2, 5, 3] + " | " + tab3[2, 5, 4]); break; } else { tab3 = tb32.tab; pc = tb32.getPC(); pr = tb32.getPR(pc); float pe = tb32.getPE(pc, pr); int pos = getPeNum3(pr, pc); pref.Visibility = Visibility.Collapsed; comm.Visibility = Visibility.Collapsed; side3 = tb32.side; page.draw3(tab3, "Tableau " + (i + 1), "Tableau is not Optimal", pos, side3); tb32 = fuzzy3(tb32, type, cons, vars, tab3); optimal = false; offset = page.off; } } } }