To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 3bc2e8ec authored by Sebastian Hörl's avatar Sebastian Hörl
Browse files

Initial commit

parent f22754ec
......@@ -14,6 +14,10 @@ import org.matsim.vehicles.VehicleTypeImpl;
import com.google.inject.name.Names;
import ch.ethz.matsim.av.config.AVConfig;
import ch.ethz.matsim.av.config.AVDispatcherConfig;
import ch.ethz.matsim.av.config.AVGeneratorConfig;
import ch.ethz.matsim.av.config.AVOperatorConfig;
import ch.ethz.matsim.av.framework.AVConfigGroup;
import ch.ethz.matsim.av.framework.AVModule;
import ch.ethz.matsim.av.routing.AVRoute;
......@@ -28,9 +32,11 @@ import ch.ethz.matsim.projects.astra.analysis.AnalysisModule;
import ch.ethz.matsim.projects.astra.av.ASTRAAVModule;
import ch.ethz.matsim.projects.astra.av.ASTRAQSimModule;
import ch.ethz.matsim.projects.astra.av.pricing.AVPriceCalculationConfigGroup;
import ch.ethz.matsim.projects.astra.av.pricing.AVPriceCalculationMode;
import ch.ethz.matsim.projects.astra.av.pricing.AVPriceCalculationModule;
import ch.ethz.matsim.projects.astra.av.waiting_time.AVWaitingTimeCalculatorConfigGroup;
import ch.ethz.matsim.projects.astra.av.waiting_time.AVWaitingTimeCalculatorModule;
import ch.ethz.matsim.projects.astra.av.waiting_time.AVWaitingTimeCalculatorType;
import ch.ethz.matsim.projects.astra.av.waiting_time.kernel.KernelWaitingTimeCalculatorConfigGroup;
import ch.ethz.matsim.projects.astra.av.waiting_time.zonal.ZonalWaitingTimeCalculatorConfigGroup;
import ch.ethz.matsim.projects.astra.config.ASTRAConfigGroup;
......@@ -40,10 +46,21 @@ import ch.ethz.matsim.projects.astra.traffic.ASTRATrafficModule;
public class RunScenario {
static public void main(String[] args) {
Config config = ConfigUtils.loadConfig(args[0], new ASTRAConfigGroup(), new AVConfigGroup(),
new DvrpConfigGroup(), new AVPriceCalculationConfigGroup(), new AVWaitingTimeCalculatorConfigGroup(),
new KernelWaitingTimeCalculatorConfigGroup(), new ZonalWaitingTimeCalculatorConfigGroup());
ASTRAConfigGroup astraConfig = new ASTRAConfigGroup();
AVPriceCalculationConfigGroup pricingConfig = new AVPriceCalculationConfigGroup();
AVWaitingTimeCalculatorConfigGroup waitingTimeConfig = new AVWaitingTimeCalculatorConfigGroup();
Config config = ConfigUtils.loadConfig(args[0], astraConfig, new DvrpConfigGroup(), pricingConfig,
new AVWaitingTimeCalculatorConfigGroup(), new KernelWaitingTimeCalculatorConfigGroup(),
new ZonalWaitingTimeCalculatorConfigGroup(), new AVConfigGroup());
double flowEfficiencyFactor = Double.parseDouble(args[1]);
long numberOfVehicles = Long.parseLong(args[2]);
String shapeFile = args.length > 3 ? args[3] : null;
astraConfig.setBaseline(true);
pricingConfig.setMode(AVPriceCalculationMode.FIXED);
waitingTimeConfig.setCalculator(AVWaitingTimeCalculatorType.FIXED);
Scenario scenario = ScenarioUtils.createScenario(config);
scenario.getPopulation().getFactory().getRouteFactories().setRouteFactory(AVRoute.class, new AVRouteFactory());
......@@ -68,6 +85,20 @@ public class RunScenario {
controler.addOverridingModule(new AVPriceCalculationModule());
controler.addOverridingModule(new ModeShareListenerModule());
// Configure service
AVConfig avConfig = new AVConfig();
AVOperatorConfig operatorConfig = avConfig.createOperatorConfig("sav");
AVDispatcherConfig dispatcherConfig = operatorConfig.createDispatcherConfig("SingleHeuristic");
if (shapeFile != null) {
dispatcherConfig.addParam("areaShapefile", shapeFile);
}
AVGeneratorConfig generatorConfig = operatorConfig.createGeneratorConfig("ASTRA");
generatorConfig.setNumberOfVehicles(numberOfVehicles);
// Configure flow efficiency of shared AVs
VehicleType avType = new VehicleTypeImpl(Id.create("sav", VehicleType.class));
......@@ -77,6 +108,7 @@ public class RunScenario {
@Override
public void install() {
bind(VehicleType.class).annotatedWith(Names.named(AVModule.AV_MODE)).toInstance(avType);
bind(AVConfig.class).toInstance(avConfig);
}
});
......
package ch.ethz.matsim.students_fs18.zenhaeusern;
import java.io.File;
import java.util.Arrays;
import java.util.Random;
import org.matsim.api.core.v01.Scenario;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.network.io.MatsimNetworkReader;
import org.matsim.core.population.io.PopulationReader;
import org.matsim.core.population.io.PopulationWriter;
import org.matsim.core.router.MainModeIdentifier;
import org.matsim.core.router.MainModeIdentifierImpl;
import org.matsim.core.router.StageActivityTypes;
import org.matsim.core.router.StageActivityTypesImpl;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.pt.PtConstants;
import ch.ethz.matsim.baseline_scenario.transit.routing.DefaultEnrichedTransitRoute;
import ch.ethz.matsim.baseline_scenario.transit.routing.DefaultEnrichedTransitRouteFactory;
import ch.ethz.matsim.projects.astra.av.area.AVServiceArea;
import ch.ethz.matsim.projects.astra.av.area.FullServiceArea;
import ch.ethz.matsim.projects.astra.av.area.SHPServiceArea;
import ch.ethz.matsim.projects.astra.av.tools.FeasibleTripFinder;
import ch.ethz.matsim.projects.astra.av.tools.TripAssignment;
import ch.ethz.matsim.projects.astra.mode_choice.ASTRAChainAlternatives;
import ch.ethz.matsim.projects.astra.utils.LongPlanFilter;
public class RunTripAssignment {
static public void main(String[] args) {
String inputPopulationPath = args[0];
String inputNetworkPath = args[1];
String inputShapefilePath = args[2];
String outputPopulationPath = args[3];
String mode = args[4];
double probability = Double.parseDouble(args[5]);
Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
scenario.getPopulation().getFactory().getRouteFactories().setRouteFactory(DefaultEnrichedTransitRoute.class,
new DefaultEnrichedTransitRouteFactory());
new MatsimNetworkReader(scenario.getNetwork()).readFile(inputNetworkPath);
new PopulationReader(scenario).readFile(inputPopulationPath);
new LongPlanFilter(10, new StageActivityTypesImpl(PtConstants.TRANSIT_ACTIVITY_TYPE))
.run(scenario.getPopulation());
StageActivityTypes stageActivityTypes = new StageActivityTypesImpl(PtConstants.TRANSIT_ACTIVITY_TYPE);
MainModeIdentifier mainModeIdentifier = new MainModeIdentifierImpl();
ASTRAChainAlternatives chainAlternatives = new ASTRAChainAlternatives(stageActivityTypes, mainModeIdentifier);
AVServiceArea serviceArea = new FullServiceArea();
if (!inputShapefilePath.equals("full")) {
serviceArea = SHPServiceArea.load(scenario.getNetwork(), new File(inputShapefilePath));
}
FeasibleTripFinder tripFinder = new FeasibleTripFinder(scenario.getNetwork(), chainAlternatives,
stageActivityTypes, mainModeIdentifier, serviceArea, Arrays.asList("walk", "pt", "av"),
Arrays.asList("car", "bike"), "av", Arrays.asList("car", "pt"));
TripAssignment tripAssignment = new TripAssignment(new Random(0), tripFinder, stageActivityTypes, "av");
switch (mode) {
case "person":
tripAssignment.assignByPerson(scenario.getPopulation(), probability);
break;
case "trip":
tripAssignment.assignByTrip(scenario.getPopulation(), probability);
break;
default:
throw new IllegalStateException("Unknown mode. Use 'person' or 'trip'.");
}
new PopulationWriter(scenario.getPopulation()).write(outputPopulationPath);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment