@Override public void endActivityAndComputeNextState(double now) { events.processEvent(new ActivityEndEvent(now, id, currentLinkId, null, dynActivity.getActivityType())); computeNextAction(dynActivity, now); }
this.events.processEvent(new ActivityEndEvent( time, Id.create(atts.getValue(ActivityEndEvent.ATTRIBUTE_PERSON), Person.class),
@Override public final void endActivityAndComputeNextState(final double now) { Activity act = (Activity) this.getCurrentPlanElement() ; this.getEvents().processEvent( new ActivityEndEvent(now, this.getPerson().getId(), this.currentLinkId, act.getFacilityId(), act.getType())); // note that when we are here we don't know if next is another leg, or an activity Therefore, we go to a general method: advancePlan(now); } @Override
ActivityEndEvent endEvent = new ActivityEndEvent(actEndTime, personId, act.getLinkId(), act.getFacilityId(), act.getType()); eventQueue.add(endEvent); PersonDepartureEvent departureEvent = new PersonDepartureEvent(actEndTime, personId, act.getLinkId(), nextLeg.getMode());
e = new ActivityEndEvent(time, Id.createPersonId(vehicleId), linkId, null, null); } else if (typeIndex == PersonDeparture.ordinal()) { e = new PersonDepartureEvent(time, Id.createPersonId(vehicleId), linkId, "car");
public void testWriteReadXml() { final ActivityEndEvent event = XmlEventsTester.testWriteReadXml(getOutputDirectory() + "events.xml", new ActivityEndEvent(7893.14, Id.create("143", Person.class), Id.create("293", Link.class), Id.create("f811", ActivityFacility.class), "home")); assertEquals(7893.14, event.getTime(), EPSILON); assertEquals("143", event.getPersonId().toString()); assertEquals("293", event.getLinkId().toString()); assertEquals("f811", event.getFacilityId().toString()); assertEquals("home", event.getActType()); } }
@Override public void processEvent() { Event event; // schedule ActEndEvent event = new ActivityEndEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), vehicle .getPreviousActivity().getFacilityId(), vehicle.getPreviousActivity().getType()); eventsManager.processEvent(event); // schedule AgentDepartureEvent event = new PersonDepartureEvent(this.getMessageArrivalTime(), vehicle.getOwnerPerson().getId(), vehicle.getCurrentLinkId(), vehicle.getCurrentLeg().getMode()); eventsManager.processEvent(event); }
@Test public void testDontCreateNightActivityIfNoneIsBeingPerformedWhenSimulationEnds() { EventsToActivities testee = new EventsToActivities(); MockActivityHandler ah = new MockActivityHandler(); testee.addActivityHandler(ah); testee.reset(0); testee.handleEvent(new ActivityEndEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("f1", ActivityFacility.class), "home")); Assert.assertNotNull(ah.handledActivity); Assert.assertEquals(Time.UNDEFINED_TIME, ah.handledActivity.getActivity().getStartTime(), 1e-8); Assert.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime(), 1e-8); ah.reset(); testee.finish(); Assert.assertNull(ah.handledActivity); }
@Test public void testCreatesActivty() { EventsToActivities testee = new EventsToActivities(); MockActivityHandler ah = new MockActivityHandler(); testee.addActivityHandler(ah); testee.reset(0); testee.handleEvent(new ActivityStartEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "work")); testee.handleEvent(new ActivityEndEvent(30.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "work")); Assert.assertNotNull(ah.handledActivity); Assert.assertEquals(10.0, ah.handledActivity.getActivity().getStartTime(), 1e-8); Assert.assertEquals(30.0, ah.handledActivity.getActivity().getEndTime(), 1e-8); }
leg.setDepartureTime(Time.parseTime("07:10:00")); leg.setTravelTime( Time.parseTime("07:30:00") - leg.getDepartureTime() ); testee.handleEvent(new ActivityEndEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, null, "act1")); testee.handleEvent(new PersonDepartureEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent(new PersonArrivalEvent(leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); leg.setDepartureTime(Time.parseTime("07:00:00")); leg.setTravelTime( Time.parseTime("07:10:00") - leg.getDepartureTime() ); testee.handleEvent(new ActivityEndEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, null, "act2")); testee.handleEvent(new PersonDepartureEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent(new PersonArrivalEvent(leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); leg.setDepartureTime(Time.parseTime("31:12:00")); leg.setTravelTime( Time.parseTime("31:22:00") - leg.getDepartureTime() ); testee.handleEvent(new ActivityEndEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, null, "act3")); testee.handleEvent(new PersonDepartureEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent(new PersonArrivalEvent(leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); leg.setDepartureTime(Time.parseTime("30:12:00")); leg.setTravelTime( Time.parseTime("30:12:01") - leg.getDepartureTime() ); testee.handleEvent(new ActivityEndEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, null, "act4")); testee.handleEvent(new PersonDepartureEvent(leg.getDepartureTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode())); testee.handleEvent(new PersonArrivalEvent(leg.getDepartureTime() + leg.getTravelTime(), DEFAULT_PERSON_ID, DEFAULT_LINK_ID, leg.getMode()));
@Test public void testCreateNightActivity() { EventsToActivities testee = new EventsToActivities(); MockActivityHandler ah = new MockActivityHandler(); testee.addActivityHandler(ah); testee.reset(0); testee.handleEvent(new ActivityEndEvent(10.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "home")); Assert.assertNotNull(ah.handledActivity); Assert.assertEquals(Time.UNDEFINED_TIME, ah.handledActivity.getActivity().getStartTime(), 1e-8); Assert.assertEquals(10.0, ah.handledActivity.getActivity().getEndTime(), 1e-8); ah.reset(); testee.handleEvent(new ActivityStartEvent(90.0, Id.create("1", Person.class), Id.create("l1", Link.class), Id.create("l1", ActivityFacility.class), "home")); testee.finish(); Assert.assertNotNull(ah.handledActivity); Assert.assertEquals(Time.UNDEFINED_TIME, ah.handledActivity.getActivity().getEndTime(), 1e-8); Assert.assertEquals(90.0, ah.handledActivity.getActivity().getStartTime(), 1e-8); }
leg.setTravelTime( legTravelTime1 ); final Event endFirstAct = new ActivityEndEvent(leg.getDepartureTime(), Id.create( 1, Person.class ), Id.create( 1, Link.class ), Id.create( 1, ActivityFacility.class ), "start"); scoring1.handleEvent( endFirstAct ); scoring2.handleEvent( endFirstAct ); leg.setTravelTime( legTravelTime2 ); final Event endFirstAct = new ActivityEndEvent(leg.getDepartureTime(), Id.create( 1, Person.class ), Id.create( 1, Link.class ), Id.create( 1, ActivityFacility.class ), "start"); scoring1.handleEvent( endFirstAct ); scoring2.handleEvent( endFirstAct ); leg.setTravelTime( legTravelTime3 ); final Event endFirstAct = new ActivityEndEvent(leg.getDepartureTime(), Id.create( 1, Person.class ), Id.create( 1, Link.class ), Id.create( 1, ActivityFacility.class ), "start"); scoring1.handleEvent( endFirstAct ); scoring2.handleEvent( endFirstAct );
final Event endFirstAct = new ActivityEndEvent(leg.getDepartureTime(), Id.create( 1, Person.class ), Id.create( 1, Link.class ), Id.create( 1, ActivityFacility.class ), "start"); scoring1.handleEvent( endFirstAct ); scoring2.handleEvent( endFirstAct );
events.processEvent(new PersonMoneyEvent(i*200, personId, 1.0)); events.processEvent(new ActivityStartEvent(i*200, personId, Id.createLinkId(0), null, "work")); events.processEvent(new ActivityEndEvent(i*200 + 100, personId, Id.createLinkId(0), null, "work")); events.processEvent(new PersonDepartureEvent(i*200+100, personId, Id.createLinkId(0), "car")); events.processEvent(new PersonArrivalEvent(i*200+200, personId, Id.createLinkId(0), "car"));
return new ActivityEndEvent(pe.getActEnd().getTime(), Id.createPersonId(pe.getActEnd().getPersId().getId()), Id.createLinkId(pe.getActEnd().getLinkId().getId()), Id.create(pe.getActEnd().getFacilityId().getId(), ActivityFacility.class), pe.getActEnd().getActType());
events.processEvent(new PersonMoneyEvent(i*200, personId, 1.0)); events.processEvent(new ActivityStartEvent(i*200, personId, Id.createLinkId(0), null, "work")); events.processEvent(new ActivityEndEvent(i*200 + 100, personId, Id.createLinkId(0), null, "work")); events.processEvent(new PersonDepartureEvent(i*200+100, personId, Id.createLinkId(0), "car")); events.processEvent(new PersonArrivalEvent(i*200+200, personId, Id.createLinkId(0), "car"));