public void insertActivity(MobsimAgent agent, int index, Activity activity, String upstreamMode, String downstreamMode ) {
Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
List<PlanElement> planElements = plan.getPlanElements() ;
checkIfNotInPastOrCurrent(agent, index) ;
planElements.add( index, activity ) ;
{
Activity actBefore = findRealActBefore(agent, index);
if ( actBefore != null ) {
if ( WithinDayAgentUtils.indexOfPlanElement(agent, actBefore) < WithinDayAgentUtils.getCurrentPlanElementIndex(agent) ) {
editTrips.replanCurrentTrip(agent, this.mobsim.getSimTimer().getTimeOfDay(), upstreamMode );
} else {
EditTrips.insertEmptyTrip(plan, actBefore, activity, upstreamMode, pf ) ;
}
}
}
{
Activity actAfter = findRealActAfter(agent, index);
if ( actAfter != null ) {
EditTrips.insertEmptyTrip(plan, activity, actAfter, downstreamMode, pf ) ;
}
}
WithinDayAgentUtils.resetCaches(agent);
this.mobsim.rescheduleActivityEnd(agent);
}