Skip to content

Commit

Permalink
add enum case for teleported bike
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Sep 21, 2023
1 parent 3219b0c commit ca82018
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/main/java/org/matsim/run/RunLeipzigScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@

import javax.annotation.Nullable;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.*;

/**
* Run the Leipzig scenario. All the upstream stuff (network generation, initial demand generation) is in the Makefile.
Expand Down Expand Up @@ -236,7 +233,32 @@ protected Config prepareConfig(Config config) {
BicycleConfigGroup bikeConfigGroup = ConfigUtils.addOrGetModule(config, BicycleConfigGroup.class);
bikeConfigGroup.setBicycleMode(TransportMode.bike);
}
//TODO we may have to implement another case for bikeTeleportedStandardMATSim
case bikeTeleportedStandardMatsim -> {

log.info("Simulating with bikes teleported");
PlansCalcRouteConfigGroup plansCalcRouteConfigGroup = ConfigUtils.addOrGetModule(config, PlansCalcRouteConfigGroup.class);

if (plansCalcRouteConfigGroup.getNetworkModes().contains(TransportMode.bike)) {

Collection<String> networkModes = Sets.newHashSet();

for (String mode : plansCalcRouteConfigGroup.getNetworkModes()) {
if (!mode.equals(TransportMode.bike)) {
networkModes.add(mode);
}
}
plansCalcRouteConfigGroup.setNetworkModes(networkModes);
}

if (!plansCalcRouteConfigGroup.getTeleportedModeParams().containsKey(TransportMode.bike)) {
PlansCalcRouteConfigGroup.TeleportedModeParams teleportedModeParams = new PlansCalcRouteConfigGroup.TeleportedModeParams();
teleportedModeParams.setMode(TransportMode.bike);
teleportedModeParams.setBeelineDistanceFactor(1.3);
teleportedModeParams.setTeleportedModeSpeed(3.1388889);
plansCalcRouteConfigGroup.addTeleportedModeParams(teleportedModeParams);
}
}

default -> throw new IllegalStateException("Unexpected value: " + (bike));
}

Expand Down Expand Up @@ -319,5 +341,5 @@ public void install() {
/**
* Defines how bicycles are scored.
*/
enum BicycleHandling {onNetworkWithStandardMatsim, onNetworkWithBicycleContrib}
enum BicycleHandling {onNetworkWithStandardMatsim, onNetworkWithBicycleContrib, bikeTeleportedStandardMatsim}
}

0 comments on commit ca82018

Please sign in to comment.