@Override public void doSpecificWork() { StopWatch sw = new StopWatch().start(); LOGGER.info("Start calculating " + lms.getLandmarkCount() + " landmarks, default active lms:" + defaultActiveLandmarks + ", weighting:" + lms.getLmSelectionWeighting() + ", " + Helper.getMemInfo()); lms.createLandmarks(); lms.flush(); LOGGER.info("Calculated landmarks for " + (lms.getSubnetworksWithLandmarks() - 1) + " subnetworks, took:" + sw.stop().getSeconds() + " => " + lms.getLandmarksAsGeoJSON() + ", stored weights:" + lms.getLandmarkCount() + ", nodes:" + graph.getNodes() + ", " + Helper.getMemInfo()); }
@Test public void testWithSubnetworks() { ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2, 10, true); ghStorage.edge(2, 4).setFlags(encoder.setAccess(0, false, false)); ghStorage.edge(4, 5, 10, true); ghStorage.edge(5, 6, 10, false); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(2); storage.createLandmarks(); assertEquals(3, storage.getSubnetworksWithLandmarks()); assertEquals("[2, 0]", Arrays.toString(storage.getLandmarks(1))); assertEquals("[6, 4]", Arrays.toString(storage.getLandmarks(2))); }
@Test public void testWithSubnetworks2() { // should not happen with subnetwork preparation // 0 - 1 - 2 = 3 - 4 ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2, 10, true); ghStorage.edge(2, 3, 10, false); ghStorage.edge(3, 2, 10, false); ghStorage.edge(3, 4, 10, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(3); storage.createLandmarks(); assertEquals(2, storage.getSubnetworksWithLandmarks()); assertEquals("[4, 0]", Arrays.toString(storage.getLandmarks(1))); }
@Test public void testWeightingConsistence() { // create an indifferent problem: shortest weighting can pass the speed==0 edge but fastest cannot (?) ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2).setDistance(10).setFlags(encoder.setProperties(0.9, true, true)); ghStorage.edge(2, 3, 10, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(2); storage.createLandmarks(); assertEquals(2, storage.getSubnetworksWithLandmarks()); assertEquals("[1, 0]", Arrays.toString(storage.getLandmarks(1))); }
@Test public void testWithOnewaySubnetworks() { // should not happen with subnetwork preparation // create an indifferent problem: node 2 and 3 are part of two 'disconnected' subnetworks ghStorage.edge(0, 1, 10, true); ghStorage.edge(1, 2, 10, false); ghStorage.edge(2, 3, 10, false); ghStorage.edge(4, 5, 10, true); ghStorage.edge(5, 2, 10, false); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.setMinimumNodes(2); storage.createLandmarks(); assertEquals(2, storage.getSubnetworksWithLandmarks()); assertEquals("[4, 0]", Arrays.toString(storage.getLandmarks(1))); }
storage.createLandmarks(); assertEquals(3, storage.getSubnetworksWithLandmarks());
@Test public void testDeltaWarning() { int distance = 1000000; ghStorage.edge(1, 2, distance, false); ghStorage.edge(2, 3, distance, false); ghStorage.edge(3, 4, distance, false); ghStorage.edge(4, 5, distance, false); ghStorage.edge(5, 6, distance, false); ghStorage.edge(6, 1, distance, false); ghStorage.edge(1, 7, distance, true); ghStorage.edge(7, 8, distance, true); ghStorage.edge(8, 9, distance, true); ghStorage.edge(6, 10, distance, true); ghStorage.edge(10, 11, distance, true); ghStorage.edge(11, 12, distance, true); LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), new FastestWeighting(encoder), 2); storage.createLandmarks(); assertEquals(12, storage.getLandmarks(1)[0]); assertEquals(9, storage.getLandmarks(1)[1]); assertEquals((int) Math.pow(2, 13) - 2, storage.getToWeight(0, 9) - storage.getFromWeight(0, 9)); assertEquals((int) -Math.pow(2, 13), storage.getToWeight(1, 12) - storage.getFromWeight(1, 12)); } }
LandmarkStorage store = new LandmarkStorage(graph, dir, weighting, lm); store.setMinimumNodes(2); store.createLandmarks();
@Override public void doSpecificWork() { StopWatch sw = new StopWatch().start(); LOGGER.info("Start calculating " + lms.getLandmarkCount() + " landmarks, default active lms:" + defaultActiveLandmarks + ", weighting:" + lms.getLmSelectionWeighting() + ", " + Helper.getMemInfo()); lms.createLandmarks(); lms.flush(); LOGGER.info("Calculated landmarks for " + (lms.getSubnetworksWithLandmarks() - 1) + " subnetworks, took:" + sw.stop().getSeconds() + " => " + lms.getLandmarksAsGeoJSON() + ", stored weights:" + lms.getLandmarkCount() + ", nodes:" + graph.getNodes() + ", " + Helper.getMemInfo()); }
@Override public void doWork() { super.doWork(); StopWatch sw = new StopWatch().start(); LOGGER.info("Start calculating " + lms.getLandmarkCount() + " landmarks, default active lms:" + defaultActiveLandmarks + ", weighting:" + lms.getLmSelectionWeighting() + ", " + Helper.getMemInfo()); lms.createLandmarks(); lms.flush(); LOGGER.info("Calculating landmarks for " + (lms.getSubnetworksWithLandmarks() - 1) + " subnetworks took:" + sw.stop().getSeconds() + " => " + lms.getLandmarksAsGeoJSON() + ", stored weights:" + lms.getLandmarkCount() + ", nodes:" + graph.getNodes() + ", " + Helper.getMemInfo()); }