Beispiel #1
0
        public void VerifySimulatedData(MasterDBContext dbContext, DataGeneratorContext dbGeneratorCtx,
                                        ResultContext dbResultCtx, int simNumber)
        {
            var simulation = SimulationRepository.GetSimulationById(simNumber, dbGeneratorCtx);

            if (simulation != null)
            {
                var approach = ApproachRepository.GetApproachById(dbGeneratorCtx, simulation.ApproachId);
                if (approach.TransitionMatrixInput.ExtendedTransitionMatrix)
                {
                    var generator = new MainGenerator();
                    generator.StartGeneration(approach, dbContext, dbResultCtx);

                    var articleCount =
                        ArticleRepository.GetArticleNamesAndCountForEachUsedArticleInSimulation(dbResultCtx, simNumber);

                    var articlesByNames =
                        ArticleRepository.GetArticlesByNames(articleCount.Keys.ToHashSet(), dbContext);
                    var capabilities = ResourceCapabilityRepository.GetParentResourceCapabilities(dbContext);

                    var actualTransitionMatrix = new TransitionMatrix
                    {
                        Pi = new double[capabilities.Count + 1, capabilities.Count + 1]
                    };

                    var capPosByCapId = new Dictionary <int, int>();
                    foreach (var cap in capabilities)
                    {
                        var number = cap.Name.Substring(0, cap.Name.IndexOf(" "));
                        var pos    = AlphabeticNumbering.GetNumericRepresentation(number);
                        capPosByCapId.Add(cap.Id, pos);
                    }

                    foreach (var a in articlesByNames)
                    {
                        var operations = a.Value.Operations.ToList();
                        operations.Sort((o1, o2) => o1.HierarchyNumber.CompareTo(o2.HierarchyNumber));

                        var operationCount = 0;
                        var lastCapPos     = 0;
                        do
                        {
                            var capPos =
                                capPosByCapId[
                                    operations[operationCount].ResourceCapability.ParentResourceCapability.Id];
                            actualTransitionMatrix.Pi[lastCapPos, capPos] += articleCount[a.Key];
                            lastCapPos = capPos + 1;
                            operationCount++;
                        } while (operationCount < operations.Count);

                        actualTransitionMatrix.Pi[lastCapPos, capabilities.Count] += articleCount[a.Key];
                    }

                    for (var i = 0; i <= capabilities.Count; i++)
                    {
                        var sum = 0.0;
                        for (var j = 0; j <= capabilities.Count; j++)
                        {
                            sum += actualTransitionMatrix.Pi[i, j];
                        }

                        for (var j = 0; j <= capabilities.Count; j++)
                        {
                            actualTransitionMatrix.Pi[i, j] /= sum;
                        }
                    }

                    var transitionMatrixGenerator = new TransitionMatrixGenerator();
                    ActualOrganizationDegree = transitionMatrixGenerator.CalcOrganizationDegree(
                        actualTransitionMatrix.Pi,
                        capabilities.Count + 1);
                    GeneratedOrganizationDegree = transitionMatrixGenerator.CalcOrganizationDegree(
                        generator.TransitionMatrix.Pi,
                        capabilities.Count + 1);

                    System.Diagnostics.Debug.WriteLine("################################# Executed work plans have an organization degree of " + ActualOrganizationDegree + " (transition matrix has " + GeneratedOrganizationDegree + "; input was " + approach.TransitionMatrixInput.DegreeOfOrganization + ")");
                }
            }
        }
Beispiel #2
0
        public void Test1()
        {
            var lintMax   = Int32.MaxValue;
            var longMax   = Int64.MaxValue;
            var doubleMax = Double.MaxValue;

            System.Diagnostics.Debug.WriteLine(lintMax.ToString());
            System.Diagnostics.Debug.WriteLine(longMax.ToString());
            System.Diagnostics.Debug.WriteLine(doubleMax.ToString());
            var faculty = new Faculty();
            //var f1 = faculty.Calc(200);
            //var f2 = faculty.Calc(20);
            //var r = Math.Round(f2);
            //var p1 = Math.Pow(100.537, 100);
            //var p2 = Math.Pow(10.1, 20);
            var x1   = Math.Round(Math.Pow(5.0 / 1.0, 19) * 50);
            var x2   = Convert.ToInt64(x1);
            var sum1 = Convert.ToInt64(0);
            var sum2 = 0.0;

            for (int i = 0; i < 20; i++)
            {
                var result = Convert.ToInt64(Math.Round(Math.Pow(5.0 / 1.0, i) * 50));
                sum1 += result;
                sum2 += result;
            }

            sum1 *= 5;
            sum2 *= 5.0;
            var x3 = Convert.ToInt64(Math.Round(sum2));

            var x4 = Math.Round(5.4343454359);

            var n1 = AlphabeticNumbering.GetAlphabeticNumbering(0);
            var n2 = AlphabeticNumbering.GetAlphabeticNumbering(25);
            var n3 = AlphabeticNumbering.GetAlphabeticNumbering(26);
            var n4 = AlphabeticNumbering.GetAlphabeticNumbering(52);
            var n5 = AlphabeticNumbering.GetAlphabeticNumbering(454);
            var n6 = AlphabeticNumbering.GetAlphabeticNumbering(1);
            var n7 = AlphabeticNumbering.GetAlphabeticNumbering(2);
            var n8 = AlphabeticNumbering.GetAlphabeticNumbering(3);

            var n11 = AlphabeticNumbering.GetNumericRepresentation(n1);
            var n12 = AlphabeticNumbering.GetNumericRepresentation(n2);
            var n13 = AlphabeticNumbering.GetNumericRepresentation(n3);
            var n14 = AlphabeticNumbering.GetNumericRepresentation(n4);
            var n15 = AlphabeticNumbering.GetNumericRepresentation(n5);
            var n16 = AlphabeticNumbering.GetNumericRepresentation(n6);
            var n17 = AlphabeticNumbering.GetNumericRepresentation(n7);
            var n18 = AlphabeticNumbering.GetNumericRepresentation(n8);

            var list1 = new List <TruncatedDiscreteNormal>();
            var truncatedDiscreteNormalDistribution =
                new TruncatedDiscreteNormal(9, 11, Normal.WithMeanVariance(5.0, 2.0));

            list1.Add(truncatedDiscreteNormalDistribution);
            list1.Add(truncatedDiscreteNormalDistribution);
            list1.Add(truncatedDiscreteNormalDistribution);
            list1.Add(truncatedDiscreteNormalDistribution);
            var x5 = list1[1].Sample();

            Assert.True(true);
        }