public static void main(String[] args) { Config config; if (args.length == 1) { LOG.info("A user-specified config.xml file was provided. Using it..."); config = ConfigUtils.loadConfig(args[0], new BicycleConfigGroup()); fillConfigWithBicycleStandardValues(config); } else if (args.length == 0) { LOG.info("No config.xml file was provided. Using 'standard' example files given in this contrib's resources folder."); // Setting the context like this works when the data is stored under "/matsim/contribs/bicycle/src/main/resources/bicycle_example" config = ConfigUtils.createConfig("bicycle_example/"); config.addModule(new BicycleConfigGroup()); fillConfigWithBicycleStandardValues(config); config.network().setInputFile("network_lane.xml"); // Modify this config.plans().setInputFile("population_1200.xml"); } else { throw new RuntimeException("More than one argument was provided. There is no procedure for this situation. Thus aborting!" + " Provide either (1) only a suitable config file or (2) no argument at all to run example with given example of resources folder."); } config.controler().setLastIteration(100); // Modify if motorized interaction is used boolean considerMotorizedInteraction = false; new RunBicycleExample().run(config, considerMotorizedInteraction); }
public TimeAllocationMutator(Provider<TripRouter> tripRouterProvider, PlansConfigGroup plansConfigGroup, TimeAllocationMutatorConfigGroup timeAllocationMutatorConfigGroup, GlobalConfigGroup globalConfigGroup, final Population population) { super(globalConfigGroup); this.tripRouterProvider = tripRouterProvider; this.activityDurationInterpretation = plansConfigGroup.getActivityDurationInterpretation(); this.mutationRange = timeAllocationMutatorConfigGroup.getMutationRange(); this.affectingDuration = timeAllocationMutatorConfigGroup.isAffectingDuration(); // in case we have subpopulations and individual settings for them if (plansConfigGroup.getSubpopulationAttributeName() != null && timeAllocationMutatorConfigGroup.isUseIndividualSettingsForSubpopulations() && population != null) { this.subpopulationAttribute = plansConfigGroup.getSubpopulationAttributeName(); this.subpopulationMutationRanges = new HashMap<>(); this.subpopulationAffectingDuration = new HashMap<>(); this.personAttributes = population.getPersonAttributes(); Collection<? extends ConfigGroup> settings = timeAllocationMutatorConfigGroup.getParameterSets(TimeAllocationMutatorSubpopulationSettings.SET_NAME); for (ConfigGroup group : settings) { TimeAllocationMutatorSubpopulationSettings subpopulationSettings = (TimeAllocationMutatorSubpopulationSettings) group; String subpopulation = subpopulationSettings.getSubpopulation(); this.subpopulationMutationRanges.put(subpopulation, subpopulationSettings.getMutationRange()); this.subpopulationAffectingDuration.put(subpopulation, subpopulationSettings.isAffectingDuration()); log.info("Found individual time mutator settings for subpopulation: " + subpopulation); } } else { this.personAttributes = null; this.subpopulationAttribute = null; this.subpopulationMutationRanges = null; this.subpopulationAffectingDuration = null; } }
public static void setVspDefaults(final Config config) { config.timeAllocationMutator().setMutationRange(7200.); config.timeAllocationMutator().setAffectingDuration(false); config.plans().setRemovingUnneccessaryPlanAttributes(true); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration); config.vspExperimental().setVspDefaultsCheckingLevel(VspDefaultsCheckingLevel.warn); }
@Override public void install() { PlansConfigGroup.ActivityDurationInterpretation actDurInterpr = getConfig().plans().getActivityDurationInterpretation() ; if ( actDurInterpr != PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime || getConfig().plans().isRemovingUnneccessaryPlanAttributes() ) { addControlerListenerBinding().to(VspPlansCleaner.class); } } }
config.plans().setInputFile( populationFilename ); config.plans().setInputPersonAttributeFile( popAttrFilename ); ConfigUtils.addOrGetModule(config, RoadPricingConfigGroup.GROUP_NAME, RoadPricingConfigGroup.class).setTollLinksFile(tollFilename);
config.plans().setInputFile(getAbsolutePath(prefix, config.plans().getInputFile())); config.facilities().setInputFile(getAbsolutePath(prefix, config.facilities().getInputFile())); config.counts().setInputFile(getAbsolutePath(prefix, config.counts().getCountsFileName()));
config.plans().setInputCRS( INITIAL_CRS ); config.global().setCoordinateSystem( TARGET_CRS ); config.plans().setInputFile( BASE_FILE );
@Inject SubpopulationScoringParameters(PlansConfigGroup plansConfigGroup, PlanCalcScoreConfigGroup planCalcScoreConfigGroup, ScenarioConfigGroup scenarioConfigGroup, Population population, TransitConfigGroup transitConfigGroup) { this.config = planCalcScoreConfigGroup; this.scConfig = scenarioConfigGroup; this.transitConfigGroup = transitConfigGroup; this.personAttributes = population.getPersonAttributes(); this.subpopulationAttributeName = plansConfigGroup.getSubpopulationAttributeName(); }
/** * Creates a new TimeAllocationMutator with a mutation range as defined in * the configuration (module "TimeAllocationMutator", param "mutationRange"). */ @Deprecated public TimeAllocationMutator(Config config, Provider<TripRouter> tripRouterProvider, final double mutationRange, boolean affectingDuration) { super(config.global()); this.tripRouterProvider = tripRouterProvider; this.affectingDuration = affectingDuration; this.mutationRange = mutationRange; this.activityDurationInterpretation = (config.plans().getActivityDurationInterpretation()); this.personAttributes = null; this.subpopulationAttribute = null; this.subpopulationMutationRanges = null; this.subpopulationAffectingDuration = null; log.warn("deprecated constructor was used - individual time allocation mutator settings for subpopulations is not supported!"); }
config.plans().setActivityDurationInterpretation(ActivityDurationInterpretation.tryEndTimeThenDuration);
final String netFile = directory+"/net.xml"; config.plans().setInputFile( plansFile ); config.plans().setInputPersonAttributeFile( attributeFile ); config.network().setInputFile( netFile );
private static String identifySubpopulation( final ReplanningGroup g, final Scenario sc) { final String attName = sc.getConfig().plans().getSubpopulationAttributeName(); final ObjectAttributes atts = sc.getPopulation().getPersonAttributes(); String name = null; for ( Person p : g.getPersons() ) { final String persSubPop = (String) atts.getAttribute( p.getId().toString() , attName ); if ( persSubPop == null && name != null ) throw new RuntimeException( "inconsistent subpopulations in group "+g ); if ( name != null && !name.equals( persSubPop ) ) throw new RuntimeException( "inconsistent subpopulations in group "+g ); name = persSubPop; } return name; }
@Inject public JDEQSimulation(final JDEQSimConfigGroup config, final Scenario scenario, final EventsManager events) { Road.setConfig(config); Message.setEventsManager(events); this.config = config; this.scenario = scenario; this.events = events; this.activityDurationInterpretation = this.scenario.getConfig().plans().getActivityDurationInterpretation(); }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { PlansConfigGroup.ActivityDurationInterpretation actDurInterp = (plansConfigGroup.getActivityDurationInterpretation() ) ; for ( Person person : population.getPersons().values() ) { if (plansConfigGroup.isRemovingUnneccessaryPlanAttributes()) { act.setStartTime(Time.UNDEFINED_TIME) ; if (plansConfigGroup.isRemovingUnneccessaryPlanAttributes()) {
config.planCalcScore().setLearningRate(1.0); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.minOfDurationAndEndTime);
config.controler().setWriteSnapshotsInterval(0); config.plans().setInputFile(null);
private String getSubpopName(Person person) { return "yy_" + getSubpopName( person.getId(), this.population.getPersonAttributes(), this.scenario.getConfig().plans().getSubpopulationAttributeName() ) ; } public static final String getSubpopName( Id<Person> personId, ObjectAttributes personAttributes, String subpopAttrName ) {
@Override public boolean handleActivity(MobsimAgent agent) { // We expect all the agents to appear here at the beginning of the simulation (starting their // overnight activity.) That's when we enter them into JDEQSim and never let them out. new Vehicle(scheduler, ((HasPerson) agent).getPerson(), scenario.getConfig().plans().getActivityDurationInterpretation()); numberOfAgents++; return true; }
if ( !config.plans().isRemovingUnneccessaryPlanAttributes() ) { problem = true ; System.out.flush() ; PlansConfigGroup.ActivityDurationInterpretation actDurInterpr = config.plans().getActivityDurationInterpretation() ; if ( actDurInterpr == PlansConfigGroup.ActivityDurationInterpretation.endTimeOnly ) { problem = true; System.out.flush() ; log.error("You are using " + config.plans().getActivityDurationInterpretation() + " as activityDurationInterpretation in " + "conjunction with the matsim transit module. This is not working at all as pt interaction activities never have an end time and " + "thus will never end!"); problem = true ; System.out.flush() ; log.log( lvl, "You are using ActivityDurationInterpretation " + config.plans().getActivityDurationInterpretation() + " ; vsp default is to use " + PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration + "This means you have to add the following lines into the vspExperimental section of your config file: ") ;
public static void populationWithBDIAttributeExample() { { Config config = ConfigUtils.createConfig() ; Scenario scenario = ScenarioUtils.createScenario( config ) ; Population pop = scenario.getPopulation() ; PopulationFactory pf = pop.getFactory() ; for ( int ii=0 ; ii<10 ; ii++ ) { Person person = pf.createPerson( Id.createPersonId(ii)) ; person.getAttributes().putAttribute("isBDIAgent", true ) ; pop.addPerson(person); } PopulationUtils.writePopulation(pop, "pop.xml"); } { Config config = ConfigUtils.createConfig() ; config.plans().setInputFile("pop.xml"); Scenario scenario = ScenarioUtils.loadScenario( config ) ; for ( Person person : scenario.getPopulation().getPersons().values() ) { final String attribute = (String) person.getAttributes().getAttribute("isBDIAgent"); System.out.println( "id=" + person.getId() + "; isBdi=" + attribute ) ; } } }