Ejemplo n.º 1
0
        public void SetExpressions()
        {
            for (int i = 1; i <= 6; i++)
            {
                int y = i;
                P20A.SetExpr(y, () => Projects.Sum(x => x.P20A[y]));
                P20B.SetExpr(y, () => Projects.Sum(x => x.P20B[y]));
                P20C.SetExpr(y, () => Projects.Sum(x => x.P20C[y]));
                P20D.SetExpr(y, () => Projects.Sum(x => x.P20D[y]));
                P20E.SetExpr(y, () => Projects.Sum(x => x.P20E[y]));
                P20F.SetExpr(y, () => Projects.Sum(x => x.P20F[y]));
                P22A.SetExpr(y, () => Projects.Sum(x => x.P22A[y]));

                var city = DocumentManager.CurrentDocument.City;
                C8A.SetExpr(y, () => city.C8A[y]);
                C8B.SetExpr(y, () => city.C8B[y]);
                C8C_1.SetExpr(y, () => city.C8C[y] * city.C14A);
                C8D.SetExpr(y, () => city.C8D[y]);
                C7C.SetExpr(y, () => city.C7C[y]);
                C8E.SetExpr(y, () => city.C8E[y]);
            }
            P20G = new YearwiseSum(P20A, P20B, P20C, P20D, P20E, P20F);
        }
        public void SetExpressions()
        {
            P2F = new YearwiseSum(P02 + 10, 10, P2A, P2B, P2C, P2D, P2E);
            P3T = new YearwiseSum(P02 + 10, 10, P3A, P3B, P3C, P3D, P3E);
            for (int i = 1; i <= 10; i++) // mod 20120206
            {
                int year = i;
                P3F.SetExpr(year, () => P2F[year] - P3T[year]);
            }
            P5A = new DoubleExpression(() => P3D.KnownYearsSum);
            P5C = new DoubleExpression(() => DocumentManager.CurrentDocument.City.C10B);
            P5D = new DoubleExpression(() => DocumentManager.CurrentDocument.City.C10A);

            P6A = new DoubleExpression(() => P3E.KnownYearsSum);
            P6C = new DoubleExpression(() => DocumentManager.CurrentDocument.City.C11B);
            P6D = new DoubleExpression(() => DocumentManager.CurrentDocument.City.C11A);

            P7E = new DoubleExpression(() => P7A + P7B + P7C + P7D);
            for (int i = 2; i <= 10; i++)
            {
                int year = P02 + i;

                P14A.SetExprA(year, () =>
                {
                    if (year >= P5B + P5C.GetValue() || year < P5B)
                    {
                        return(0);
                    }
                    else
                    {
                        if (year == P5B)
                        {
                            return(P5A.GetValue());
                        }
                        else
                        {
                            return(P14A[year - 1]);
                        }
                    }
                });

                P14B.SetExprA(year, () =>
                {
                    if (P14A[year] == 0 || year - P02 <= 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return(P14A[year] - Enumerable.Range(P02 + 1, year - P02).Sum(x => P14D[x]));
                    }
                });

                P14C.SetExprA(year, () => (P14B[year - 1] + P14B[year]) / 2 * P5D.GetValue());
                P14D.SetExprA(year, () => P14A[year] / P5C.GetValue());
            }
            for (int i = 2; i <= 10; i++)
            {
                int year = P02 + i;

                P15A.SetExprA(year, () =>
                {
                    if (year >= P6B + P6C.GetValue() || year < P6B)
                    {
                        return(0);
                    }
                    else
                    {
                        if (year == P6B)
                        {
                            return(P6A.GetValue());
                        }
                        else
                        {
                            return(P15A[year - 1]);
                        }
                    }
                });

                P15B.SetExprA(year, () =>
                {
                    if (P15A[year] == 0 || year - P02 <= 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return(P15A[year] - Enumerable.Range(P02 + 1, year - P02).Sum(x => P15D[x]));
                    }
                });

                P15C.SetExprA(year, () => (P15B[year - 1] + P15B[year]) / 2 * P6D.GetValue());
                P15D.SetExprA(year, () => P15A[year] / P6C.GetValue());
            }
            for (int i = 2; i <= 10; i++)
            {
                int year = P02 + i;
                P16A.SetExprA(year, () =>
                {
                    //if(year>P1G+DocumentManager.CurrentDocument.City.C12B)
                    //{

                    //}
                    return(0);
                });

                P16B.SetExprA(year, () => year > P1F_2 ? P7C : 0);
            }
            for (int i = 2; i <= 10; i++)
            {
                int year = P02 + i;
                P17A.SetExprA(year, () => year > P1F_2 ? P4A : 0);
                P17B.SetExprA(year, () => P14C[year] + P14D[year] + P15C[year] + P15D[year]);
            }
            P18_1F = new YearwiseSum(P02 + 8, 14, P18_1A, P18_1B, P18_1C, P18_1D, P18_1E);
            for (int i = -3; i <= 10; i++)
            {
                int year = i;
                P18_1A.SetExpr(year, () => DocumentManager.CurrentDocument.City.C6A[year]);
                P18_1B.SetExpr(year, () => DocumentManager.CurrentDocument.City.C6B[year]);
                P18_1C.SetExpr(year, () => DocumentManager.CurrentDocument.City.C6C[year]);
                P18_1D.SetExpr(year, () => DocumentManager.CurrentDocument.City.C6D[year]);
                P18_1E.SetExpr(year, () => DocumentManager.CurrentDocument.City.C6E[year]);
            }
            P18_2D = new YearwiseSum(P02 + 8, 14, P18_2A, P18_2B, P18_2C);
            for (int i = -3; i <= 10; i++)
            {
                int year = i;
                P18_2A.SetExpr(year, () => DocumentManager.CurrentDocument.City.C7A[year]);
                P18_2B.SetExpr(year, () => DocumentManager.CurrentDocument.City.C7B[year]);
                P18_2C.SetExpr(year, () => DocumentManager.CurrentDocument.City.C7C[year]);
            }
            for (int i = -3; i <= 10; i++)
            {
                int year = i;
                P18A.SetExpr(year, () => DocumentManager.CurrentDocument.City.C8A[year]);
                P18B.SetExpr(year, () => DocumentManager.CurrentDocument.City.C8B[year]);
                P18C.SetExpr(year, () => DocumentManager.CurrentDocument.City.C8C[year]);
                P18D.SetExpr(year, () => DocumentManager.CurrentDocument.City.C8D[year]);
                P18E.SetExpr(year, () => DocumentManager.CurrentDocument.City.C8E[year]);
            }
            P19_1F = new YearwiseSum(P02 + 8, 14, P19_1A, P19_1B, P19_1C, P19_1D, P19_1E);
            for (int i = -3; i <= 10; i++)
            {
                int year = i;
                P19_1A.SetExpr(year, () => P18_1A[year]);
                P19_1B.SetExpr(year, () => P18_1B[year]);
                P19_1C.SetExpr(year, () => P18_1C[year]);
                P19_1D.SetExpr(year, () => P18_1D[year]);
                P19_1E.SetExpr(year, () => P18_1E[year]);
            }
            P19_2D = new YearwiseSum(P02 + 8, 14, P19_2A, P19_2B, P19_2C);
            for (int i = -3; i <= 10; i++)
            {
                int year = i;
                P19_2A.SetExpr(year, () => P18_2A[year]);
                P19_2B.SetExpr(year, () => P18_2B[year]);
                P19_2C.SetExpr(year, () => P18_2C[year]);
            }
            for (int i = -3; i <= 10; i++)
            {
                int year = i;
                P19A.SetExpr(year, () => P19_1F[year] - P19_1D[year]);
                P19B.SetExpr(year, () => P19_2B[year] + P19_2C[year]);
                P19C.SetExpr(year, () => P19A[year] - P19B[year]);
                P19D.SetExpr(year, () => P19C[year] * DocumentManager.CurrentDocument.City.C14A);
            }
            P20G = new YearwiseSum(P02 + 9, 9, P20A, P20B, P20C, P20D, P20E, P20F);
            for (int i = 1; i <= 9; i++)
            {
                int year = i;
                P20A.SetExpr(year, () => NaNto0(P3A[year]));
                P20B.SetExpr(year, () => NaNto0(P3B[year]));
                P20C.SetExpr(year, () => NaNto0(P3C[year]));
                P20D.SetExpr(year, () => NaNto0(P3D[year]));
                P20E.SetExpr(year, () => NaNto0(P3E[year]));
                P20F.SetExpr(year, () => NaNto0(P3F[year]));
            }
            for (int i = 1; i <= 9; i++)
            {
                int year = i;
                P21A.SetExpr(year, () => P20A[year]);
                P21B.SetExpr(year, () => P18B[year + 1]);
                P21C.SetExpr(year, () => P18A[year + 1]);
            }
            for (int i = 1; i <= 9; i++)
            {
                int year = i;
                P22A.SetExpr(year, () => P17B[year + 1]);
                P22B.SetExpr(year, () => DocumentManager.CurrentDocument.City.C7C[year + 1]);
                P22C.SetExpr(year, () => P18E[year + 1]);
            }
        }
 public void SetExpressions()
 {
     C1F = new YearwiseSum(C02, 4, C1A, C1B, C1C, C1D, C1E);
     for (int i = 0; i < 3; i++)
     {
         int year = -i; // 循环变量复制后才能用于匿名函数
         C1G.SetExpr(year, () =>
         {
             return((C1A[year] - C1A[year - 1]) / C1A[year - 1]);
         });
         C1H.SetExpr(year, () => (C1B[year] - C1B[year - 1]) / C1B[year - 1]);
         C1I.SetExpr(year, () => (C1C[year] - C1C[year - 1]) / C1C[year - 1]);
     }
     C2D = new YearwiseSum(C02, 4, C2A, C2B, C2C);
     for (int i = 0; i < 3; i++)
     {
         int year = -i;
         C2C.SetExpr(year, () => C4D[year]); // mod 20120206
         C2E.SetExpr(year, () => (C2A[year] - C2A[year - 1]) / C2A[year - 1]);
         C2F.SetExpr(year, () => (C2B[year] - C2B[year - 1]) / C2B[year - 1]);
     }
     C2C.SetExpr(-3, () => C4D[-3]); // mod 20120206
     C3E = new YearwiseSum(C02, 4, C3A, C3B, C3C, C3D);
     C4D = new YearwiseSum(C02 + 10, 4, C4B, C4C);
     C6F = new YearwiseSum(C02, 4, C6A, C6B, C6C, C6D, C6E);
     for (int i = 0; i <= 3; i++)
     {
         int year = -i;
         C6A.SetExpr(year, () => C1A[year]);
         C6B.SetExpr(year, () => C1B[year]);
         C6C.SetExpr(year, () => C1C[year]);
         C6D.SetExpr(year, () => C1D[year]);
         C6E.SetExpr(year, () => C1E[year]);
     }
     for (int i = 1; i <= 10; i++)
     {
         if (i == 1)
         {
             int y = i;
             C6A.SetExpr(y, () => C6A[y - 1] + C6A[y - 1] * C1G.KnownYearsAverage);
             C6B.SetExpr(y, () => C6B[y - 1] + C6B[y - 1] * C1H.KnownYearsAverage);
             C6C.SetExpr(y, () => C6C[y - 1] + C6C[y - 1] * C1I.KnownYearsAverage);
             C6D.SetExpr(y, () => C1D.KnownYearsAverage);
             C6E.SetExpr(y, () => C1E[y - 1]);
         }
         else
         {
             int y = i;
             C6A.SetExpr(y, () => C6A[y - 1] * (1 + C9A[y] * C15A_1) * (1 + C9B[y] * C15A_2));
             C6B.SetExpr(y, () => C6B[y - 1] * (1 + C9A[y] * C15B_1) * (1 + C9B[y] * C15B_2));
             C6C.SetExpr(y, () => C6C[y - 1] * (1 + C9A[y] * C15C_1) * (1 + C9B[y] * C15C_2));
             C6D.SetExpr(y, () => C6D[y - 1] * (1 + C9A[y] * C15D_1) * (1 + C9B[y] * C15D_2));
             C6E.SetExpr(y, () => C6E[y - 1] * (1 + C9A[y] * C15E_1) * (1 + C9B[y] * C15E_2));
         }
     }
     C7D = new YearwiseSum(C02, 4, C7A, C7B, C7C);
     for (int i = 0; i <= 3; i++)
     {
         int year = -i;
         C7A.SetExpr(year, () => C2A[year]);
         C7B.SetExpr(year, () => C2B[year]);
         C7C.SetExpr(year, () => C2C[year]);
     }
     for (int i = 1; i <= 10; i++)
     {
         if (i == 1)
         {
             int y = i;
             C7A.SetExpr(y, () => C7A[y - 1] + C7A[y - 1] * C2E.KnownYearsAverage);
             C7B.SetExpr(y, () => C7B[y - 1] + C7B[y - 1] * C2F.KnownYearsAverage);
             C7C.SetExpr(y, () => C4D[y]);
         }
         else
         {
             int y = i;
             C7A.SetExpr(y, () => C7A[y - 1] * (1 + C9A[y] * C16A_1) * (1 + C9B[y] * C16A_2));
             C7B.SetExpr(y, () => C7B[y - 1] * (1 + C9A[y] * C16B_1) * (1 + C9B[y] * C16B_2));
             C7C.SetExpr(y, () => C4D[y]);
         }
     }
     for (int i = -3; i <= 10; i++)
     {
         int year = i;
         C8A.SetExpr(year, () =>
         {
             if (year > 0)
             {
                 return(C6F[year] - C6D[year]);
             }
             else
             {
                 return(C6F[year] - C6C[year]);
             }
         });
         C8B.SetExpr(year, () => C7B[year] + C7C[year]);
         C8C.SetExpr(year, () => C8A[year] - C8B[year]);
         C8D.SetExpr(year, () => C8C[year] * C14A);
         C8E.SetExpr(year, () => C8C[year] * C14B);
     }
 }