protected internal override bool IncludePath(Path path, TraversalBranch startBranch, TraversalBranch endBranch)
        {
            if (!base.IncludePath(path, startBranch, endBranch))
            {
                return(false);
            }

            /*
             * In most cases we could prune startBranch and endBranch here.
             *
             * Problem when assuming startBranch and endBranch are pruned:
             *
             * Path (s) -...- (c) weight x
             * path (s) -...- (a) weight x
             * path (d) -...- (t) weight y
             * path (b) -...- (t) weight y
             * rel (c) - (b) weight z
             * rel (a) - (b) weight z
             * rel (a) - (d) weight z
             *
             *    - (c) ----   ---- (d) -
             * ...           X           ...
             * /  (prune)> /   \ <(prune)  \
             * (s) -^v^v- (a) -- (b) -^v^v- (t)
             *
             * -^v^v- and ... meaning "some path"
             *
             * We expect following collisions:
             *      1. start (c) - (b) end. Result in path of weight x+z+y
             *      2. start (a) - (d) end. Result in path of weight x+z+y
             *      3. start (a) - (b) end. Result in path of weight x+z+y
             * However, if branches are pruned on collision 1 and 2. Collision 3 will never happen and thus
             * a path is missed.
             */

            double cost = (new WeightedPathImpl(_costEvaluator, path)).weight();

            if (cost < _shortestSoFar.doubleValue())
            {
                _shortestSoFar.Value = cost;
            }
            return(NoneStrictMath.compare(cost, _shortestSoFar.doubleValue(), _epsilon) <= 0);
        }
Ejemplo n.º 2
0
        protected internal override WeightedPath FetchNextOrNull()
        {
            if (!_interest.stillInteresting(++_foundTotal))
            {
                return(null);
            }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            if (!_paths.hasNext())
            {
                return(null);
            }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            WeightedPath path = new WeightedPathImpl(_costEvaluator, _paths.next());

            if (_interest.stopAfterLowestCost() && _foundWeight != null && NoneStrictMath.compare(path.Weight(), _foundWeight.Value, _epsilon) > 0)
            {
                return(null);
            }
            _foundWeight = path.Weight();
            return(path);
        }