public IEBSResultElement Calculate(
            IEBSResultElementFactory EBSResultElementFactory,
            IdIndexElement dIndexElement,
            Iw w,
            IBEDS BEDS,
            Iμ μ,
            IVariance Variance)
        {
            int BEDS_d = BEDS.Value.Value.Value;

            double ExpectedValue_d = w.Value
                                     .Select(y => (double)μ.GetElementAtAsdecimal(
                                                 y,
                                                 dIndexElement))
                                     .Sum();

            double Variance_d = w.Value
                                .Select(y => (double)Variance.GetElementAtAsdecimal(
                                            y,
                                            dIndexElement))
                                .Sum();

            double lowerBound = BEDS_d + 0.5;

            double upperBound = double.PositiveInfinity;

            double value =
                0.5
                *
                (BEDS_d - ExpectedValue_d)
                *
                (MathNet.Numerics.SpecialFunctions.Erf(
                     (lowerBound - ExpectedValue_d)
                     *
                     Math.Pow(Math.Sqrt(2 * Variance_d), -1))
                 -
                 MathNet.Numerics.SpecialFunctions.Erf(
                     (upperBound - ExpectedValue_d)
                     *
                     Math.Pow(Math.Sqrt(2 * Variance_d), -1)))
                +
                Math.Sqrt(Variance_d)
                *
                Math.Pow(Math.Sqrt(2 * Math.PI), -1)
                *
                (Math.Exp(
                     -Math.Pow(lowerBound - ExpectedValue_d, 2)
                     *
                     Math.Pow(2 * Variance_d, -1))
                 -
                 Math.Exp(
                     -Math.Pow(upperBound - ExpectedValue_d, 2)
                     *
                     Math.Pow(2 * Variance_d, -1)));

            return(EBSResultElementFactory.Create(
                       dIndexElement,
                       (decimal)value));
        }
Ejemplo n.º 2
0
        public Constraint2(
            Iw w,
            IBEDS BEDS,
            ISPy y)
        {
            Expression LHS = Expression.Sum(
                w.Value
                .Select(
                    i => y.Value[i]));

            int RHS = BEDS.Value.Value.Value;

            this.Value = LHS <= RHS;
        }
Ejemplo n.º 3
0
        public IBEDS Create(
            PositiveInt value)
        {
            IBEDS parameter = null;

            try
            {
                parameter = new BEDS(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(parameter);
        }
Ejemplo n.º 4
0
 public IEBS Calculate(
     IEBSResultElementFactory EBSResultElementFactory,
     IEBSFactory EBSFactory,
     IEBSResultElementCalculation EBSResultElementCalculation,
     Id d,
     Iw w,
     IBEDS BEDS,
     Iμ μ,
     IVariance Variance)
 {
     return(EBSFactory.Create(
                d.Value
                .Select(y => EBSResultElementCalculation.Calculate(
                            EBSResultElementFactory,
                            y,
                            w,
                            BEDS,
                            μ,
                            Variance))
                .ToImmutableList()));
 }
Ejemplo n.º 5
0
        public IConstraint2 Create(
            Iw w,
            IBEDS BEDS,
            ITPy y)
        {
            IConstraint2 constraint = null;

            try
            {
                constraint = new Constraint2(
                    w,
                    BEDS,
                    y);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(constraint);
        }