-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/main/java/org/matsim/run/policies/OpenBerlinChoiceExperiment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.matsim.run.policies; | ||
|
||
import org.matsim.api.core.v01.Scenario; | ||
import org.matsim.api.core.v01.TransportMode; | ||
import org.matsim.api.core.v01.population.Leg; | ||
import org.matsim.api.core.v01.population.Person; | ||
import org.matsim.api.core.v01.population.Plan; | ||
import org.matsim.application.MATSimApplication; | ||
import org.matsim.core.router.TripStructureUtils; | ||
import org.matsim.run.OpenBerlinScenario; | ||
import picocli.CommandLine; | ||
|
||
/** | ||
* This class can be used to run some synthetic choice experiments on the OpenBerlin scenario. | ||
*/ | ||
public class OpenBerlinChoiceExperiment extends OpenBerlinScenario { | ||
|
||
@CommandLine.Option(names = "--bike-speed-factor", description = "Speed factor for bikes", defaultValue = "1.0") | ||
private double bikeSpeedFactor = 1.0; | ||
|
||
public static void main(String[] args) { | ||
MATSimApplication.execute(OpenBerlinChoiceExperiment.class, args); | ||
} | ||
|
||
@Override | ||
protected void prepareScenario(Scenario scenario) { | ||
|
||
super.prepareScenario(scenario); | ||
|
||
// If bike speed is adjusted, we need to remove all bike routes and travel times | ||
// These times will be recalculated by the router | ||
if (bikeSpeedFactor != 1.0) { | ||
for (Person person : scenario.getPopulation().getPersons().values()) { | ||
for (Plan plan : person.getPlans()) { | ||
for (Leg leg : TripStructureUtils.getLegs(plan)) { | ||
if (leg.getMode().equals(TransportMode.bike)) { | ||
leg.setRoute(null); | ||
leg.setTravelTimeUndefined(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |