Пример #1
0
        public IConstraints12ConstraintElement Create(
            IdIndexElement dIndexElement,
            IwIndexElement wIndexElement,
            Id d,
            Il l,
            Ipa pa,
            IP P,
            Iprob prob,
            ITPx x,
            IVariance Variance)
        {
            IConstraints12ConstraintElement constraintElement = null;

            try
            {
                constraintElement = new Constraints12ConstraintElement(
                    dIndexElement,
                    wIndexElement,
                    d,
                    l,
                    pa,
                    P,
                    prob,
                    x,
                    Variance);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(constraintElement);
        }
        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));
        }
 public IDayBedRequirementVariancesResultElement Calculate(
     IDayBedRequirementVariancesResultElementFactory dayBedRequirementVariancesResultElementFactory,
     IdIndexElement dIndexElement,
     IVariance Variance)
 {
     return(dayBedRequirementVariancesResultElementFactory.Create(
                dIndexElement,
                Variance.Value
                .Where(a => a.dIndexElement == dIndexElement)
                .Select(a => a.Value)
                .Sum()));
 }
Пример #4
0
 public IDayBedRequirementVariances Calculate(
     IDayBedRequirementVariancesResultElementFactory dayBedRequirementVariancesResultElementFactory,
     IDayBedRequirementVariancesFactory dayBedRequirementVariancesFactory,
     IDayBedRequirementVariancesResultElementCalculation dayBedRequirementVariancesResultElementCalculation,
     Id d,
     IVariance Variance)
 {
     return(dayBedRequirementVariancesFactory.Create(
                d.Value
                .Select(y => dayBedRequirementVariancesResultElementCalculation.Calculate(
                            dayBedRequirementVariancesResultElementFactory,
                            y,
                            Variance))
                .ToImmutableList()));
 }
Пример #5
0
        public IVariance Create(
            ImmutableList <IVarianceResultElement> value)
        {
            IVariance result = null;

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

            return(result);
        }
Пример #6
0
        public IVariance Create(
            VariableCollection <IwIndexElement> value)
        {
            IVariance variable = null;

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

            return(variable);
        }
Пример #7
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()));
 }
Пример #8
0
        public static void Main(string[] args)
        {
            GenericStruct <int>[] arr = new GenericStruct <int> [3];
            arr[0] = GenericStruct <int> .ReturnStruct(3);

            DerivedGenericClass <string, string> gc = new DerivedGenericClass <string, string>();
            string c = gc.func("oops");

            Console.WriteLine(c);
            gc.genericMethod("hello", arr[0].genericMethod2(3) ?? 0);
            GenericInterface <string> s = gc;

            s.genericMethod("goodbye", c);
            GenericClass <object> .myMethod(42);

            IVariance <string, int> q = null;

            q.func("nope");

            foreach (var v in arr)
            {
                v.genericMethod(64, "nope");
            }
        }
Пример #9
0
        public Constraints12ConstraintElement(
            IdIndexElement dIndexElement,
            IwIndexElement wIndexElement,
            Id d,
            Il l,
            Ipa pa,
            IP P,
            Iprob prob,
            ITPx x,
            IVariance Variance)
        {
            Expression LHS = Variance.Value[wIndexElement, dIndexElement];

            ImmutableList <Tuple <IpIndexElement, IaIndexElement, double> > .Builder builder = ImmutableList.CreateBuilder <Tuple <IpIndexElement, IaIndexElement, double> >();

            foreach (IpIndexElement pIndexElement in pa.Value.Where(i => P.IsThereElementAt(wIndexElement, i.pIndexElement)).Select(w => w.pIndexElement).Distinct())
            {
                foreach (IaIndexElement aIndexElement in pa.Value.Select(w => w.aIndexElement).Distinct())
                {
                    int dLowerBound = aIndexElement.Key <= dIndexElement.Key ? dIndexElement.Key - aIndexElement.Key : d.GetMaximumKey() + dIndexElement.Key - aIndexElement.Key;

                    double RHSSum = 0;

                    for (int w = dLowerBound;
                         w <= l.GetMaximumLengthOfStay();
                         w = w + 1)
                    {
                        RHSSum +=
                            (double)prob.GetElementAtAsdecimal(
                                pIndexElement,
                                l.GetElementAt(
                                    w))
                            *
                            (double)(1 - prob.GetElementAtAsdecimal(
                                         pIndexElement,
                                         l.GetElementAt(
                                             w)));
                    }

                    builder.Add(
                        Tuple.Create(
                            pIndexElement,
                            aIndexElement,
                            RHSSum));
                }
            }

            ImmutableList <Tuple <IpIndexElement, IaIndexElement, double> > RHSSums = builder.ToImmutableList();

            Expression RHS = Expression.Sum(
                pa.Value
                .Where(i => P.IsThereElementAt(wIndexElement, i.pIndexElement))
                .Select(
                    y =>
                    RHSSums.Where(w => w.Item1 == y.pIndexElement && w.Item2 == y.aIndexElement).Select(w => w.Item3).SingleOrDefault()
                    *
                    x.Value[
                        y.pIndexElement,
                        y.aIndexElement]));

            this.Value = LHS == RHS;
        }