private static void unregisterPassengerFromDriverRoutes(final JointTrip toRemove) { for (Leg driverLeg : toRemove.getDriverLegs()) { final DriverRoute route = (DriverRoute) driverLeg.getRoute(); route.removePassenger(toRemove.getPassengerId()); if (route.getPassengersIds().isEmpty()) { driverLeg.setMode(TransportMode.car); driverLeg.setRoute(null); } } }
/** @param args */ public static void main(String[] args) { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); Network net = scenario.getNetwork(); MatsimIo.loadNetwork(DgPaths.IVTCHNET, scenario); Population plansCmcf = MatsimIo.loadPlans(cmcfPlansFile, net); Population plans = MatsimIo.loadPlans(plansFile, net); for (Person p : plans.getPersons().values()) { Plan pl = p.getSelectedPlan(); Leg l = ((PlanImpl) pl).getNextLeg(((PlanImpl) pl).getFirstActivity()); Plan plcmcf = plansCmcf.getPersons().get(p.getId()).getSelectedPlan(); Leg lcmcf = ((PlanImpl) plcmcf).getNextLeg(((PlanImpl) plcmcf).getFirstActivity()); l.setRoute(lcmcf.getRoute()); } MatsimIo.writePlans(plans, net, outPlansFile); log.info("done"); }
public void testArriveAtStop() { ScenarioImpl scenario = (ScenarioImpl) ScenarioUtils.createScenario(ConfigUtils.createConfig()); NetworkImpl network = (NetworkImpl) scenario.getNetwork(); Node node1 = network.createAndAddNode(Id.create("1", Node.class), new CoordImpl(0, 0)); Node node2 = network.createAndAddNode(Id.create("2", Node.class), new CoordImpl(1000, 0)); Node node3 = network.createAndAddNode(Id.create("3", Node.class), new CoordImpl(2000, 0)); network.createAndAddLink(Id.create("1", Link.class), node1, node2, 1000.0, 10.0, 3600.0, 1); network.createAndAddLink(Id.create("2", Link.class), node2, node3, 1000.0, 10.0, 3600.0, 1); TransitScheduleFactory builder = new TransitScheduleFactoryImpl(); PopulationFactory pb = scenario.getPopulation().getFactory(); Person person = pb.createPerson(Id.create("1", Person.class)); Plan plan = pb.createPlan(); person.addPlan(plan); Activity homeAct = pb.createActivityFromLinkId("home", Id.create("1", Link.class)); Leg leg = pb.createLeg(TransportMode.pt); TransitStopFacility stop1 = builder.createTransitStopFacility( Id.create("1", TransitStopFacility.class), scenario.createCoord(100, 100), false); TransitStopFacility stop2 = builder.createTransitStopFacility( Id.create("2", TransitStopFacility.class), scenario.createCoord(900, 100), false); TransitStopFacility stop3 = builder.createTransitStopFacility( Id.create("3", TransitStopFacility.class), scenario.createCoord(1900, 100), false); TransitLine line1 = builder.createTransitLine(Id.create("L1", TransitLine.class)); leg.setRoute(new ExperimentalTransitRoute(stop1, line1, null, stop2)); Activity workAct = pb.createActivityFromLinkId("work", Id.create("2", Link.class)); plan.addActivity(homeAct); plan.addLeg(leg); plan.addActivity(workAct); QSim sim = (QSim) new QSimFactory().createMobsim(scenario, EventsUtils.createEventsManager()); TransitAgent agent = TransitAgent.createTransitAgent(person, sim); sim.insertAgentIntoMobsim(agent); agent.endActivityAndComputeNextState(10); assertFalse(agent.getExitAtStop(stop1)); assertTrue(agent.getExitAtStop(stop2)); assertFalse(agent.getExitAtStop(stop3)); assertTrue(agent.getExitAtStop(stop2)); // offering the same stop again should yield "true" }
/** * Tests if the scoring function correctly handles {@link PersonMoneyEvent}. It generates one * person with one plan having two activities (home, work) and a car-leg in between. It then tests * the scoring function by calling several methods on an instance of the scoring function with the * aforementioned plan. */ @Test public void testAddMoney() { Fixture f = new Fixture(); // score the same plan twice PersonImpl person1 = new PersonImpl(Id.create(1, Person.class)); PlanImpl plan1 = person1.createAndAddPlan(true); Activity act1a = plan1.createAndAddActivity("home", (Id<Link>) null); // , 0, 7.0*3600, 7*3600, false); act1a.setEndTime(f.secondLegStartTime); Leg leg1 = plan1.createAndAddLeg(TransportMode.car); // , 7*3600, 100, 7*3600+100); leg1.setDepartureTime(f.secondLegStartTime); leg1.setTravelTime(f.secondLegTravelTime); Route route2 = new GenericRouteImpl(null, null); leg1.setRoute(route2); route2.setDistance(20000.0); Activity act1b = plan1.createAndAddActivity( "work", (Id<Link>) null); // , 7.0*3600+100, Time.UNDEFINED_TIME, Time.UNDEFINED_TIME, false); act1b.setStartTime(f.secondLegStartTime + f.secondLegTravelTime); ScoringFunction sf1 = getScoringFunctionInstance(f, person1); sf1.handleActivity(act1a); sf1.handleLeg(leg1); sf1.handleActivity(act1b); sf1.finish(); double score1 = sf1.getScore(); ScoringFunction sf2 = getScoringFunctionInstance(f, person1); sf2.handleActivity(act1a); sf2.addMoney(1.23); sf2.handleLeg(leg1); sf2.addMoney(-2.46); sf2.handleActivity(act1b); sf2.addMoney(4.86); sf2.addMoney(-0.28); sf2.finish(); double score2 = sf2.getScore(); assertEquals(1.23 - 2.46 + 4.86 - 0.28, score2 - score1, EPSILON); }
/** Why? dg 09-2013 */ private void createExperimentalTransitRoutes(Scenario sc) { for (Person person : sc.getPopulation().getPersons().values()) { for (Plan plan : person.getPlans()) { for (PlanElement pe : plan.getPlanElements()) { if (pe instanceof Leg) { Leg leg = (Leg) pe; if (leg.getMode().equals("pt")) { GenericRoute route = (GenericRoute) leg.getRoute(); ExperimentalTransitRoute tr = (ExperimentalTransitRoute) new ExperimentalTransitRouteFactory().createRoute(null, null); leg.setRoute(tr); tr.setRouteDescription( route.getStartLinkId(), route.getRouteDescription(), route.getEndLinkId()); tr.setDistance(route.getDistance()); } } } } } }
@Override public List<Leg> calcRoute( final Coord fromCoord, final Coord toCoord, final double departureTime, final Person person) { // find possible start stops Map<Node, InitialNode> wrappedFromNodes = this.locateWrappedNearestTransitNodes(person, fromCoord, departureTime); // find possible end stops Map<Node, InitialNode> wrappedToNodes = this.locateWrappedNearestTransitNodes(person, toCoord, departureTime); // find routes between start and end stops Path p = this.dijkstra.calcLeastCostPath(wrappedFromNodes, wrappedToNodes, person); if (p == null) { return null; } double directWalkCost = CoordUtils.calcEuclideanDistance(fromCoord, toCoord) / this.config.getBeelineWalkSpeed() * (0 - this.config.getMarginalUtilityOfTravelTimeWalk_utl_s()); double pathCost = p.travelCost + wrappedFromNodes.get(p.nodes.get(0)).initialCost + wrappedToNodes.get(p.nodes.get(p.nodes.size() - 1)).initialCost; if (directWalkCost < pathCost) { List<Leg> legs = new ArrayList<Leg>(); Leg leg = new LegImpl(TransportMode.transit_walk); double walkDistance = CoordUtils.calcEuclideanDistance(fromCoord, toCoord); Route walkRoute = new GenericRouteImpl(null, null); walkRoute.setDistance(walkDistance); leg.setRoute(walkRoute); leg.setTravelTime(walkDistance / this.config.getBeelineWalkSpeed()); legs.add(leg); return legs; } return convertPathToLegList(departureTime, p, fromCoord, toCoord, person); }
public Fixture() { firstLegStartTime = 7 * 3600; firstLegTravelTime = 30 * 60; thirdLegTravelTime = 30 * 60; secondLegStartTime = 10 * 3600; secondLegTravelTime = 15 * 60; thirdLegStartTime = 13 * 3600; fourthLegStartTime = 16 * 3600; fourthLegTravelTime = 15 * 60; // home act end 7am // work 7:30 to 10:00 // work 10:15 to 13:00 // work 13:30 to 16:00 // home 15:15 to ... this.config = ConfigUtils.createConfig(); PlanCalcScoreConfigGroup scoring = this.config.planCalcScore(); scoring.setBrainExpBeta(2.0); scoring.setConstantCar(0.0); scoring.setConstantPt(0.0); scoring.setConstantWalk(0.0); scoring.setConstantBike(0.0); scoring.setEarlyDeparture_utils_hr(0.0); scoring.setLateArrival_utils_hr(0.0); scoring.setMarginalUtlOfWaiting_utils_hr(0.0); scoring.setPerforming_utils_hr(0.0); scoring.setTraveling_utils_hr(0.0); scoring.setTravelingPt_utils_hr(0.0); scoring.setTravelingWalk_utils_hr(0.0); scoring.setTravelingBike_utils_hr(0.0); scoring.setMarginalUtilityOfMoney(1.); scoring.setMonetaryDistanceCostRateCar(0.0); scoring.setMonetaryDistanceCostRatePt(0.0); // setup activity types h and w for scoring PlanCalcScoreConfigGroup.ActivityParams params = new PlanCalcScoreConfigGroup.ActivityParams("h"); params.setTypicalDuration(15 * 3600); scoring.addActivityParams(params); params = new PlanCalcScoreConfigGroup.ActivityParams("w"); params.setTypicalDuration(3 * 3600); scoring.addActivityParams(params); this.scenario = ScenarioUtils.createScenario(config); this.network = (NetworkImpl) this.scenario.getNetwork(); Node node1 = this.network.createAndAddNode(Id.create("1", Node.class), new CoordImpl(0.0, 0.0)); Node node2 = this.network.createAndAddNode(Id.create("2", Node.class), new CoordImpl(500.0, 0.0)); Node node3 = this.network.createAndAddNode(Id.create("3", Node.class), new CoordImpl(5500.0, 0.0)); Node node4 = this.network.createAndAddNode(Id.create("4", Node.class), new CoordImpl(6000.0, 0.0)); Node node5 = this.network.createAndAddNode(Id.create("5", Node.class), new CoordImpl(11000.0, 0.0)); Node node6 = this.network.createAndAddNode(Id.create("6", Node.class), new CoordImpl(11500.0, 0.0)); Node node7 = this.network.createAndAddNode(Id.create("7", Node.class), new CoordImpl(16500.0, 0.0)); Node node8 = this.network.createAndAddNode(Id.create("8", Node.class), new CoordImpl(17000.0, 0.0)); Node node9 = this.network.createAndAddNode(Id.create("9", Node.class), new CoordImpl(22000.0, 0.0)); Node node10 = this.network.createAndAddNode(Id.create("10", Node.class), new CoordImpl(22500.0, 0.0)); Link link1 = this.network.createAndAddLink(Id.create("1", Link.class), node1, node2, 500, 25, 3600, 1); Link link2 = this.network.createAndAddLink( Id.create("2", Link.class), node2, node3, 25000, 50, 3600, 1); Link link3 = this.network.createAndAddLink(Id.create("3", Link.class), node3, node4, 500, 25, 3600, 1); this.network.createAndAddLink(Id.create("4", Link.class), node4, node5, 5000, 50, 3600, 1); Link link5 = this.network.createAndAddLink(Id.create("5", Link.class), node5, node6, 500, 25, 3600, 1); this.network.createAndAddLink(Id.create("6", Link.class), node6, node7, 5000, 50, 3600, 1); Link link7 = this.network.createAndAddLink(Id.create("7", Link.class), node7, node8, 500, 25, 3600, 1); this.network.createAndAddLink(Id.create("8", Link.class), node8, node9, 5000, 50, 3600, 1); Link link9 = this.network.createAndAddLink( Id.create("9", Link.class), node9, node10, 500, 25, 3600, 1); this.person = new PersonImpl(Id.create("1", Person.class)); this.plan = this.person.createAndAddPlan(true); ActivityImpl firstActivity = this.plan.createAndAddActivity("h", link1.getId()); firstActivity.setEndTime(firstLegStartTime); Leg leg = this.plan.createAndAddLeg(TransportMode.car); leg.setDepartureTime(firstLegStartTime); leg.setTravelTime(firstLegTravelTime); NetworkRoute route1 = new LinkNetworkRouteImpl(link1.getId(), link3.getId()); route1.setLinkIds(link1.getId(), Arrays.asList(link2.getId()), link3.getId()); route1.setTravelTime(firstLegTravelTime); route1.setDistance(RouteUtils.calcDistance(route1, this.network)); leg.setRoute(route1); ActivityImpl secondActivity = this.plan.createAndAddActivity("w", link3.getId()); secondActivity.setStartTime(firstLegStartTime + firstLegTravelTime); secondActivity.setEndTime(secondLegStartTime); leg = this.plan.createAndAddLeg(TransportMode.pt); leg.setDepartureTime(secondLegStartTime); leg.setTravelTime(secondLegTravelTime); Route route2 = new GenericRouteImpl(link3.getId(), link5.getId()); route2.setTravelTime(secondLegTravelTime); route2.setDistance(20000.0); leg.setRoute(route2); ActivityImpl thirdActivity = this.plan.createAndAddActivity("w", link5.getId()); thirdActivity.setStartTime(secondLegStartTime + secondLegTravelTime); thirdActivity.setEndTime(thirdLegStartTime); leg = this.plan.createAndAddLeg(TransportMode.walk); leg.setDepartureTime(thirdLegStartTime); leg.setTravelTime(thirdLegTravelTime); Route route3 = new GenericRouteImpl(link5.getId(), link7.getId()); route3.setTravelTime(thirdLegTravelTime); route3.setDistance(CoordUtils.calcDistance(link5.getCoord(), link7.getCoord())); leg.setRoute(route3); ActivityImpl fourthActivity = this.plan.createAndAddActivity("w", link7.getId()); fourthActivity.setStartTime(thirdLegStartTime + thirdLegTravelTime); fourthActivity.setEndTime(fourthLegStartTime); leg = this.plan.createAndAddLeg(TransportMode.bike); leg.setDepartureTime(fourthLegStartTime); leg.setTravelTime(fourthLegTravelTime); Route route4 = new GenericRouteImpl(link7.getId(), link9.getId()); route4.setTravelTime(fourthLegTravelTime); route4.setDistance(CoordUtils.calcDistance(link7.getCoord(), link9.getCoord())); leg.setRoute(route4); ActivityImpl fifthActivity = this.plan.createAndAddActivity("h", link9.getId()); fifthActivity.setStartTime(fourthLegStartTime + fourthLegTravelTime); this.scenario.getPopulation().addPerson(this.person); }
/** * Tests that the travel times are correctly calculated during the simulation. * * @author mrieser */ @Test public void testTravelTimeCalculation() { Config config = this.utils.loadConfig(null); Fixture f = new Fixture(config); /* Create 2 persons driving from link 1 to link 3, both starting at the * same time at 7am. */ Population population = f.scenario.getPopulation(); PopulationFactory factory = population.getFactory(); Person person1 = null; person1 = factory.createPerson(Id.create("1", Person.class)); Plan plan1 = factory.createPlan(); person1.addPlan(plan1); Activity a1 = factory.createActivityFromLinkId("h", f.link1.getId()); a1.setEndTime(7.0 * 3600); plan1.addActivity(a1); Leg leg1 = factory.createLeg(TransportMode.car); plan1.addLeg(leg1); NetworkRoute route1 = ((PopulationFactoryImpl) f.scenario.getPopulation().getFactory()) .createRoute(NetworkRoute.class, f.link1.getId(), f.link3.getId()); leg1.setRoute(route1); ArrayList<Id<Link>> linkIds = new ArrayList<Id<Link>>(); linkIds.add(f.link2.getId()); route1.setLinkIds(f.link1.getId(), linkIds, f.link3.getId()); plan1.addActivity(factory.createActivityFromLinkId("h", f.link3.getId())); population.addPerson(person1); Person person2 = factory.createPerson(Id.create("2", Person.class)); Plan plan2 = factory.createPlan(); person2.addPlan(plan2); Activity a2 = factory.createActivityFromLinkId("h", f.link1.getId()); a2.setEndTime(7.0 * 3600); plan2.addActivity(a2); Leg leg2 = factory.createLeg(TransportMode.car); plan2.addLeg(leg2); NetworkRoute route2 = ((PopulationFactoryImpl) f.scenario.getPopulation().getFactory()) .createRoute(NetworkRoute.class, f.link1.getId(), f.link3.getId()); leg2.setRoute(route2); route2.setLinkIds(f.link1.getId(), linkIds, f.link3.getId()); plan2.addActivity(factory.createActivityFromLinkId("h", f.link3.getId())); population.addPerson(person2); // Complete the configuration for our test case // - set scoring parameters ActivityParams actParams = new ActivityParams("h"); actParams.setTypicalDuration(8 * 3600); actParams.setPriority(1.0); config.planCalcScore().addActivityParams(actParams); // - define iterations config.controler().setLastIteration(0); // - make sure we don't use threads, as they are not deterministic config.global().setNumberOfThreads(0); // Now run the simulation Controler controler = new Controler(f.scenario); controler.getConfig().controler().setCreateGraphs(false); controler.getConfig().controler().setWriteEventsInterval(0); controler.setDumpDataAtEnd(false); controler.run(); // test if we got the right result // the actual result is 151sec, not 150, as each vehicle "loses" 1sec in the buffer assertEquals( "TravelTimeCalculator has wrong result", 151.0, controler.getLinkTravelTimes().getLinkTravelTime(f.link2, 7 * 3600, null, null), 0.0); // now test that the ReRoute-Strategy also knows about these travel times... config.controler().setLastIteration(1); ConfigGroup strategyParams = config.getModule("strategy"); strategyParams.addParam("maxAgentPlanMemorySize", "4"); strategyParams.addParam("ModuleProbability_1", "1.0"); strategyParams.addParam("Module_1", "ReRoute"); // Run the simulation again controler = new Controler(f.scenario); controler.getConfig().controler().setCreateGraphs(false); controler .getConfig() .controler() .setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); controler.getConfig().controler().setWriteEventsInterval(0); controler.run(); // test that the plans have the correct times assertEquals( "ReRoute seems to have wrong travel times.", 151.0, ((Leg) (person1.getPlans().get(1).getPlanElements().get(1))).getTravelTime(), 0.0); }
protected List<Leg> convertPathToLegList( double departureTime, Path p, Coord fromCoord, Coord toCoord, Person person) { List<Leg> legs = new ArrayList<Leg>(); Leg leg; double walkDistance, walkWaitTime, travelTime = 0; Route walkRoute; Coord coord = fromCoord; TransitRouteStop stop = null; double time = departureTime; for (Link link : p.links) { TransitRouterNetworkLink l = (TransitRouterNetworkLink) link; if (l.route != null) { // in line link double ttime = ttCalculator.getLinkTravelTime(l, time, person, null); travelTime += ttime; time += ttime; } else if (l.fromNode.route != null) { // inside link leg = new LegImpl(TransportMode.pt); ExperimentalTransitRoute ptRoute = new ExperimentalTransitRoute( stop.getStopFacility(), l.fromNode.line, l.fromNode.route, l.fromNode.stop.getStopFacility()); leg.setRoute(ptRoute); leg.setTravelTime(travelTime); legs.add(leg); travelTime = 0; stop = l.fromNode.stop; coord = l.fromNode.stop.getStopFacility().getCoord(); } else if (l.toNode.route != null) { // wait link leg = new LegImpl(TransportMode.transit_walk); walkDistance = CoordUtils.calcEuclideanDistance(coord, l.toNode.stop.getStopFacility().getCoord()); walkWaitTime = walkDistance / this.config.getBeelineWalkSpeed() + ttCalculator.getLinkTravelTime( l, time + walkDistance / this.config.getBeelineWalkSpeed(), person, null); walkRoute = new GenericRouteImpl( stop == null ? null : stop.getStopFacility().getLinkId(), l.toNode.stop.getStopFacility().getLinkId()); walkRoute.setDistance(walkDistance); leg.setRoute(walkRoute); leg.setTravelTime(walkWaitTime); legs.add(leg); stop = l.toNode.stop; time += walkWaitTime; } } leg = new LegImpl(TransportMode.transit_walk); walkDistance = CoordUtils.calcEuclideanDistance(coord, toCoord); walkWaitTime = walkDistance / this.config.getBeelineWalkSpeed(); walkRoute = new GenericRouteImpl(stop == null ? null : stop.getStopFacility().getLinkId(), null); walkRoute.setDistance(walkDistance); leg.setRoute(walkRoute); leg.setTravelTime(walkWaitTime); legs.add(leg); return legs; }
public void testTransitRouteCopy() { Config config = super.loadConfig(null); config.scenario().setUseTransit(true); config.scenario().setUseVehicles(true); ScenarioImpl scenario = (ScenarioImpl) ScenarioUtils.createScenario(config); Id<Node> nodeId1 = Id.create("1", Node.class); Id<Node> nodeId2 = Id.create("2", Node.class); Id<Node> nodeId3 = Id.create("3", Node.class); Id<Link> linkId1 = Id.create("1", Link.class); Id<Link> linkId2 = Id.create("2", Link.class); // build network Network network = scenario.getNetwork(); NetworkFactory nBuilder = network.getFactory(); Node node1 = nBuilder.createNode(nodeId1, scenario.createCoord(0, 0)); Node node2 = nBuilder.createNode(nodeId2, scenario.createCoord(1000, 0)); Node node3 = nBuilder.createNode(nodeId3, scenario.createCoord(2000, 0)); network.addNode(node1); network.addNode(node2); network.addNode(node3); Link link1 = nBuilder.createLink(linkId1, node1, node2); Link link2 = nBuilder.createLink(linkId2, node2, node3); network.addLink(link1); network.addLink(link2); // build schedule TransitSchedule schedule = scenario.getTransitSchedule(); TransitScheduleFactory sBuilder = schedule.getFactory(); TransitStopFacility stopF1 = sBuilder.createTransitStopFacility( Id.create("1", TransitStopFacility.class), scenario.createCoord(1000.0, 0), false); TransitStopFacility stopF2 = sBuilder.createTransitStopFacility( Id.create("2", TransitStopFacility.class), scenario.createCoord(2000.0, 0), false); stopF1.setLinkId(link1.getId()); stopF2.setLinkId(link2.getId()); schedule.addStopFacility(stopF1); schedule.addStopFacility(stopF2); TransitLine tLine1 = sBuilder.createTransitLine(Id.create("1", TransitLine.class)); TransitRouteStop stop1 = sBuilder.createTransitRouteStop(stopF1, 0, 0); TransitRouteStop stop2 = sBuilder.createTransitRouteStop(stopF2, 100, 100); ArrayList<TransitRouteStop> stops = new ArrayList<TransitRouteStop>(); stops.add(stop1); stops.add(stop2); NetworkRoute netRoute = new LinkNetworkRouteImpl(link1.getId(), link2.getId()); netRoute.setLinkIds(link1.getId(), Collections.<Id<Link>>emptyList(), link2.getId()); TransitRoute tRoute1 = sBuilder.createTransitRoute(Id.create("1", TransitRoute.class), netRoute, stops, "bus"); tRoute1.addDeparture(sBuilder.createDeparture(Id.create("1", Departure.class), 7.0 * 3600)); tLine1.addRoute(tRoute1); schedule.addTransitLine(tLine1); // build vehicles new CreateVehiclesForSchedule(schedule, scenario.getVehicles()).run(); // build population Population population = scenario.getPopulation(); PopulationFactory pBuilder = population.getFactory(); Person person1 = pBuilder.createPerson(Id.create("1", Person.class)); Plan plan = pBuilder.createPlan(); Activity homeAct = pBuilder.createActivityFromLinkId("h", linkId1); homeAct.setEndTime(7.0 * 3600); plan.addActivity(homeAct); Leg leg = pBuilder.createLeg(TransportMode.pt); ExperimentalTransitRoute tRoute = new ExperimentalTransitRoute(stopF1, tLine1, tRoute1, stopF2); leg.setRoute(tRoute); plan.addLeg(leg); plan.addActivity(pBuilder.createActivityFromLinkId("w", linkId2)); person1.addPlan(plan); population.addPerson(person1); // prepare config config.controler().setFirstIteration(0); config.controler().setLastIteration(1); ActivityParams params = new ActivityParams("h"); params.setTypicalDuration(16.0 * 3600); config.planCalcScore().addActivityParams(params); params = new ActivityParams("w"); params.setTypicalDuration(8.0 * 3600); config.planCalcScore().addActivityParams(params); StrategySettings tam = new StrategySettings(Id.create(1, StrategySettings.class)); tam.setStrategyName("TimeAllocationMutator"); tam.setWeight(1.0); config.strategy().addStrategySettings(tam); // run Controler controler = new Controler(scenario); controler.getConfig().controler().setWriteEventsInterval(0); controler.setCreateGraphs(false); controler.run(); // checks assertEquals(1, population.getPersons().size()); assertEquals(2, person1.getPlans().size()); assertEquals( ExperimentalTransitRoute.class, ((Leg) person1.getPlans().get(0).getPlanElements().get(1)).getRoute().getClass()); assertEquals( ExperimentalTransitRoute.class, ((Leg) person1.getPlans().get(1).getPlanElements().get(1)).getRoute().getClass()); }