コード例 #1
0
        private void Make2()
        {
            MainForm.DebugForm.AddLine("KV: make2");

            // create instance of simplifier
            var s     = new Simplify();
            var value = new List <ValueDuo>();

            if (boxA1.Checked)
            {
                value.Add(new ValueDuo(1, 1));
            }
            if (boxA2.Checked)
            {
                value.Add(new ValueDuo(0, 1));
            }
            if (boxA3.Checked)
            {
                value.Add(new ValueDuo(1, 0));
            }
            if (boxA4.Checked)
            {
                value.Add(new ValueDuo(0, 0));
            }

            s.Add(value);
            s.SetMode(2);

            // Prepare the algorythm and run it!
            s.Simple(s.Prepare());

            var res = s.GetDuo();

            if (MainForm.OutputWindow.Visible)
            {
                MainForm.OutputWindow.Hide();
            }
            else
            {
                MainForm.OutputWindow = new OutputDnf();
                MainForm.OutputWindow.Activate();
                MainForm.OutputWindow.SetString(GetDuoString(res));
                MainForm.OutputWindow.Show();
            }
        }
コード例 #2
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (_checked)
            {
                // Debugging
                Console.WriteLine(@"Start simplifying");
                MainForm.DebugForm.AddLine("Start simplifying");

                // Get all rows
                var dgvr = dataGrid.Rows;

                // Debugging
                Console.WriteLine(@"Mode " + dataGrid.ColumnCount);
                MainForm.DebugForm.AddLine("Mode " + dataGrid.ColumnCount);

                // Create instance of Simplify.cs
                var simple = new Simplify();

                // 2 columns, use ValueDuo
                if (dataGrid.ColumnCount == 2)
                {
                    // as a result
                    var list = new List <ValueDuo>();

                    // Get row i
                    for (var i = 0; i < dgvr.Count - 1; i++)
                    {
                        int[] ba = { 0, 0 };
                        // Get cell j in row i
                        for (var j = 0; j < dgvr[i].Cells.Count; j++)
                        {
                            // check for 1 and 0 and put it into an bool-array
                            if (dgvr[i].Cells[j].Value.ToString() == "1")
                            {
                                ba[j] = 1;
                            }
                        }
                        // convert bool array to a ValueDuo and add it to Dictionary
                        var v = new ValueDuo(ba);
                        list.Add(v);
                    }
                    // put dictionary to instance simple of Simplify.cs
                    simple.Add(list); simple.SetMode(2);
                }

                // 3 columns, use ValueTrio
                if (dataGrid.ColumnCount == 3)
                {
                    // as a result
                    var list = new List <ValueTrio>();

                    // Get row i
                    for (var i = 0; i < dgvr.Count - 1; i++)
                    {
                        int[] ba = { 0, 0, 0 };
                        // Get cell j in row i
                        for (var j = 0; j < dgvr[i].Cells.Count; j++)
                        {
                            // check for 1 and 0 and put it into an bool-array
                            if (dgvr[i].Cells[j].Value.ToString() == "1")
                            {
                                ba[j] = 1;
                            }
                        }
                        // convert bool array to a ValueDuo and add it to Dictionary
                        var v = new ValueTrio(ba);
                        list.Add(v);
                    }
                    // put dictionary to instance simple of Simplify.cs
                    simple.Add(list); simple.SetMode(3);
                }

                // 4 columns, use ValueQuartett
                if (dataGrid.ColumnCount == 4)
                {
                    // as a result
                    var list = new List <ValueQuartett>();

                    // Get row i
                    for (var i = 0; i < dgvr.Count - 1; i++)
                    {
                        int[] ba = { 0, 0, 0, 0 };
                        // Get cell j in row i
                        for (var j = 0; j < dgvr[i].Cells.Count; j++)
                        {
                            // check for 1 and 0 and put it into an bool-array
                            if (dgvr[i].Cells[j].Value.ToString() == "1")
                            {
                                ba[j] = 1;
                            }
                        }
                        // convert bool array to a ValueDuo and add it to Dictionary
                        var v = new ValueQuartett(ba);
                        list.Add(v);
                    }
                    // put dictionary to instance simple of Simplify.cs
                    simple.Add(list); simple.SetMode(4);
                }

                // 5 columns, use ValueQuintett
                if (dataGrid.ColumnCount == 5)
                {
                    // as a result
                    var list = new List <ValueQuintett>();

                    // Get row i
                    for (var i = 0; i < dgvr.Count - 1; i++)
                    {
                        int[] ba = { 0, 0, 0, 0, 0 };
                        // Get cell j in row i
                        for (var j = 0; j < dgvr[i].Cells.Count; j++)
                        {
                            // check for 1 and 0 and put it into an bool-array
                            if (dgvr[i].Cells[j].Value.ToString() == "1")
                            {
                                ba[j] = 1;
                            }
                        }
                        // convert bool array to a ValueDuo and add it to Dictionary
                        var v = new ValueQuintett(ba);
                        list.Add(v);
                    }
                    // put dictionary to instance simple of Simplify.cs
                    simple.Add(list); simple.SetMode(5);
                }

                // 6 columns, use ValueSextett
                if (dataGrid.ColumnCount == 6)
                {
                    // as a result
                    var list = new List <ValueSextett>();

                    // Get row i
                    for (var i = 0; i < dgvr.Count - 1; i++)
                    {
                        int[] ba = { 0, 0, 0, 0, 0, 0 };
                        // Get cell j in row i
                        for (var j = 0; j < dgvr[i].Cells.Count; j++)
                        {
                            // check for 1 and 0 and put it into an bool-array
                            if (dgvr[i].Cells[j].Value.ToString() == "1")
                            {
                                ba[j] = 1;
                            }
                        }
                        // convert bool array to a ValueDuo and add it to Dictionary
                        var v = new ValueSextett(ba);
                        list.Add(v);
                    }
                    // put dictionary to instance simple of Simplify.cs
                    simple.Add(list); simple.SetMode(6);
                }

                // Prepare the algorythm and run it!
                simple.Simple(simple.Prepare());

                if (MainForm.OutputWindow.Visible)
                {
                    MainForm.OutputWindow.Hide();
                }
                else
                {
                    MainForm.OutputWindow = new OutputDnf();
                    MainForm.OutputWindow.Activate();

                    if (dataGrid.ColumnCount == 2)
                    {
                        MainForm.OutputWindow.SetString(GetDuoString(simple.GetDuo()));
                    }
                    if (dataGrid.ColumnCount == 3)
                    {
                        MainForm.OutputWindow.SetString(GetTrioString(simple.GetTrio()));
                    }
                    if (dataGrid.ColumnCount == 4)
                    {
                        MainForm.OutputWindow.SetString(GetQuartettString(simple.GetQuartett()));
                    }

                    MainForm.OutputWindow.Show();
                }
            }
            else
            {
                // If no error
                labelProblem.Text      = @"Check first.";
                labelProblem.ForeColor = Color.Red;
            }
        }
コード例 #3
0
        private void Make4()
        {
            MainForm.DebugForm.AddLine("KV: make4");

            // create instance of simplifier
            var s     = new Simplify();
            var value = new List <ValueQuartett>();

            if (boxC1.Checked)
            {
                value.Add(new ValueQuartett(1, 1, 1, 1));
            }
            if (boxC2.Checked)
            {
                value.Add(new ValueQuartett(1, 1, 0, 1));
            }
            if (boxC3.Checked)
            {
                value.Add(new ValueQuartett(0, 1, 0, 1));
            }
            if (boxC4.Checked)
            {
                value.Add(new ValueQuartett(0, 1, 1, 1));
            }
            if (boxC5.Checked)
            {
                value.Add(new ValueQuartett(1, 1, 1, 0));
            }
            if (boxC6.Checked)
            {
                value.Add(new ValueQuartett(1, 1, 0, 0));
            }
            if (boxC7.Checked)
            {
                value.Add(new ValueQuartett(0, 1, 0, 0));
            }
            if (boxC8.Checked)
            {
                value.Add(new ValueQuartett(0, 1, 1, 0));
            }
            if (boxC9.Checked)
            {
                value.Add(new ValueQuartett(1, 0, 1, 0));
            }
            if (boxC10.Checked)
            {
                value.Add(new ValueQuartett(1, 0, 0, 0));
            }
            if (boxC11.Checked)
            {
                value.Add(new ValueQuartett(0, 0, 0, 0));
            }
            if (boxC12.Checked)
            {
                value.Add(new ValueQuartett(0, 0, 1, 0));
            }
            if (boxC13.Checked)
            {
                value.Add(new ValueQuartett(1, 0, 1, 1));
            }
            if (boxC14.Checked)
            {
                value.Add(new ValueQuartett(1, 0, 0, 1));
            }
            if (boxC15.Checked)
            {
                value.Add(new ValueQuartett(0, 0, 0, 1));
            }
            if (boxC16.Checked)
            {
                value.Add(new ValueQuartett(0, 0, 1, 1));
            }

            s.Add(value);
            s.SetMode(4);

            // Prepare the algorythm and run it!
            s.Simple(s.Prepare());

            var res = s.GetQuartett();

            if (MainForm.OutputWindow.Visible)
            {
                MainForm.OutputWindow.Hide();
            }
            else
            {
                MainForm.OutputWindow = new OutputDnf();
                MainForm.OutputWindow.Activate();
                MainForm.OutputWindow.SetString(GetQuartettString(res));
                MainForm.OutputWindow.Show();
            }
        }