Vitesse des transports adaptée

This commit is contained in:
AngeHerman 2024-04-29 17:13:17 +02:00
parent f77c105ff9
commit 2dd7abcc0c
4 changed files with 40 additions and 7 deletions

View file

@ -21,6 +21,8 @@ public class CSVSchedulesProvider {
put("Subway", new int[]{4, 2, 6,3,3,4});
}};
// Time between 2 passages for the transports with a new type we don't know yet
private static int DEFAULT_TIMING = 6;
private static final NumberFormat MINUTES_SECOND_FORMATTER = NumberFormat

View file

@ -23,6 +23,23 @@ import fr.u_paris.gla.project.utils.GPS;
* CSV Stream Provider class
*/
public final class CSVStreamProvider {
private static final HashMap<String, Double> two_acceleration_distance_by_type = new HashMap<String, Double>(){{
put("Bus", 0.1);
put("Funicular", 0.1);
put("Tram", 0.1);
put("Rail", 0.2);
put("Subway", 0.1);
}};
private static final HashMap<String, Double> max_speed_by_type = new HashMap<String, Double>(){{
put("Bus", 10.0);
put("Funicular", 5.0);
put("Tram", 20.0);
put("Rail", 50.0);
put("Subway", 30.0);
}};
/**
* Formatter from numbers into GPS Coordinates
*/
@ -201,7 +218,7 @@ public final class CSVStreamProvider {
this.line[NetworkFormat.DISTANCE_INDEX] = NumberFormat.getInstance(Locale.ENGLISH)
.format(distance);
this.line[NetworkFormat.DURATION_INDEX] = formatTime(
(long) Math.ceil(distanceToTime(distance) * SECONDS_IN_HOURS));
(long) Math.ceil(distanceToTime(distance,this.traceType) * SECONDS_IN_HOURS));
int bifurcation = this.lineSegments.get(this.start).size() - 1;
this.line[NetworkFormat.VARIANT_INDEX] = Integer
.toString(bifurcation);
@ -231,6 +248,18 @@ public final class CSVStreamProvider {
MINUTES_SECOND_FORMATTER.format(time / SECONDS_IN_MINUTES), MINUTES_SECOND_FORMATTER.format(time % SECONDS_IN_MINUTES));
}
// /** A tool method to give a delay to go through a certain distance.
// * <p>
// * This is a model with an linear acceleration and deceleration periods and a
// * constant speed in between.
// *
// * @param distance the distance (in km)
// * @return the duration of the trip (in hours) */
// private static double distanceToTime(double distance) {
// return Math.max(0, distance - TWO_ACCELERATION_DISTANCE) / MAX_SPEED
// + Math.pow(Math.min(distance, TWO_ACCELERATION_DISTANCE) / MAX_SPEED, 2);
// }
/** A tool method to give a delay to go through a certain distance.
* <p>
* This is a model with an linear acceleration and deceleration periods and a
@ -238,9 +267,11 @@ public final class CSVStreamProvider {
*
* @param distance the distance (in km)
* @return the duration of the trip (in hours) */
private static double distanceToTime(double distance) {
return Math.max(0, distance - TWO_ACCELERATION_DISTANCE) / MAX_SPEED
+ Math.pow(Math.min(distance, TWO_ACCELERATION_DISTANCE) / MAX_SPEED, 2);
private static double distanceToTime(double distance, String type) {
Double max_speed = max_speed_by_type.get(type);
Double two_acc_distance = two_acceleration_distance_by_type.get(type);
return Math.max(0, distance - two_acc_distance) / max_speed
+ Math.pow(Math.min(distance, two_acc_distance) / max_speed, 2);
}
private void fillTransports(int bif) {

View file

@ -245,7 +245,7 @@ public class IDFMNetworkExtractor {
}
}
public static void builFiles() {
public static void buildFiles() {
if (checkFileExistence("./"+HOURS_FILE_NAME) && checkFileExistence("./"+TRACE_FILE_NAME)) {
LOGGER.severe("Files already exists.");

View file

@ -209,7 +209,7 @@ public class ItineraryCalculator {
LOGGER.severe("Invalid command line. Target file names are in the main file for now.");
return;
}
//IDFMNetworkExtractor.builFiles();
IDFMNetworkExtractor.buildFiles();
try {
HashSet<Stop> nodes = new HashSet<>();
@ -244,7 +244,7 @@ public class ItineraryCalculator {
//System.out.println(graph.getConnections(porteivry));
Finder finder = new Finder(graph);
List<Path> res = finder.findPath(porteivry, chatelet, 43200);
List<Path> res = finder.findPath(chatelet, garenord, 43200);
for (Path element : res) {
System.out.println(element.getCurrentStop());
}