forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for reachability thresholds, opentripplanner#2148.
- Loading branch information
1 parent
5871d8e
commit 040258d
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/test/java/org/opentripplanner/profile/PropagatedTimesStoreTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.opentripplanner.profile; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Test; | ||
import org.opentripplanner.graph_builder.module.FakeGraph; | ||
import org.opentripplanner.routing.graph.Graph; | ||
|
||
/** | ||
* Test the propagated times store. | ||
*/ | ||
public class PropagatedTimesStoreTest extends TestCase { | ||
/** | ||
* Test that changing the reachability threshold works (i.e. averages are computed properly when destinations are | ||
* only reachable part of the time). | ||
*/ | ||
@Test | ||
public static void testReachability () throws Exception { | ||
ProfileRequest pr = new ProfileRequest(); | ||
// old default: no restrictions o | ||
pr.reachabilityThreshold = 0; | ||
|
||
Graph g = new Graph(); | ||
|
||
PropagatedTimesStore pts = new PropagatedTimesStore(g, pr, 1); | ||
// accessible one-third of the time | ||
int[][] times = new int[][] { | ||
new int[] { 1 }, | ||
new int[] { RaptorWorker.UNREACHED }, | ||
new int[] { RaptorWorker.UNREACHED } | ||
}; | ||
|
||
pts.setFromArray(times, PropagatedTimesStore.ConfidenceCalculationMethod.MIN_MAX); | ||
|
||
// it is reachable at least 0% of the time | ||
assertEquals(1, pts.avgs[0]); | ||
|
||
pr.reachabilityThreshold = 0.5f; | ||
pts = new PropagatedTimesStore(g, pr, 1); | ||
pts.setFromArray(times, PropagatedTimesStore.ConfidenceCalculationMethod.MIN_MAX); | ||
|
||
// it is not reachable 50% of the time | ||
assertEquals(RaptorWorker.UNREACHED, pts.avgs[0]); | ||
} | ||
} |