@Override public boolean canBeRuledOut( int numberOfVisits, Double pathPriority, Double oldPriority ) { return numberOfVisits > 0 || NoneStrictMath.compare( pathPriority, oldPriority, epsilon ) >= 0; }
/** * Compares two numbers given some amount of allowed error. */ public static int compare( double x, double y, double eps ) { return equals( x, y, eps ) ? 0 : x < y ? -1 : 1; }
@Override public int compare( Double x, Double y ) { return NoneStrictMath.compare( x, y, epsilon ); } }
/** * Returns true if both arguments are equal or within the range of allowed error (inclusive) * Error given by {@link NoneStrictMath#EPSILON} */ public static boolean equals( double x, double y ) { return equals( x, y, EPSILON ); }
/** * Compares two numbers given some amount of allowed error. * Error given by {@link NoneStrictMath#EPSILON} */ public static int compare( double x, double y ) { return compare( x, y, EPSILON ); }
assertTrue( "Expected 3 paths of cost 2", NoneStrictMath.equals( paths.next().weight(), 2 ) ); assertTrue( "Expected 3 paths of cost 3", NoneStrictMath.equals( paths.next().weight(), 3 ) ); assertTrue( "Expected 1 path of cost 4", NoneStrictMath.equals( paths.next().weight(), 4 ) ); assertFalse( "Expected exactly 7 paths", paths.hasNext() );
@Override public Boolean apply( Double newValue, Double oldValue ) { return NoneStrictMath.compare( newValue, oldValue, epsilon ) <= 0; } };
assertTrue( "Expected 3 paths of cost 2", NoneStrictMath.equals( paths.next().weight(), 2 ) );
@Override public Iterable<Relationship> expand( Path path, BranchState<Double> state ) { if ( NoneStrictMath.compare( state.getState(), shortestSoFar.doubleValue(), epsilon ) > 0 && stopAfterLowestCost ) { return Collections.emptyList(); } return source.expand( path, state ); }
NoneStrictMath.equals( path.weight(), expectedWeight ) );
@Override protected WeightedPath fetchNextOrNull() { if ( shortestIterator == null ) { shortestPaths = new ArrayList<>(); while ( paths.hasNext() ) { WeightedPath path = new WeightedPathImpl( costEvaluator, paths.next() ); if ( NoneStrictMath.compare( path.weight(), foundWeight, epsilon ) < 0 ) { foundWeight = path.weight(); shortestPaths.clear(); } if ( NoneStrictMath.compare( path.weight(), foundWeight, epsilon ) <= 0 ) { shortestPaths.add( path ); } } shortestIterator = shortestPaths.iterator(); } return shortestIterator.hasNext() ? shortestIterator.next() : null; } }
/** * Compares two numbers given some amount of allowed error. */ public static int compare( double x, double y, double eps ) { return equals( x, y, eps ) ? 0 : x < y ? -1 : 1; }
@Override public Iterable<Relationship> expand( Path path, BranchState<Double> state ) { double thisState = state.getState(); thisSideShortest.setValue( thisState ); if ( NoneStrictMath.compare( thisState + otherSideShortest.doubleValue(), shortestSoFar.doubleValue(), epsilon ) > 0 && stopAfterLowestCost ) { return Iterables.emptyResourceIterable(); } return source.expand( path, state ); }
/** * Returns true if both arguments are equal or within the range of allowed error (inclusive) * Error given by {@link NoneStrictMath#EPSILON} */ public static boolean equals( double x, double y ) { return equals( x, y, EPSILON ); }
@Override protected WeightedPath fetchNextOrNull() { if ( !interest.stillInteresting( ++foundTotal ) ) { return null; } if ( !paths.hasNext() ) { return null; } WeightedPath path = new WeightedPathImpl( costEvaluator, paths.next() ); if ( interest.stopAfterLowestCost() && foundWeight != null && NoneStrictMath.compare( path.weight(), foundWeight, epsilon ) > 0 ) { return null; } foundWeight = path.weight(); return path; }
return NoneStrictMath.compare( cost, shortestSoFar.doubleValue(), epsilon ) <= 0;
/** * Compares two numbers given some amount of allowed error. * Error given by {@link NoneStrictMath#EPSILON} */ public static int compare( double x, double y ) { return compare( x, y, EPSILON ); }
@Override public int compare( Double x, Double y ) { return NoneStrictMath.compare( x, y, epsilon ); } }
@Override public Boolean apply( Double newValue, Double oldValue ) { return NoneStrictMath.compare( newValue, oldValue, epsilon ) <= 0; } };
@Override public boolean canBeRuledOut( int numberOfVisits, Double pathPriority, Double oldPriority ) { return numberOfVisits > 0 || NoneStrictMath.compare( pathPriority, oldPriority, epsilon ) >= 0; }