Ejemplo n.º 1
0
        public void FirstFiftyGroupedByRisk()
        {
            var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator());
            var riskCalculator = new AStarRiskCalculator();

            var groups = Enumerable.Range(1, 50).AsParallel()
                .Select(radius =>
                {
                    var stations = latticeCalculator.FindLatticePoints(radius).Select(coord => new Station(coord));
                    return riskCalculator.CalculateRisk(stations, radius);
                })
                .GroupBy(result => result.TotalRisk)
                .OrderBy(grp => grp.Key);

            foreach(var grp in groups)
            {
                Console.Write("{0}, {1}:", grp.Key, grp.First().TotalDistanceRatio);
                foreach(var value in grp.OrderBy(result => result.Radius))
                {
                    Console.Write(" {0:N0}", value.Radius);
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
        private RiskResult FindResult(int radius)
        {
            var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator());
            var riskCalculator = new AStarRiskCalculator();

            var stations = latticeCalculator.FindLatticePoints(radius).Select(coord => new Station(coord));
            return riskCalculator.CalculateRisk(stations, radius);
        }
Ejemplo n.º 3
0
        public void MaxZ()
        {
            var latticeCalculator = new SliceSphereLatticeCalculator(new TurtleCircleLatticeCalculator());
            var riskCalculator = new AStarRiskCalculator();

            var results = Enumerable.Range(1, 50).AsParallel()
                .Select(radius =>
                {
                    var stations = latticeCalculator.FindLatticePoints(radius).Select(coord => new Station(coord));
                    return riskCalculator.CalculateRisk(stations, radius);
                })
                .OrderBy(result => result.Radius);

            foreach (var result in results)
            {
                var maxZ = result.Path.Max(path => path.Source.CartesianLocation.Z - path.Target.CartesianLocation.Z);
                Console.WriteLine("{0}: {1}", result.Radius, maxZ);
            }
        }