Skip to content

Commit

Permalink
Router / attribute aggregation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CorinStaves committed Dec 26, 2023
1 parent dbb7366 commit 73fc95d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/main/java/diary/RunRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.router.costcalculators.FreespeedTravelTimeAndDisutility;
import org.matsim.core.router.util.TravelTime;
import routing.ActiveAttributes;
import routing.Bicycle;
import routing.disutility.DistanceDisutility;
import routing.disutility.JibeDisutility3Fast;
import routing.travelTime.WalkTravelTime;
import diary.calculate.RouteIndicatorCalculator;
import io.TripCsvWriter;
Expand Down Expand Up @@ -124,14 +124,14 @@ public static void main(String[] args) throws IOException, FactoryException {
// bike
// calc.network("bike_jibe_day", ORIGIN, DESTINATION, bike, networkBike, networkBike, new JibeDisutility3Fast(networkBike,bike,TransportMode.bike,ttBikeFast,true), ttBike, null,savePath);
// calc.network("bike_jibe_night", ORIGIN, DESTINATION, bike, networkBike, networkBike, new JibeDisutility3Fast(networkBike,bike,TransportMode.bike,ttBikeFast,false), ttBike, null,savePath);
calc.network("bike_short", ORIGIN, DESTINATION, bike, networkBike, networkBike, new DistanceDisutility(), ttBikeFast, null,savePath);
calc.network("bike_fast", ORIGIN, DESTINATION, bike, networkBike, networkBike, new OnlyTimeDependentTravelDisutility(ttBikeFast), ttBike, null,savePath);
calc.network("bike_short", ORIGIN, DESTINATION, bike, networkBike, networkBike, new DistanceDisutility(), ttBikeFast, ActiveAttributes.getJibeDist(TransportMode.bike),savePath);
calc.network("bike_fast", ORIGIN, DESTINATION, bike, networkBike, networkBike, new OnlyTimeDependentTravelDisutility(ttBikeFast), ttBike, ActiveAttributes.getJibeTime(TransportMode.bike,bike),savePath);

// walk
// calc.network("walk_jibe_day", ORIGIN, DESTINATION, null, networkWalk, networkWalk, new JibeDisutility3Fast(networkWalk,null,TransportMode.walk,ttWalk,true), ttWalk, null, savePath);
// calc.network("walk_jibe_night", ORIGIN, DESTINATION, null, networkWalk, networkWalk, new JibeDisutility3Fast(networkWalk,null,TransportMode.walk,ttWalk,false), ttWalk, null, savePath);
calc.network("walk_short", ORIGIN, DESTINATION, null, networkWalk, networkWalk, new DistanceDisutility(), ttWalk, null,savePath);
calc.network("walk_fast", ORIGIN, DESTINATION, null, networkWalk, networkWalk, new OnlyTimeDependentTravelDisutility(ttWalk), ttWalk, null,savePath);
calc.network("walk_short", ORIGIN, DESTINATION, null, networkWalk, networkWalk, new DistanceDisutility(), ttWalk, ActiveAttributes.getJibeDist(TransportMode.walk),savePath);
calc.network("walk_fast", ORIGIN, DESTINATION, null, networkWalk, networkWalk, new OnlyTimeDependentTravelDisutility(ttWalk), ttWalk, ActiveAttributes.getJibeTime(TransportMode.walk,null),savePath);

// // public transport
// calc.pt("pt", ORIGIN, DESTINATION, config, transitScheduleFilePath, transitNetworkFilePath);
Expand Down
40 changes: 33 additions & 7 deletions src/main/java/routing/ActiveAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,56 @@ public static LinkedHashMap<String,TravelAttribute> getJibe(String mode, Vehicle
return attributes;
}

public static LinkedHashMap<String,TravelAttribute> getJibe3(String mode, Vehicle veh) {
public static LinkedHashMap<String,TravelAttribute> getJibeTime(String mode, Vehicle veh) {
LinkedHashMap<String,TravelAttribute> attributes = new LinkedHashMap<>();
attributes.put("gradient",(l,td,tt) -> Math.max(Math.min(Gradient.getGradient(l),0.5),0.) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("comfort",(l,td,tt) -> LinkComfort.getComfortFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("vgvi",(l,td,tt) -> LinkAmbience.getVgviFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
// attributes.put("lighting",(l,td,tt) -> LinkAmbience.getLightingFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("shannon", (l,td,tt) -> LinkAmbience.getShannonFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("shannon_adj", (l,td,tt) -> LinkAmbience.getShannonFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("shannon_sum", (l,td,tt) -> (double) l.getAttributes().getAttribute("shannon") * tt.getLinkTravelTime(l,0.,null,veh));
// attributes.put("crime", (l,td,tt) -> LinkAmbience.getCrimeFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("POIs",(l,td,tt) -> LinkAmbience.getPoiFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("negPOIs",(l,td,tt) -> LinkAmbience.getNegativePoiFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("POI_adj",(l,td,tt) -> LinkAmbience.getPoiFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("POI_count",(l,td,tt) -> ((Integer) l.getAttributes().getAttribute("POIs")).doubleValue());
attributes.put("negPOI_adj",(l,td,tt) -> LinkAmbience.getNegativePoiFactor(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("negPOI_count",(l,td,tt) -> ((Integer) l.getAttributes().getAttribute("negPOIs")).doubleValue());
// attributes.put("ambience", (l,td,tt) -> LinkAmbience.getDayAmbience(l) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("stressLink",(l,td,tt) -> LinkStress.getStress(l,mode) * tt.getLinkTravelTime(l,0.,null,veh));
attributes.put("stressJct",(l,td,tt) -> getJibe3StressJct(mode,l,tt,veh));
attributes.put("stressJct",(l,td,tt) -> getJibe3StressJctTime(mode,l,tt,veh));
return attributes;
}

public static LinkedHashMap<String,TravelAttribute> getJibeDist(String mode) {
LinkedHashMap<String,TravelAttribute> attributes = new LinkedHashMap<>();
attributes.put("gradient",(l,td,tt) -> Math.max(Math.min(Gradient.getGradient(l),0.5),0.) * l.getLength());
attributes.put("comfort",(l,td,tt) -> LinkComfort.getComfortFactor(l) * l.getLength());
attributes.put("vgvi",(l,td,tt) -> LinkAmbience.getVgviFactor(l) * l.getLength());
// attributes.put("lighting",(l,td,tt) -> LinkAmbience.getLightingFactor(l) * l.getLength());
attributes.put("shannon_adj", (l,td,tt) -> LinkAmbience.getShannonFactor(l) * l.getLength());
attributes.put("shannon_sum", (l,td,tt) -> (double) l.getAttributes().getAttribute("shannon") * l.getLength());
// attributes.put("crime", (l,td,tt) -> LinkAmbience.getCrimeFactor(l) * l.getLength());
attributes.put("POI_adj",(l,td,tt) -> LinkAmbience.getPoiFactor(l) * l.getLength());
attributes.put("POI_count",(l,td,tt) -> ((Integer) l.getAttributes().getAttribute("POIs")).doubleValue());
attributes.put("negPOI_adj",(l,td,tt) -> LinkAmbience.getNegativePoiFactor(l) * l.getLength());
attributes.put("negPOI_count",(l,td,tt) -> ((Integer) l.getAttributes().getAttribute("negPOIs")).doubleValue());
// attributes.put("ambience", (l,td,tt) -> LinkAmbience.getDayAmbience(l) * l.getLength());
attributes.put("stressLink",(l,td,tt) -> LinkStress.getStress(l,mode) * l.getLength());
attributes.put("stressJct",(l,td,tt) -> getJibe3StressJctDist(mode,l));
return attributes;
}


private static double getJibe3StressJct(String mode, Link l, TravelTime tt, Vehicle veh) {
private static double getJibe3StressJctTime(String mode, Link l, TravelTime tt, Vehicle veh) {
if((boolean) l.getAttributes().getAttribute("crossVehicles")) {
return JctStress.getStress(l,mode) * tt.getLinkTravelTime(l,0.,null,veh) *
(Math.min((double) l.getAttributes().getAttribute("crossWidth") / l.getLength(), 1.));
} else return 0.;
}

private static double getJibe3StressJctDist(String mode, Link l) {
if((boolean) l.getAttributes().getAttribute("crossVehicles")) {
return JctStress.getStress(l,mode) * Math.min((double) l.getAttributes().getAttribute("crossWidth"), l.getLength());
} else return 0.;
}


}

0 comments on commit 73fc95d

Please sign in to comment.