示例#1
0
        private tableau4 fuzzy4(tableau4 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
            tableau4 _tb = new tableau4(tabb, type, cons, vars, side4);

            //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);
        }
示例#2
0
        private void eq33go_Click(object sender, RoutedEventArgs e)
        {
            cons            = 3; vars = 3;
            string[,,] text = new string[4, 4, 4]
            {
                { //first row
                    { eq33000.Text, eq33001.Text, eq33002.Text, eq33003.Text },
                    { eq33010.Text, eq33011.Text, eq33012.Text, eq33013.Text },
                    { eq33020.Text, eq33021.Text, eq33022.Text, eq33023.Text },
                    { eq33030.Text, eq33031.Text, eq33032.Text, eq33033.Text }
                },
                { //second row
                    { eq33100.Text, eq33101.Text, eq33102.Text, eq33103.Text },
                    { eq33110.Text, eq33111.Text, eq33112.Text, eq33113.Text },
                    { eq33120.Text, eq33121.Text, eq33122.Text, eq33123.Text },
                    { eq33130.Text, eq33131.Text, eq33132.Text, eq33133.Text }
                },
                { //third row
                    { eq33200.Text, eq33201.Text, eq33202.Text, eq33203.Text },
                    { eq33210.Text, eq33211.Text, eq33212.Text, eq33213.Text },
                    { eq33220.Text, eq33221.Text, eq33222.Text, eq33223.Text },
                    { eq33230.Text, eq33231.Text, eq33232.Text, eq33233.Text }
                },
                { //z-row
                    { eq33z00.Text, eq33z01.Text, eq33z02.Text, eq33z03.Text },
                    { eq33z10.Text, eq33z11.Text, eq33z12.Text, eq33z13.Text },
                    { eq33z20.Text, eq33z21.Text, eq33z22.Text, eq33z23.Text },
                    { "0", "0", "0", "0" }
                }
            };

            // Validation
            string[] tiers = new string[16];
            string[] tier = new string[16];
            int      n = 0; bool ans; bool status = false;

            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 4; y++)
                {
                    for (int z = 0; z < 4; z++)
                    {
                        eqn33[x, y, z] = isValid(text[x, y, z]) ? float.Parse(text[x, y, z]) : 0;
                    }
                    tiers[n] = eqn33[x, y, 0] + "-" + eqn33[x, y, 1] + "-" + eqn33[x, y, 2] + "-" + eqn33[x, y, 3];
                    List <float> temp = new List <float> {
                        eqn33[x, y, 0], eqn33[x, y, 1], eqn33[x, y, 2], eqn33[x, y, 3]
                    };
                    temp.Sort();
                    tier[n] = temp[0] + "-" + temp[1] + "-" + temp[2] + "-" + temp[3];
                    n       = n + 1;
                }
            }

            for (int i = 0; i < 16; i++)
            {
                ans = isArranged(tiers[i], tier[i]);
                if (ans == true)
                {
                    status          = true;
                    err4.Visibility = Visibility.Visible;
                    err4.Foreground = Brushes.Green;
                    err4.Content    = "Inputs are Ok.";
                }
                else if (ans == false)
                {
                    status          = false;
                    err4.Visibility = Visibility.Visible;
                    err4.Foreground = Brushes.Red;
                    err4.Content    = "Inputs are not Ok.";
                    break;
                }
            }

            if (status == true)
            {
                // Assigning the
                float[,,] eqn_33 =
                {
                    //row 1
                    { { eqn33[0, 0, 0], eqn33[0, 0, 1], eqn33[0, 0, 2], eqn33[0, 0, 3], 0 },
                            { eqn33[0, 1, 0], eqn33[0, 1, 1], eqn33[0, 1, 2], eqn33[0, 1, 3], 0 },
                            { eqn33[0, 2, 0], eqn33[0, 2, 1], eqn33[0, 2, 2], eqn33[0, 2, 3], 0 },
                            { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0,     0 },
                            { eqn33[0, 3, 0], eqn33[0, 3, 1], eqn33[0, 3, 2], eqn33[0, 3, 3], 0 } },
                    //row 2
                    { { eqn33[1, 0, 0], eqn33[1, 0, 1], eqn33[1, 0, 2], eqn33[1, 0, 3], 0 },
                            { eqn33[1, 1, 0], eqn33[1, 1, 1], eqn33[1, 1, 2], eqn33[1, 1, 3], 0 },
                            { eqn33[1, 2, 0], eqn33[1, 2, 1], eqn33[1, 2, 2], eqn33[1, 2, 3], 0 },
                            { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0,     0 },
                            { eqn33[1, 3, 0], eqn33[1, 3, 1], eqn33[1, 3, 2], eqn33[1, 3, 3], 0 } },
                    //row 3
                    { { eqn33[2, 0, 0], eqn33[2, 0, 1], eqn33[2, 0, 2], eqn33[2, 0, 3], 0 },
                            { eqn33[2, 1, 0], eqn33[2, 1, 1], eqn33[2, 1, 2], eqn33[2, 1, 3], 0 },
                            { eqn33[2, 2, 0], eqn33[2, 2, 1], eqn33[2, 2, 2], eqn33[2, 2, 3], 0 },
                            { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0,     0 },
                            { eqn33[2, 3, 0], eqn33[2, 3, 1], eqn33[2, 3, 2], eqn33[2, 3, 3], 0 } },
                    //z-row
                    { { eqn33[3, 0, 0], eqn33[3, 0, 1], eqn33[3, 0, 2], eqn33[3, 0, 3], 0 },
                            { eqn33[3, 1, 0], eqn33[3, 1, 1], eqn33[3, 1, 2], eqn33[3, 1, 3], 0 },
                            { eqn33[3, 2, 0], eqn33[3, 2, 1], eqn33[3, 2, 2], eqn33[3, 2, 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();
                tableau4 tb33 = new tableau4(eqn_33, type, cons, vars, side4);
                tb33.toCompForm();
                tb33.rank();
                //gives optimal the value of the isOptimal method of the current tableau
                optimal = tb33.isOptimal();
                for (int i = 0; optimal == false; i++)
                {
                    if (tb33.isOptimal())
                    {
                        //stop
                        tab4            = tb33.tab;
                        pref.Visibility = Visibility.Collapsed;
                        comm.Visibility = Visibility.Collapsed;
                        page.draw4(tab4, "Tableau " + (i + 1), "Tableau is Optimal", 0, side4);
                        optimal = true;
                        page.statement("Z* = " + tab4[3, 6, 0] + " , " + tab4[3, 6, 1] + " , " + tab4[3, 6, 2] + " , " + tab4[3, 6, 3] + " | " + tab4[3, 6, 4] + "\n" +
                                       side4[0] + "* = " + tab4[0, 6, 0] + " , " + tab4[0, 6, 1] + " , " + tab4[0, 6, 2] + " , " + tab4[0, 6, 3] + " | " + tab4[0, 6, 4] + " , " +
                                       side4[1] + "* = " + tab4[1, 6, 0] + " , " + tab4[1, 6, 1] + " , " + tab4[1, 6, 2] + " , " + tab4[1, 6, 3] + " | " + tab4[1, 6, 4] + " , " +
                                       side4[2] + "* = " + tab4[2, 6, 0] + " , " + tab4[2, 6, 1] + " , " + tab4[2, 6, 2] + " , " + tab4[2, 6, 3] + " | " + tab4[2, 6, 4]);
                        break;
                    }
                    else
                    {
                        tab4 = tb33.tab;
                        pc   = tb33.getPC();
                        pr   = tb33.getPR(pc);
                        float pe  = tb33.getPE(pc, pr);
                        int   pos = getPeNum4(pr, pc);
                        pref.Visibility = Visibility.Collapsed;
                        comm.Visibility = Visibility.Collapsed;
                        side4           = tb33.side;
                        page.draw4(tab4, "Tableau " + (i + 1), "Tableau is not Optimal", pos, side4);
                        tb33    = fuzzy4(tb33, type, cons, vars, tab4);
                        optimal = false;
                        offset  = page.off;
                    }
                }
            }
        }