Exemple #1
0
Fichier : BEW.cs Projet : b1es/BEW
 private void buttonMEBevolution_Click(object sender, EventArgs e)
 {
     this.toolStripProgressBar1.Step = 10;
     this.toolStripProgressBar1.PerformStep();
     constValue.dataMEB        = null;
     BoundaryElement.Instances = 0;
     this.richTextBox2.Text    = null;
     MEB.nb = int.Parse(this.comboBoxMEBnb.Text); // Ilość punktów Gaussa elementy brzegowe
     if (this.textBoxMEBlambda.Text.IndexOf(".") >= 0)
     {
         this.textBoxMEBlambda.Text = this.textBoxMEBlambda.Text.Replace(".", ",");
     }
     MEB.lam = double.Parse(this.textBoxMEBlambda.Text);
     BoundaryElement.ElemType = this.comboBoxMEBelemType.Text;
     constValue.dataMEB       = MEB.EvaluationMEB();
     if (constValue.MEBiternalPointList.Count > 0)
     {
         constValue.MEBiternalPointList.InternalTemperaturs(MEB.nb,
                                                            constValue.dataMEB.ElementList,
                                                            constValue.dataMEB.BoundaryNodeList,
                                                            MEB.lam);
         constValue.dataMEB.IntenralPointList = constValue.MEBiternalPointList;
         this.buttonMEBtextIntTemp.Enabled    = true;
     }
     this.toolStripProgressBar1.Step = 100;
     this.toolStripProgressBar1.PerformStep();
     this.richTextBox2.Text            += "Rozwiązanie końcowe:\n" + constValue.dataMEB.BoundaryNodeList.ToString();
     this.toolStripProgressBar1.Value   = 0;
     this.buttonMEBintTemp.Enabled      = true;
     this.labelMEBx2.Enabled            = true;
     this.textBoxMEBx2.Enabled          = true;
     this.labelMEBx1.Enabled            = true;
     this.textBoxMEBx1.Enabled          = true;
     this.labelMEBintTem.Enabled        = true;
     this.buttonMEBtextSolution.Enabled = true;
     this.button_MEBTable.Enabled       = true;
     this.button_MEBMakeTask.Enabled    = true;
 }
Exemple #2
0
        public static Data EvaluationMME()
        {
            // Utworzenie obiektu data
            Data data = new Data();

            BoundaryList boundaryList = new BoundaryList();

            Reader.GetGeometry(@path, ref boundaryList);                       // Odczytywanie listy elementów brzegowych
            Reader.GetBoundaryConditionsMME(@path, ref boundaryList);          // Odczytywanie warunków brzegowych
            BoundaryNodeList bNodeList   = new BoundaryNodeList(boundaryList); // Utworzenie listy węzłów brzegowych
            ElementList      elementList = new ElementList(boundaryList);      // Utworzenie listy elementów brzegowych

            InternalPointList iPointList = constValue.MMEiternalPointList;
            BoundaryNodeList  nodeList   = new BoundaryNodeList(iPointList);        // Wyznaczanie listy węzłów dla elementów brzegowych

            double[,] G = Matrixs.GMatrix(nb, ref elementList, ref bNodeList, lam); // Wycznaczenie macierzy G
            double[,] H = Matrixs.HMatrix(nb, ref elementList, ref bNodeList);      // Wycznaczenie macierzy H
            double[,] B;

            double[,] A1 = Matrixs.A1MatrixMME(ref G, ref H, ref bNodeList);    // Wycznaczenie macierzy A1
            if (!GaussJordanElimination.gaussJordanElimination(A1, out B))
            {
                data.Error = "Macierz A1 jest nieodwracalna.\n\n"
                             + AuxiliaryFunctions.PrintArray(A1, (int)Math.Sqrt(A1.Length), (int)Math.Sqrt(A1.Length));
                data.binarySerialize(); // Zapis obiektu data do pliku binarnego
                return(data);
            }

            double[,] A2 = Matrixs.A2MatrixMME(ref G, ref H, ref bNodeList);    // Wycznaczenie macierzy A2

            double[,] Hw;
            double[,] Gw;
            if (BoundaryElement.ElemType == "Constant")
            {
                Hw = Matrixs.HdMatrix(nb, ref elementList, ref nodeList);
                Gw = Matrixs.GdMatrix(nb, ref elementList, ref nodeList, lam);
            }
            else
            {
                Hw = Matrixs.HMatrixForInternalPoints(nb, ref elementList, ref nodeList, ref bNodeList);
                Gw = Matrixs.GMatrixForInternalPoints(nb, ref elementList, ref nodeList, ref bNodeList, lam);
            }
            data.BoundaryList      = boundaryList;
            data.ElementList       = elementList;
            data.BoundaryNodeList  = bNodeList;
            data.IntenralPointList = iPointList;
            data.G   = G;
            data.Gw  = Gw;
            data.H   = H;
            data.Hw  = Hw;
            data.A1  = A1;
            data.B   = B;
            data.A2  = A2;
            data.R   = Matrixs.RMatrix(Gw, Hw, data.B, data.BoundaryNodeList, data.IntenralPointList);
            data.Dw  = Matrixs.DwMatrix(Gw, Hw, data.U, data.BoundaryNodeList, data.IntenralPointList);
            data.Dw1 = Matrixs.Dw1Matrix(Gw, Hw, data.BoundaryNodeList, data.IntenralPointList);
            data.W   = Matrixs.WMatrix(data.Hw, data.Gw, data.U, data.BoundaryNodeList, data.IntenralPointList);
            data.P   = Matrixs.PMatrix(data.BoundaryNodeList);
            data.E   = Matrixs.EMatrix(Gw, Hw, data.P, data.BoundaryNodeList, data.IntenralPointList);
            data.Z   = Matrixs.ZMatrix(data.Dw, data.P, data.E, data.BoundaryNodeList, data.IntenralPointList);
            data.Fd  = Matrixs.FdMatrix(data.Z, data.IntenralPointList);
            //double[] fff = { 11.327, 21.561, 25, 21.561, 11.327 };
            //data.Fd = fff;
            data.J  = Matrixs.JMatrix(data.BoundaryNodeList);
            data.S  = Matrixs.SMatrix(data.U, data.P, data.BoundaryNodeList);
            data.Pd = Matrixs.PdMatrix(data.U, data.J, data.S, data.BoundaryNodeList);
            data.C  = Matrixs.CMatrix(data.U, data.BoundaryNodeList);

            // WOLFE
            int n = (int)Math.Sqrt(data.C.Length);  // Ilość zmiennych decyzyjnych
            int m = (int)((data.W.Length / n) * 2); // Ilość ograniczeń

            double[,] A = new double[m, n];
            double[] b = new double[m];
            double[,] C;
            double[] p;
            if (precision == -1)
            {
                for (int i = 0; i < m / 2; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        A[i, j] = data.W[i, j];
                    }
                    b[i] = data.Fd[i] + epsilon;
                }
                for (int i = 0; i < m / 2; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        A[i + m / 2, j] = -data.W[i, j];
                    }
                    b[i + m / 2] = epsilon - data.Fd[i];
                }
                C = new double[n, n];
                p = new double[n];
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        C[i, j] = data.C[i, j];
                    }
                    p[i] = data.Pd[i];
                }
            }
            else
            {
                for (int i = 0; i < m / 2; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        A[i, j] = Math.Round(data.W[i, j], precision);
                    }
                    b[i] = Math.Round(data.Fd[i] + epsilon, precision);
                }
                for (int i = 0; i < m / 2; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        A[i + m / 2, j] = Math.Round(-data.W[i, j], precision);
                    }
                    b[i + m / 2] = Math.Round(epsilon - data.Fd[i], precision);
                }
                C = new double[n, n];
                p = new double[n];
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        C[i, j] = Math.Round(data.C[i, j], precision);
                    }
                    p[i] = Math.Round(data.Pd[i], precision);
                }
            }
            InitialTask    iTask = new InitialTask(n, m, C, p, A, b);
            SubstituteTask sTask = new SubstituteTask(iTask);
            Wolfe          wolfe = new Wolfe(sTask);

            wolfe.Evaluation();
            data.Error = wolfe.Error;
            if (data.Error == null)
            {
                AssignSolution(wolfe, ref data);
                MEB.EvaluationMEB(data);
            }
            // wolfe

            data.binarySerialize(); // Zapis obiektu data do pliku binarnego
            return(data);
        }