コード例 #1
0
        public override void Compute(MSInput input, out MSOutput output)
        {
            output = new MSOutput();
            var trajectory = input.Trajectory;

            ShortcutProvider.Init(input, output, false);

            LinkedList <TPoint2D> prevShortestPath = null;

            for (var level = input.NumLevels; level >= 1; level--)
            {
                var epsilon        = input.GetEpsilon(level);
                var levelShortcuts = ShortcutProvider.GetShortcuts(level, epsilon);

                LinkedList <TPoint2D> shortestPath;

                if (prevShortestPath == null)
                {
                    var pointPath = ShortestPathProvider.FindShortestPath(levelShortcuts, trajectory.First(), trajectory.Last());
                    shortestPath = pointPath.Points;
                }
                else
                {
                    shortestPath = new LinkedList <TPoint2D>();
                    var prevPoint = trajectory.First();

                    foreach (var point in prevShortestPath)
                    {
                        if (point == trajectory.First())
                        {
                            continue;
                        }

                        var pointPath = ShortestPathProvider.FindShortestPath(levelShortcuts, prevPoint, point);

                        foreach (var p in pointPath.Points)
                        {
                            shortestPath.AddLast(p);
                        }

                        prevPoint = point;
                    }
                }

                shortestPath.AddFirst(trajectory.First());

                var newTrajectory = new Trajectory2D(shortestPath);

                //report shortest path
                //output.LogObject("Level Shortest Path", levelTrajectory);
                output.LogLine("Level " + level + " trajectory found. Length: " + newTrajectory.Count);
                output.SetTrajectoryAtLevel(level, newTrajectory);

                prevShortestPath = shortestPath;

                ShortcutProvider.SetSearchIntervals(shortestPath);
            }
        }
コード例 #2
0
        public override void Compute(MSInput input, out MSOutput output)
        {
            output = new MSOutput();
            var trajectory = input.Trajectory;

            ShortcutProvider.Init(input, output, false);

            ICollection <TPoint2D> prevShortestPath = trajectory;

            for (var level = 1; level <= input.NumLevels; level++)
            {
                var epsilon = input.GetEpsilon(level);

                var levelShortcuts = ShortcutProvider.GetShortcuts(level, epsilon);

                var levelShortestPath = ShortestPathProvider.FindShortestPath(levelShortcuts, trajectory.First(), trajectory.Last()).Points;
                levelShortestPath.AddFirst(trajectory.First());

                //O(n)
                var levelTrajectory = new Trajectory2D(levelShortestPath);

                //O(n)
                var levelShortestPathSet = new HashSet <TPoint2D>(levelShortestPath);

                //report level trajectory
                output.SetTrajectoryAtLevel(level, levelTrajectory);

                //prune shortcutgraph and shortcuts
                //only consider points that are not the first/last
                foreach (var point in prevShortestPath)
                {
                    //O(1)
                    if (!levelShortestPathSet.Contains(point))
                    {
                        //remove shortcuts from shortcut set
                        ShortcutProvider.RemovePoint(point);
                    }
                }

                prevShortestPath = levelShortestPath;
            }
        }
コード例 #3
0
        public override void Compute(MSInput input, out MSOutput output)
        {
            output = new MSOutput();
            var trajectory = input.Trajectory;

            ShortcutProvider.Init(input, output, false);

            for (var level = 1; level <= input.NumLevels; level++)
            {
                var epsilon = input.GetEpsilon(level);

                var levelShortcuts = ShortcutProvider.GetShortcuts(level, epsilon);

                var shortestPath = ShortestPathProvider.FindShortestPath(levelShortcuts, trajectory.First(), trajectory.Last()).Points;

                shortestPath.AddFirst(trajectory.First());

                //O(n)
                var levelTrajectory = new Trajectory2D(shortestPath);

                output.SetTrajectoryAtLevel(level, levelTrajectory);
            }
        }
コード例 #4
0
        public override void Compute(MSInput input, out MSOutput output)
        {
            output = new MSOutput();
            var trajectory = input.Trajectory;

            ShortcutProvider.Init(input, output, false);

            var onDemandShortcutProvider = (ShortcutsOnDemand)ShortcutProvider;
            var prevTrajectory           = trajectory;

            for (var level = 1; level <= input.NumLevels; level++)
            {
                var epsilon = input.GetEpsilon(level);

                var shortcutAlgo  = onDemandShortcutProvider.Algorithm;
                var shortcutInput = new MSSInput(prevTrajectory, new List <double> {
                    epsilon
                });
                MSSOutput shortcutOutput;

                shortcutAlgo.Compute(shortcutInput, out shortcutOutput);
                var levelShortcuts = shortcutOutput.GetShortcuts(1);

                output.LogObject("Number of shortcuts found on level " + level, levelShortcuts.Count);

                var levelShortestPath = ShortestPathProvider.FindShortestPath(levelShortcuts, prevTrajectory.First(), prevTrajectory.Last()).Points;
                levelShortestPath.AddFirst(prevTrajectory.First());

                //O(n)
                var levelTrajectory = new Trajectory2D(levelShortestPath);

                //report level trajectory
                output.SetTrajectoryAtLevel(level, levelTrajectory);

                prevTrajectory = levelTrajectory;
            }
        }