All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.transit.raptor.rangeraptor.path.PathParetoSetComparators Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.transit.raptor.rangeraptor.path;

import org.opentripplanner.transit.raptor.api.path.Path;
import org.opentripplanner.transit.raptor.api.transit.RaptorTripSchedule;
import org.opentripplanner.transit.raptor.util.paretoset.ParetoComparator;


/**
 * List of different pareto set comparators. Earlier we created these dynamically,
 * but that affect the performance, so it is better to have one function for each
 * use case.
 * 

* All comparators include the "standard" set of criteria: *

    *
  • Arrival Time
  • *
  • Number of transfers
  • *
  • Total travel duration time
  • *
* The {@code travelDuration} is added as a criteria to the pareto comparator in addition to the parameters * used for each stop arrivals. The {@code travelDuration} is only needed at the destination because Range Raptor * works in iterations backwards in time. */ public class PathParetoSetComparators { /** Prevent this utility class from instantiation. */ private PathParetoSetComparators() { } public static ParetoComparator> comparatorStandard() { return (l, r) -> l.endTime() < r.endTime() || l.numberOfTransfers() < r.numberOfTransfers() || l.travelDurationInSeconds() < r.travelDurationInSeconds(); } public static ParetoComparator> comparatorWithTimetable() { return (l, r) -> l.rangeRaptorIterationDepartureTime() > r.rangeRaptorIterationDepartureTime() || l.endTime() < r.endTime() || l.numberOfTransfers() < r.numberOfTransfers() || l.travelDurationInSeconds() < r.travelDurationInSeconds(); } public static ParetoComparator> comparatorWithTimetableAndCost() { return (l, r) -> l.rangeRaptorIterationDepartureTime() > r.rangeRaptorIterationDepartureTime() || l.endTime() < r.endTime() || l.numberOfTransfers() < r.numberOfTransfers() || l.travelDurationInSeconds() < r.travelDurationInSeconds() || l.cost() < r.cost(); } public static ParetoComparator> comparatorWithTimetableAndRelaxedCost( double relaxCostAtDestinationArrival ) { return (l, r) -> l.rangeRaptorIterationDepartureTime() > r.rangeRaptorIterationDepartureTime() || l.endTime() < r.endTime() || l.numberOfTransfers() < r.numberOfTransfers() || l.travelDurationInSeconds() < r.travelDurationInSeconds() || l.cost() < Math.round(r.cost() * relaxCostAtDestinationArrival); } public static ParetoComparator> comparatorWithCost() { return (l, r) -> l.endTime() < r.endTime() || l.numberOfTransfers() < r.numberOfTransfers() || l.travelDurationInSeconds() < r.travelDurationInSeconds() || l.cost() < r.cost(); } public static ParetoComparator> comparatorWithRelaxedCost( double relaxCostAtDestinationArrival ) { return (l, r) -> l.endTime() < r.endTime() || l.numberOfTransfers() < r.numberOfTransfers() || l.travelDurationInSeconds() < r.travelDurationInSeconds() || l.cost() < Math.round(r.cost() * relaxCostAtDestinationArrival); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy