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)); } }
public BoundaryNodeList(BoundaryList boundaryList) // Konstruktor { switch (BoundaryElement.ElemType) { case "Constant": { int ctr = 0; foreach (Boundary boundary in boundaryList) { ctr += boundary.Count; } nList = new BoundaryNode[ctr]; ctr = 0; foreach (Boundary boundary in boundaryList) { foreach (BoundaryElement bElement in boundary) { nList[ctr] = new BoundaryNode(bElement, bElement.Node[0], 1, ctr++); } } break; } case "Linear": { int R = 0; foreach (Boundary boundary in boundaryList) { if ((!AuxiliaryFunctions.Parallelism(boundary[0], boundary[boundary.Count - 1])) && (boundary[0].BC != boundary[boundary.Count - 1].BC)) { R += 2; } else { R++; } for (int i = 1; i < boundary.Count; i++) { if ((!AuxiliaryFunctions.Parallelism(boundary[i], boundary[i - 1])) && (boundary[i].BC != boundary[i - 1].BC)) { R += 2; } else { R++; } } } nList = new BoundaryNode[R]; int ctr = 0; foreach (Boundary boundary in boundaryList) { bool isFirstDouble = false; if ((!AuxiliaryFunctions.Parallelism(boundary[0], boundary[boundary.Count - 1])) && (boundary[0].BC != boundary[boundary.Count - 1].BC)) { nList[ctr] = new BoundaryNode(boundary[0], boundary[0].XP, 2, ctr); isFirstDouble = true; } else { nList[ctr] = new BoundaryNode(boundary[0], boundary[0].XP, 1, ctr); } ctr++; for (int i = 1; i < boundary.Count; i++) { if ((!AuxiliaryFunctions.Parallelism(boundary[i], boundary[i - 1])) && (boundary[i].BC != boundary[i - 1].BC)) { nList[ctr] = new BoundaryNode(boundary[i - 1], boundary[i - 1].XK, 2, ctr); ctr++; nList[ctr] = new BoundaryNode(boundary[i], boundary[i].XP, 2, ctr); } else { nList[ctr] = new BoundaryNode(boundary[i], boundary[i].XP, 1, ctr); } ctr++; } if (isFirstDouble) { nList[ctr++] = new BoundaryNode(boundary[boundary.Count - 1], boundary[boundary.Count - 1].XK, 2, ctr - 1); } } break; } case "Parabolic": { int R = 0; foreach (Boundary boundary in boundaryList) { if ((!AuxiliaryFunctions.Parallelism(boundary[0], boundary[boundary.Count - 1])) && (boundary[0].BC != boundary[boundary.Count - 1].BC)) { R += 2; } else { R++; } R++; for (int i = 1; i < boundary.Count; i++) { if ((!AuxiliaryFunctions.Parallelism(boundary[i], boundary[i - 1])) && (boundary[i].BC != boundary[i - 1].BC)) { R += 2; } else { R++; } R++; } } nList = new BoundaryNode[R]; int ctr = 0; foreach (Boundary boundary in boundaryList) { bool isFirstDouble = false; if ((!AuxiliaryFunctions.Parallelism(boundary[0], boundary[boundary.Count - 1])) && (boundary[0].BC != boundary[boundary.Count - 1].BC)) { nList[ctr] = new BoundaryNode(boundary[0], boundary[0].XP, 2, ctr); isFirstDouble = true; } else { nList[ctr] = new BoundaryNode(boundary[0], boundary[0].XP, 1, ctr); } ctr++; nList[ctr] = new BoundaryNode(boundary[0], boundary[0].Node[1], 3, ctr); ctr++; for (int i = 1; i < boundary.Count; i++) { if ((!AuxiliaryFunctions.Parallelism(boundary[i], boundary[i - 1])) && (boundary[i].BC != boundary[i - 1].BC)) { nList[ctr] = new BoundaryNode(boundary[i - 1], boundary[i - 1].XK, 2, ctr); ctr++; nList[ctr] = new BoundaryNode(boundary[i], boundary[i].XP, 2, ctr); } else { nList[ctr] = new BoundaryNode(boundary[i], boundary[i].XP, 1, ctr); } ctr++; nList[ctr] = new BoundaryNode(boundary[i], boundary[i].Node[1], 3, ctr); ctr++; } if (isFirstDouble) { nList[ctr++] = new BoundaryNode(boundary[boundary.Count - 1], boundary[boundary.Count - 1].XK, 2, ctr - 1); } } break; } default: throw new System.Exception("Niepoprawny rodzaj elementu w konstruktorze NodeList!!!"); } }
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); }