Example #1
0
        private void IsNonnegative()
        {
            double det;

            GaussJordanElimination.gaussJordanDet(c, out det);
            if (det <= 0.0)
            {
                throw new System.Exception("Macierz C nie jest nieujemnie określona!!!");
            }
            for (int i = 0; i < (int)Math.Sqrt(c.Length); i++)
            {
                if (c[i, i] <= 0.0)
                {
                    throw new System.Exception("Macierz C nie jest nieujemnie określona!!!");
                }
            }
        }
Example #2
0
 public Data(ref BoundaryList bl, ref ElementList el, ref BoundaryNodeList bnl, ref InternalPointList ipl, ref double[,] Garr,
             ref double[,] Harr, ref double[,] A1arr, ref double[,] A2arr, ref double[] Farr, ref double[] Yarr, ref double[] Xarr)
 {
     this.boundaryList = bl;
     this.elementList  = el;
     this.bNodeList    = bnl;
     this.iPointList   = ipl;
     this.g            = Garr;
     this.h            = Harr;
     this.a1           = A1arr;
     this.a2           = A2arr;
     this.f            = Farr;
     this.y            = Yarr;
     this.x            = Xarr;
     if (!GaussJordanElimination.gaussJordanElimination(A1, out this.b))
     {
         throw new System.Exception("Macierz A1 jest nieodwracalna!!!");
     }
     else
     {
         u = AuxiliaryFunctions.MMMultiplication(ref b, ref a2, (int)Math.Sqrt(b.Length), (int)Math.Sqrt(b.Length));
     }
 }
Example #3
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);
        }