Пример #1
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            Display_form primalmat = new Display_form(); //the new form
            String       type      = cbType.SelectedItem.ToString();
            int          con       = Convert.ToInt16(cbCon.SelectedItem.ToString());
            int          dec       = Convert.ToInt16(cbDec.SelectedItem.ToString());

            primalmat.setMatrix(con, dec, type);
            primalmat.ShowDialog();
        }
Пример #2
0
        private void BtnSolve_Click(object sender, EventArgs e)
        {
            Display_form dualmat = new Display_form(); //rhe dual matrix form

            if (lblType.Text.Equals("Min"))
            {
                dualmat.setMatrix(matDec, matCon, "Max");
            }
            if (lblType.Text.Equals("Max"))
            {
                dualmat.setMatrix(matDec, matCon, "Min");
            }

            for (int i = 0; i < matCon; i++)
            {
                for (int j = 0; j < matDec; j++)
                {
                    dualmat.eqCon[j].Text       = this.LP[j].Text;
                    dualmat.LP[i].Text          = this.eqCon[i].Text;
                    dualmat.txtArray[j, i].Text = this.txtArray[i, j].Text;
                }
            }

            for (int i = 0; i < matCon; i++)
            {
                if (this.cbConBoxes[i].Text.Equals("≥") && lblType.Text.Equals("Min"))    //sets the signs for dual's decision var constraints as the signs of the regular constraints of primal, transposed
                {
                    dualmat.cbDecBoxes[i].Text = "≥";
                }
                if (this.cbConBoxes[i].Text.Equals("≤") && lblType.Text.Equals("Min"))
                {
                    dualmat.cbDecBoxes[i].Text = "≤";
                }
                if (this.cbConBoxes[i].Text.Equals("≥") && lblType.Text.Equals("Max"))
                {
                    dualmat.cbDecBoxes[i].Text = "≤";
                }
                if (this.cbConBoxes[i].Text.Equals("≤") && lblType.Text.Equals("Max"))
                {
                    dualmat.cbDecBoxes[i].Text = "≥";
                }
                if (this.cbConBoxes[i].Text.Equals("="))
                {
                    dualmat.cbDecBoxes[i].Text = "urs";
                }
                //dualMatrix.ObjFunc.coefficients[i] = primalMatrix.Constraints[i].value;

                //  dualmat.cbDecBoxes[i].Text = this.cbConBoxes[i].Text;
            }

            for (int i = 0; i < matDec; i++)
            {
                if (this.cbDecBoxes[i].Text.Equals("≥") && lblType.Text.Equals("Max")) //sets signs and values of dual constraints to the appropriate one based on priml decision constraints
                {
                    dualmat.cbConBoxes[i].Text = "≥";
                }
                if (this.cbDecBoxes[i].Text.Equals("≥") && lblType.Text.Equals("Min"))
                {
                    dualmat.cbConBoxes[i].Text = "≤";
                }
                if (this.cbDecBoxes[i].Text.Equals("≤") && lblType.Text.Equals("Max"))
                {
                    dualmat.cbConBoxes[i].Text = "≤";
                }
                if (this.cbDecBoxes[i].Text.Equals("≤") && lblType.Text.Equals("Min"))
                {
                    dualmat.cbConBoxes[i].Text = "≥";
                }
                if (this.cbDecBoxes[i].Text.Equals("urs"))
                {
                    dualmat.cbConBoxes[i].Text = "=";
                }

                // dualmat.cbConBoxes[i].Text = this.cbDecBoxes[i].Text;
            }

            if (this.Text.Equals("Primal"))
            {
                dualmat.Text = "Dual";
            }
            else
            {
                dualmat.Text = "Primal";
            }
            dualmat.ShowDialog();
        }