public void run() { new MatsimNetworkReader(scenario).readFile(scenario.getConfig().network().getInputFile()); new TransitScheduleReaderV1(scenario) .readFile(this.scenario.getConfig().transit().getTransitScheduleFile()); Logger.getLogger(this.getClass()) .fatal( "cannot say if the following should be vehicles or transit vehicles; aborting ... . kai, feb'15"); System.exit(-1); new VehicleReaderV1((scenario).getTransitVehicles()) .readFile(this.scenario.getConfig().transit().getVehiclesFile()); Controler controler = new Controler(this.scenario); controler .getConfig() .controler() .setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.addOverridingModule(new OTFVisFileWriterModule()); controler.addControlerListener( new OptControlerListener( this.fare, this.scenario, this.calculate_inVehicleTimeDelayEffects, this.calculate_waitingTimeDelayEffects, this.calculate_capacityDelayEffects, this.marginalCostPricingPt, this.calculate_carCongestionEffects, this.marginalCostPricingCar)); ControlerConfigGroup controlerConfGroup = controler.getConfig().controler(); if (controlerConfGroup.getLastIteration() == 0) { controlerConfGroup.setWriteEventsInterval(1); controlerConfGroup.setWritePlansInterval(1); } else { controlerConfGroup.setWriteEventsInterval(controlerConfGroup.getLastIteration()); controlerConfGroup.setWritePlansInterval(controlerConfGroup.getLastIteration()); } PlanCalcScoreConfigGroup planCalcScoreConfigGroup = controler.getConfig().planCalcScore(); planCalcScoreConfigGroup.setMarginalUtilityOfMoney(MARGINAL_UTILITY_OF_MONEY); planCalcScoreConfigGroup.setPerforming_utils_hr(PERFORMING); planCalcScoreConfigGroup.getModes().get(TransportMode.car).setConstant(CONSTANT_CAR); planCalcScoreConfigGroup .getModes() .get(TransportMode.car) .setMarginalUtilityOfTraveling(TRAVEL_CAR); planCalcScoreConfigGroup .getModes() .get(TransportMode.car) .setMonetaryDistanceRate(MONETARY_DISTANCE_COST_RATE_CAR); planCalcScoreConfigGroup.getModes().get(TransportMode.walk).setConstant(CONSTANT_WALK); planCalcScoreConfigGroup .getModes() .get(TransportMode.walk) .setMarginalUtilityOfTraveling(TRAVEL_WALK); planCalcScoreConfigGroup .getModes() .get(TransportMode.pt) .setMonetaryDistanceRate(MONETARY_DISTANCE_COST_RATE_PT); planCalcScoreConfigGroup.getModes().get(TransportMode.pt).setConstant(CONSTANT_PT); planCalcScoreConfigGroup .getModes() .get(TransportMode.pt) .setMarginalUtilityOfTraveling(TRAVEL_PT_IN_VEHICLE); planCalcScoreConfigGroup.setMarginalUtlOfWaitingPt_utils_hr(TRAVEL_PT_WAITING); planCalcScoreConfigGroup.setUtilityOfLineSwitch(LINE_SWITCH); planCalcScoreConfigGroup.setLateArrival_utils_hr(LATE_ARRIVAL); planCalcScoreConfigGroup.setEarlyDeparture_utils_hr(EARLY_DEPARTURE); planCalcScoreConfigGroup.setMarginalUtlOfWaiting_utils_hr(WAITING); OptimizationScoringFunctionFactory scoringfactory = new OptimizationScoringFunctionFactory(scenario, STUCK_SCORE); controler.setScoringFunctionFactory(scoringfactory); controler.getConfig().controler().setCreateGraphs(false); controler.run(); }
public static void main(String[] args) { Config config = new Config(); config.addCoreModules(); Controler controler = new Controler(config); // controler settings controler .getConfig() .controler() .setOverwriteFileSetting( true ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); controler.getConfig().controler().setCreateGraphs(false); // controlerConfigGroup ControlerConfigGroup ccg = controler.getConfig().controler(); ccg.setOutputDirectory(outputPath); ccg.setFirstIteration(0); ccg.setLastIteration(0); ccg.setMobsim("qsim"); Set set = new HashSet(); set.add(EventsFileFormat.xml); ccg.setEventsFileFormats(set); // ccg.setRunId("321"); // qsimConfigGroup QSimConfigGroup qcg = controler.getConfig().qsim(); qcg.setStartTime(0 * 3600.); qcg.setEndTime(30 * 3600.); qcg.setFlowCapFactor(0.1); qcg.setStorageCapFactor(0.3); // qcg.setFlowCapFactor(0.01); // qcg.setStorageCapFactor(0.03); qcg.setNumberOfThreads(1); qcg.setRemoveStuckVehicles(false); qcg.setStuckTime(10.0); // planCalcScoreConfigGroup PlanCalcScoreConfigGroup pcs = controler.getConfig().planCalcScore(); Set<String> activities = new HashSet<String>(); activities.add("unknown"); activities.add("work"); activities.add("pickup"); activities.add("with adult"); activities.add("other"); activities.add("pvWork"); activities.add("pvHome"); activities.add("gvHome"); activities.add("education"); activities.add("business"); activities.add("shopping"); activities.add("private"); activities.add("leisure"); activities.add("sports"); activities.add("home"); activities.add("friends"); for (String activity : activities) { ActivityParams params = new ActivityParams(activity); params.setTypicalDuration(30 * 3600); pcs.addActivityParams(params); } // strategy StrategyConfigGroup scg = controler.getConfig().strategy(); StrategySettings strategySettings = new StrategySettings(Id.create("1", StrategySettings.class)); strategySettings.setStrategyName("ChangeExpBeta"); strategySettings.setWeight(1.0); scg.addStrategySettings(strategySettings); // network NetworkConfigGroup ncg = controler.getConfig().network(); ncg.setInputFile(networkFile); // plans PlansConfigGroup pcg = controler.getConfig().plans(); pcg.setInputFile(plansFile); // define emission tool input files EmissionsConfigGroup ecg = new EmissionsConfigGroup(); controler.getConfig().addModule(ecg); ecg.setEmissionRoadTypeMappingFile(roadTypeMappingFile); ecg.setEmissionVehicleFile(emissionVehicleFile); ecg.setAverageWarmEmissionFactorsFile(averageFleetWarmEmissionFactorsFile); ecg.setAverageColdEmissionFactorsFile(averageFleetColdEmissionFactorsFile); ecg.setUsingDetailedEmissionCalculation(isUsingDetailedEmissionCalculation); ecg.setDetailedWarmEmissionFactorsFile(detailedWarmEmissionFactorsFile); ecg.setDetailedColdEmissionFactorsFile(detailedColdEmissionFactorsFile); // TODO: the following does not work yet. Need to force controler to always write events in the // last iteration. VspExperimentalConfigGroup vcg = controler.getConfig().vspExperimental(); vcg.setWritingOutputEvents(false); controler.addControlerListener(new EmissionControlerListener()); controler.run(); }
@Inject PlansDumpingImpl(ControlerConfigGroup config) { this.firstIteration = config.getFirstIteration(); this.writePlansInterval = config.getWritePlansInterval(); }