-
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
1 parent
4071c94
commit 45a039c
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/org/matsim/prepare/olympiastadion_study/PrepareDummyPlans.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,38 @@ | ||
package org.matsim.prepare.olympiastadion_study; | ||
|
||
import org.matsim.api.core.v01.Coord; | ||
import org.matsim.api.core.v01.Id; | ||
import org.matsim.api.core.v01.TransportMode; | ||
import org.matsim.api.core.v01.population.*; | ||
import org.matsim.core.config.ConfigUtils; | ||
import org.matsim.core.population.PopulationUtils; | ||
|
||
import java.util.Random; | ||
|
||
public class PrepareDummyPlans { | ||
public static void main(String[] args) { | ||
Population population = PopulationUtils.createPopulation(ConfigUtils.createConfig()); | ||
PopulationFactory factory = population.getFactory(); | ||
Random random = new Random(1); | ||
|
||
for (int i = 0; i < 100; i++) { | ||
Person person = factory.createPerson(Id.createPersonId("dummy_" + i)); | ||
Plan plan = factory.createPlan(); | ||
// Olympiastadion | ||
Activity fromAct = factory.createActivityFromCoord("dummy", new Coord(787944, 5826767)); | ||
// for testing, we use a time when PT supply is good | ||
fromAct.setEndTime(15 * 3600 + random.nextInt(3600)); | ||
Leg leg = factory.createLeg(TransportMode.pt); | ||
// Berlin Hbf | ||
Activity toAct = factory.createActivityFromCoord("dummy", new Coord(796465, 5828241)); | ||
|
||
plan.addActivity(fromAct); | ||
plan.addLeg(leg); | ||
plan.addActivity(toAct); | ||
person.addPlan(plan); | ||
population.addPerson(person); | ||
} | ||
|
||
new PopulationWriter(population).write("/Users/luchengqi/Documents/MATSimScenarios/Berlin/olympiastadion-study/testing-plans/dummy-plans.xml.gz"); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/org/matsim/run/olympiastadion_study/RunWithTestingPlans.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,65 @@ | ||
package org.matsim.run.olympiastadion_study; | ||
|
||
import org.matsim.api.core.v01.Scenario; | ||
import org.matsim.core.config.Config; | ||
import org.matsim.core.config.ConfigUtils; | ||
import org.matsim.core.config.groups.ReplanningConfigGroup; | ||
import org.matsim.core.config.groups.ScoringConfigGroup; | ||
import org.matsim.core.controler.Controler; | ||
import org.matsim.core.controler.OutputDirectoryHierarchy; | ||
import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; | ||
import org.matsim.core.scenario.ScenarioUtils; | ||
|
||
import static org.matsim.run.OpenBerlinScenario.CRS; | ||
|
||
public class RunWithTestingPlans { | ||
public static void main(String[] args) { | ||
Config config = ConfigUtils.createConfig(); | ||
config.network().setInputFile("https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v6.0/input/berlin-v6.0-network-with-pt.xml.gz"); | ||
config.plans().setInputFile("/Users/luchengqi/Documents/MATSimScenarios/Berlin/olympiastadion-study/testing-plans/dummy-plans.xml.gz"); | ||
config.transit().setTransitScheduleFile("https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v6.0/input/berlin-v6.0-transitSchedule.xml.gz"); | ||
config.transit().setVehiclesFile("https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v6.0/input/berlin-v6.0-transitVehicles.xml.gz"); | ||
config.transit().setUseTransit(true); | ||
|
||
config.qsim().setFlowCapFactor(1.0); | ||
config.qsim().setStorageCapFactor(1.0); | ||
|
||
ScoringConfigGroup.ActivityParams dummyAct = new ScoringConfigGroup.ActivityParams("dummy"); | ||
dummyAct.setTypicalDuration(3600); | ||
config.scoring().addActivityParams(dummyAct); | ||
|
||
config.global().setCoordinateSystem(CRS); | ||
|
||
config.replanning().addStrategySettings( | ||
new ReplanningConfigGroup.StrategySettings() | ||
.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta) | ||
.setWeight(0.7) | ||
); | ||
|
||
config.replanning().addStrategySettings( | ||
new ReplanningConfigGroup.StrategySettings() | ||
.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ReRoute) | ||
.setWeight(0.1) | ||
); | ||
|
||
config.replanning().addStrategySettings( | ||
new ReplanningConfigGroup.StrategySettings() | ||
.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.TimeAllocationMutator) | ||
.setWeight(0.1) | ||
); | ||
|
||
config.replanning().addStrategySettings( | ||
new ReplanningConfigGroup.StrategySettings() | ||
.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ChangeSingleTripMode) | ||
.setWeight(0.1) | ||
); | ||
|
||
config.controller().setLastIteration(1); | ||
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); | ||
config.controller().setOutputDirectory("/Users/luchengqi/Documents/MATSimScenarios/Berlin/olympiastadion-study/output/dummy-test"); | ||
|
||
Scenario scenario = ScenarioUtils.loadScenario(config); | ||
Controler controler = new Controler(scenario); | ||
controler.run(); | ||
} | ||
} |