Search in sources :

Example 6 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project Terasology by MovingBlocks.

the class GLSLMaterial method setFloat2.

@Override
public void setFloat2(String desc, float f1, float f2, boolean currentOnly) {
    if (isDisposed()) {
        return;
    }
    if (currentOnly) {
        enable();
        int id = getUniformLocation(getActiveShaderProgramId(), desc);
        GL20.glUniform2f(id, f1, f2);
    } else {
        TIntIntIterator it = disposalAction.shaderPrograms.iterator();
        while (it.hasNext()) {
            it.advance();
            GL20.glUseProgram(it.value());
            int id = getUniformLocation(it.value(), desc);
            GL20.glUniform2f(id, f1, f2);
        }
        restoreStateAfterUniformsSet();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Example 7 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project Terasology by MovingBlocks.

the class GLSLMaterial method setFloat4.

@Override
public void setFloat4(String desc, float f1, float f2, float f3, float f4, boolean currentOnly) {
    if (isDisposed()) {
        return;
    }
    if (currentOnly) {
        enable();
        int id = getUniformLocation(getActiveShaderProgramId(), desc);
        GL20.glUniform4f(id, f1, f2, f3, f4);
    } else {
        TIntIntIterator it = disposalAction.shaderPrograms.iterator();
        while (it.hasNext()) {
            it.advance();
            GL20.glUseProgram(it.value());
            int id = getUniformLocation(it.value(), desc);
            GL20.glUniform4f(id, f1, f2, f3, f4);
        }
        restoreStateAfterUniformsSet();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Example 8 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project OpenTripPlanner by opentripplanner.

the class RaptorWorker method runRaptorScheduled.

/**
 * Run a raptor search not using frequencies
 */
public void runRaptorScheduled(TIntIntMap initialStops, int departureTime) {
    // Arrays.fill(bestTimes, UNREACHED); hold on to old state
    max_time = departureTime + MAX_DURATION;
    round = 0;
    // go to first round
    advance();
    // clear patterns left over from previous calls.
    patternsTouched.clear();
    allStopsTouched.clear();
    stopsTouched.clear();
    // Copy initial stops over to the first round
    TIntIntIterator iterator = initialStops.iterator();
    while (iterator.hasNext()) {
        iterator.advance();
        int stopIndex = iterator.key();
        int time = iterator.value() + departureTime;
        // note not setting bestNonTransferTimes here because the initial walk is effectively a "transfer"
        bestTimes[stopIndex] = Math.min(time, bestTimes[stopIndex]);
        markPatternsForStop(stopIndex);
    }
    // Anytime a round updates some stops, move on to another round
    while (doOneRound(bestTimes, bestNonTransferTimes, previousPatterns, false)) {
        advance();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Example 9 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project OpenTripPlanner by opentripplanner.

the class InitialStopsTest method testInitialStopWalkSpeedIncrease.

/**
 * Test that increasing the walk speed on a walk-to-transit search
 * a) decreases or leaves unchanged all access times.
 * b) allows access to a superset of the originally accessible stops.
 * c) decreases at least some access times.
 *
 * There was once a bug where bike speed was not correctly applied because we used the distance not the speed.
 */
@Test
public void testInitialStopWalkSpeedIncrease() throws Exception {
    Graph g = buildGraphNoTransit();
    addRegularStopGrid(g);
    addTransitMultipleLines(g);
    link(g);
    g.index(new DefaultStreetVertexIndexFactory());
    ProfileRequest req = new ProfileRequest();
    req.fromLon = req.toLon = -83.0118;
    req.fromLat = req.toLat = 39.9908;
    req.date = new LocalDate(2015, 9, 17);
    req.bikeSpeed = 4.1f;
    req.walkSpeed = 1.3f;
    req.fromTime = 7 * 3600;
    req.toTime = 9 * 3600;
    req.maxBikeTime = 20;
    req.maxWalkTime = 20;
    req.transitModes = new TraverseModeSet("TRANSIT");
    req.accessModes = req.egressModes = req.directModes = new QualifiedModeSet("WALK");
    RaptorWorkerData data = RepeatedRaptorProfileRouter.getRaptorWorkerData(req, g, null, new TaskStatistics());
    assertNotNull(data);
    RepeatedRaptorProfileRouter rrpr = new RepeatedRaptorProfileRouter(g, req);
    TIntIntMap initialStops1 = rrpr.findInitialStops(false, data);
    assertFalse(initialStops1.isEmpty());
    // let's get crazy, set walk speed really high.
    req.walkSpeed = 25f;
    data = RepeatedRaptorProfileRouter.getRaptorWorkerData(req, g, null, new TaskStatistics());
    assertNotNull(data);
    rrpr = new RepeatedRaptorProfileRouter(g, req);
    TIntIntMap initialStops2 = rrpr.findInitialStops(false, data);
    // we should find decreases to at least some stops
    boolean foundDecreases = false;
    for (TIntIntIterator it = initialStops1.iterator(); it.hasNext(); ) {
        it.advance();
        // the reached stops from the faster search should be a superset of the reached stops from the slower search
        assertTrue(initialStops2.containsKey(it.key()));
        assertTrue("Found increase in travel time to stop", initialStops2.get(it.key()) <= it.value());
        foundDecreases = foundDecreases || initialStops2.get(it.key()) < it.value() - EPSILON;
    }
    assertTrue("No decreases were found due to increased walk speed", foundDecreases);
}
Also used : RepeatedRaptorProfileRouter(org.opentripplanner.profile.RepeatedRaptorProfileRouter) FakeGraph(org.opentripplanner.graph_builder.module.FakeGraph) Graph(org.opentripplanner.routing.graph.Graph) TIntIntIterator(gnu.trove.iterator.TIntIntIterator) TaskStatistics(org.opentripplanner.analyst.cluster.TaskStatistics) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) QualifiedModeSet(org.opentripplanner.api.parameter.QualifiedModeSet) RaptorWorkerData(org.opentripplanner.profile.RaptorWorkerData) DefaultStreetVertexIndexFactory(org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory) ProfileRequest(org.opentripplanner.profile.ProfileRequest) LocalDate(org.joda.time.LocalDate) TIntIntMap(gnu.trove.map.TIntIntMap) Test(org.junit.Test)

Example 10 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project OpenTripPlanner by opentripplanner.

the class InitialStopsTest method testInitialStopBikeSpeedIncrease.

/**
 * Test that increasing the bike speed on a bike-to-transit search
 * a) decreases or leaves unchanged all access times.
 * b) allows access to a superset of the originally accessible stops.
 *
 * There was once a bug where bike speed was not correctly applied because we used the distance not the speed.
 */
@Test
public void testInitialStopBikeSpeedIncrease() throws Exception {
    Graph g = buildGraphNoTransit();
    addRegularStopGrid(g);
    addTransitMultipleLines(g);
    link(g);
    g.index(new DefaultStreetVertexIndexFactory());
    ProfileRequest req = new ProfileRequest();
    req.fromLon = req.toLon = -83.0118;
    req.fromLat = req.toLat = 39.9908;
    req.date = new LocalDate(2015, 9, 17);
    req.bikeSpeed = 4.1f;
    req.walkSpeed = 1.3f;
    req.fromTime = 7 * 3600;
    req.toTime = 9 * 3600;
    req.maxBikeTime = 20;
    req.transitModes = new TraverseModeSet("TRANSIT");
    req.accessModes = req.egressModes = req.directModes = new QualifiedModeSet("BICYCLE");
    RaptorWorkerData data = RepeatedRaptorProfileRouter.getRaptorWorkerData(req, g, null, new TaskStatistics());
    assertNotNull(data);
    RepeatedRaptorProfileRouter rrpr = new RepeatedRaptorProfileRouter(g, req);
    TIntIntMap initialStops1 = rrpr.findInitialStops(false, data);
    assertFalse(initialStops1.isEmpty());
    // let's get crazy, set bike speed really high.
    req.bikeSpeed = 25f;
    data = RepeatedRaptorProfileRouter.getRaptorWorkerData(req, g, null, new TaskStatistics());
    assertNotNull(data);
    rrpr = new RepeatedRaptorProfileRouter(g, req);
    TIntIntMap initialStops2 = rrpr.findInitialStops(false, data);
    // we should find decreases to at least some stops
    boolean foundDecreases = false;
    for (TIntIntIterator it = initialStops1.iterator(); it.hasNext(); ) {
        it.advance();
        // the reached stops from the faster search should be a superset of the reached stops from the slower search
        assertTrue(initialStops2.containsKey(it.key()));
        assertTrue("Found increase in travel time to stop", initialStops2.get(it.key()) <= it.value());
        foundDecreases = foundDecreases || initialStops2.get(it.key()) < it.value() - EPSILON;
    }
    assertTrue(foundDecreases);
}
Also used : RepeatedRaptorProfileRouter(org.opentripplanner.profile.RepeatedRaptorProfileRouter) FakeGraph(org.opentripplanner.graph_builder.module.FakeGraph) Graph(org.opentripplanner.routing.graph.Graph) TIntIntIterator(gnu.trove.iterator.TIntIntIterator) TaskStatistics(org.opentripplanner.analyst.cluster.TaskStatistics) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) QualifiedModeSet(org.opentripplanner.api.parameter.QualifiedModeSet) RaptorWorkerData(org.opentripplanner.profile.RaptorWorkerData) DefaultStreetVertexIndexFactory(org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory) ProfileRequest(org.opentripplanner.profile.ProfileRequest) LocalDate(org.joda.time.LocalDate) TIntIntMap(gnu.trove.map.TIntIntMap) Test(org.junit.Test)

Aggregations

TIntIntIterator (gnu.trove.iterator.TIntIntIterator)22 TIntIntMap (gnu.trove.map.TIntIntMap)3 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)2 LocalDate (org.joda.time.LocalDate)2 Test (org.junit.Test)2 TaskStatistics (org.opentripplanner.analyst.cluster.TaskStatistics)2 QualifiedModeSet (org.opentripplanner.api.parameter.QualifiedModeSet)2 FakeGraph (org.opentripplanner.graph_builder.module.FakeGraph)2 ProfileRequest (org.opentripplanner.profile.ProfileRequest)2 RaptorWorkerData (org.opentripplanner.profile.RaptorWorkerData)2 RepeatedRaptorProfileRouter (org.opentripplanner.profile.RepeatedRaptorProfileRouter)2 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)2 Graph (org.opentripplanner.routing.graph.Graph)2 DefaultStreetVertexIndexFactory (org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory)2 CUtils (cc.redberry.pipe.CUtils)1 OutputPort (cc.redberry.pipe.OutputPort)1 Range (com.milaboratory.core.Range)1 com.milaboratory.core.alignment (com.milaboratory.core.alignment)1 MutationsBuilder (com.milaboratory.core.mutations.MutationsBuilder)1 com.milaboratory.core.sequence (com.milaboratory.core.sequence)1