Skip to content

Commit

Permalink
Add prepare and initial run script
Browse files Browse the repository at this point in the history
  • Loading branch information
luchengqi7 committed Oct 10, 2024
1 parent 4071c94 commit 45a039c
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
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");
}
}
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();
}
}

0 comments on commit 45a039c

Please sign in to comment.