private ActivityParams getActivityTypeByNumber(final String number) { ActivityParams actType = this.activityTypesByNumber.get(number); if ((actType == null)) { // not sure what this means, but I found it so... // TD, sep'14 actType = new ActivityParams(number); this.activityTypesByNumber.put(number, actType); addParameterSet(actType); } return actType; }
@Override public ConfigGroup createParameterSet(final String type) { switch (type) { case ActivityParams.SET_TYPE: return new ActivityParams(); case ModeParams.SET_TYPE: return new ModeParams(); default: throw new IllegalArgumentException(type); } }
public ActivityParams getOrCreateActivityParams(final String actType) { ActivityParams params = this.getActivityParamsPerType().get(actType); if (params == null) { params = new ActivityParams(actType); addActivityParams(params); } return params; }
ActivityParams params = new ActivityParams("h") ; params.setTypicalDuration(123456789.0) ; // probably dummy params.setScoringThisActivityAtAll(false);
ActivityParams homeActivity = new ActivityParams("home"); homeActivity.setTypicalDuration(12*60*60); config.planCalcScore().addActivityParams(homeActivity); ActivityParams workActivity = new ActivityParams("work"); workActivity.setTypicalDuration(8*60*60); config.planCalcScore().addActivityParams(workActivity);
ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); config.planCalcScore().addActivityParams(dummyAct);
config.addCoreModules(); ActivityParams workParams = new ActivityParams("work"); workParams.setTypicalDuration(60 * 60 * 8); config.planCalcScore().addActivityParams(workParams); ActivityParams homeParams = new ActivityParams("home"); homeParams.setTypicalDuration(16 * 60 * 60); config.planCalcScore().addActivityParams(homeParams);
generator.setAssignLinksToFacilitiesIfMissing(true, f.scenario.getNetwork()); PlanCalcScoreConfigGroup config = new PlanCalcScoreConfigGroup(); ActivityParams homeParams = new ActivityParams("home"); ActivityParams workParams = new ActivityParams("work"); workParams.setOpeningTime(7*3600); workParams.setClosingTime(19*3600);
final double traveling = -1200.0; config.planCalcScore().getModes().get(TransportMode.car).setMarginalUtilityOfTraveling(traveling); ActivityParams params = new ActivityParams("home"); params.setTypicalDuration(24.0 * 3600.0); config.planCalcScore().addActivityParams(params);
PlanCalcScoreConfigGroup.ActivityParams transitActivityParams = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setTypicalDuration(120.0); transitActivityParams.setOpeningTime(0.) ;
PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams("h2"); params.setTypicalDuration(8*3600);
/** * test simulated capacities of link 1 in case of one lane representing one lane. * the capacity of the link should correspond to the capacity of the lane, also when it is less than the link capacity given in the network. */ public void testCapacityWithOneLaneOneLane() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); config.planCalcScore().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); createOneLane(scenario, 1); initPopulation(scenario.getPopulation()); EventsManager events = EventsUtils.createEventsManager(); SimulatedCapacityHandler simulatedCapacity = new SimulatedCapacityHandler(); events.addHandler(simulatedCapacity); PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) // .useDefaults() // .build(scenario, events) // .run(); // check simulated capacity values assertEquals(simulatedCapacity.getSimulatedLaneCapacity(Id.create("1", Lane.class)), simulatedCapacity.getSimulatedLinkCapacity(), MatsimTestUtils.EPSILON); assertEquals(1800, simulatedCapacity.getSimulatedLaneCapacity(Id.create("1.ol", Lane.class)), MatsimTestUtils.EPSILON); assertEquals(900, simulatedCapacity.getSimulatedLaneCapacity(Id.create("1", Lane.class)), MatsimTestUtils.EPSILON); }
/** * test simulated capacities of link 1 in case of one lane representing two lanes. * the capacity of the link should correspond to the capacity of the lane, also when it is less than the link capacity given in the network. */ public void testCapacityWithOneLaneTwoLanes() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); config.planCalcScore().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); createOneLane(scenario, 2); initPopulation(scenario.getPopulation()); EventsManager events = EventsUtils.createEventsManager(); SimulatedCapacityHandler simulatedCapacity = new SimulatedCapacityHandler(); events.addHandler(simulatedCapacity); PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) // .useDefaults() // .build(scenario, events) // .run(); // check simulated capacity values assertEquals(simulatedCapacity.getSimulatedLaneCapacity(Id.create("1", Lane.class)), simulatedCapacity.getSimulatedLinkCapacity(), MatsimTestUtils.EPSILON); assertEquals(1800, simulatedCapacity.getSimulatedLaneCapacity(Id.create("1.ol", Lane.class)), MatsimTestUtils.EPSILON); assertEquals(2*900, simulatedCapacity.getSimulatedLaneCapacity(Id.create("1", Lane.class)), MatsimTestUtils.EPSILON); }
private static void enrichConfig(Config c) { PlanCalcScoreConfigGroup.ActivityParams pre = new PlanCalcScoreConfigGroup.ActivityParams("origin"); pre.setTypicalDuration(49); // needs to be geq 49, otherwise when // running a simulation one gets // "java.lang.RuntimeException: zeroUtilityDuration of type pre-evac must be greater than 0.0. Did you forget to specify the typicalDuration?" // the reason is the double precision. see also comment in // ActivityUtilityParameters.java (gl) pre.setMinimalDuration(49); pre.setClosingTime(49); pre.setEarliestEndTime(49); pre.setLatestStartTime(49); pre.setOpeningTime(49); PlanCalcScoreConfigGroup.ActivityParams post = new PlanCalcScoreConfigGroup.ActivityParams("destination"); post.setTypicalDuration(49); // dito post.setMinimalDuration(49); post.setClosingTime(49); post.setEarliestEndTime(49); post.setLatestStartTime(49); post.setOpeningTime(49); c.planCalcScore().addActivityParams(pre); c.planCalcScore().addActivityParams(post); c.planCalcScore().setLateArrival_utils_hr(0.); c.planCalcScore().setPerforming_utils_hr(0.); }
/** * test simulated capacity of link 1 in case without lanes. * the capacity should correspond to the given flow capacity of the link */ public void testCapacityWoLanes() { Config config = ConfigUtils.createConfig(); ActivityParams dummyAct = new ActivityParams("dummy"); dummyAct.setTypicalDuration(12 * 3600); config.planCalcScore().addActivityParams(dummyAct); MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(config); initNetwork(scenario.getNetwork()); initPopulation(scenario.getPopulation()); EventsManager events = EventsUtils.createEventsManager(); SimulatedCapacityHandler simulatedCapacity = new SimulatedCapacityHandler(); events.addHandler(simulatedCapacity); PrepareForSimUtils.createDefaultPrepareForSim(scenario).run(); new QSimBuilder(scenario.getConfig()) // .useDefaults() // .build(scenario, events) // .run(); // check simulated capacity values assertEquals(1800, simulatedCapacity.getSimulatedLinkCapacity(), MatsimTestUtils.EPSILON); }
@Test public void testCheckPlanCalcScore_PtInteractionActivity() { Config config = new Config(); config.addCoreModules(); ActivityParams transitActivityParams = new ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); transitActivityParams.setClosingTime(1.) ; config.planCalcScore().addActivityParams(transitActivityParams); try { new ConfigConsistencyCheckerImpl().checkPlanCalcScore(config); Assert.assertEquals(0,1) ; // should never get here } catch ( Exception ee ){ System.out.println("expected exception") ; } config.vspExperimental().setAbleToOverwritePtInteractionParams(true) ; try { new ConfigConsistencyCheckerImpl().checkPlanCalcScore(config); } catch ( Exception ee ){ Assert.assertEquals(0,1) ; // should never get here } }
@Test(expected = RuntimeException.class) public void testSubpopulationParams() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory(utils.getOutputDirectory()); PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams("home"); params.setScoringThisActivityAtAll(true); params.setTypicalDuration(60.0); ScoringParameterSet sps = config.planCalcScore().getOrCreateScoringParameters("one"); sps.addActivityParams(params); ScoringParameterSet sps2 = config.planCalcScore().getOrCreateScoringParameters("two"); sps2.addActivityParams(params); // --- config.controler().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... config.checkConsistency(); Controler controler = new Controler(config); controler.run(); }
@Test(expected = RuntimeException.class) public void testPtInteractionParams() { Config config = ConfigUtils.createConfig(); config.controler().setOutputDirectory(utils.getOutputDirectory()); PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams(PtConstants.TRANSIT_ACTIVITY_TYPE); params.setScoringThisActivityAtAll(true); params.setTypicalDuration(60.0); config.planCalcScore().addActivityParams(params); // --- config.controler().setLastIteration(0); // in case the exception is _not_ thrown, we don't need 100 iterations to find that out ... // --- Controler controler = new Controler(config); controler.run(); }
@Test public void testAddActivityParams() { PlanCalcScoreConfigGroup c = new PlanCalcScoreConfigGroup(); Assert.assertNull(c.getActivityParams("type1")); // Assert.assertEquals(0, c.getActivityParams().size()); Assert.assertEquals(6, c.getActivityParams().size()); // yyyyyy see PlanCalcScoreConfigGroup, where I am currently adding interaction activities hard-wired. kai, feb'16 // yyyyyy and now also the "dummy" activity. kai, jul'17 ActivityParams ap = new ActivityParams("type1"); c.addActivityParams(ap); Assert.assertEquals(ap, c.getActivityParams("type1")); // Assert.assertEquals(1, c.getActivityParams().size()); Assert.assertEquals(7, c.getActivityParams().size()); // yyyyyy see PlanCalcScoreConfigGroup, where I am currently adding interaction activities hard-wired. kai, feb'16 // yyyyyy and now also the "dummy" activity. kai, jul'17 }
@Override public ConfigGroup createParameterSet(final String type) { switch (type) { case ActivityParams.SET_TYPE: return new ActivityParams(); case ModeParams.SET_TYPE: return new ModeParams(); case ScoringParameterSet.SET_TYPE: return new ScoringParameterSet(); default: throw new IllegalArgumentException(type); } }