MATSIM
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.matsim.withinday.utils.EditPlans Class Reference

Public Member Functions

 EditPlans (QSim mobsim, TripRouter tripRouter, EditTrips editTrips, PopulationFactory pf)
 
 EditPlans (QSim mobsim, TripRouter tripRouter, EditTrips editTrips, Scenario sc)
 
 EditPlans (QSim mobsim, TripRouter tripRouter, EditTrips editTrips)
 
 EditPlans (QSim mobsim, EditTrips editTrips)
 
boolean addActivityAtEnd (MobsimAgent agent, Activity activity, String routingMode)
 
PlanElement removeActivity (MobsimAgent agent, int index, String mode)
 
final void rescheduleActivityEndtime (MobsimAgent agent, int index, double newEndTime)
 
final Activity replaceActivity (MobsimAgent agent, int index, Activity newAct, String upstreamMode, String downstreamMode)
 
void insertActivity (MobsimAgent agent, int index, Activity activity, String upstreamMode, String downstreamMode)
 
PlanElement removeActivity (MobsimAgent agent, int index)
 
final Activity replaceActivity (MobsimAgent agent, int index, Activity newAct)
 
void insertActivity (MobsimAgent agent, int index, Activity activity)
 
void rescheduleActivityEnd (MobsimAgent agent)
 
boolean isAtRealActivity (MobsimAgent agent)
 
boolean isRealActivity (PlanElement pe)
 
String getModeOfCurrentOrNextTrip (MobsimAgent agent)
 
void flushEverythingBeyondCurrent (MobsimAgent agent)
 
void rescheduleCurrentActivityEndtime (MobsimAgent agent, double newEndTime)
 
Activity createFinalActivity (String type, Id< Link > newLinkId)
 

Static Public Member Functions

static Activity findRealActAfter (MobsimAgent agent, int index)
 
static int findIndexOfRealActAfter (MobsimAgent agent, int index)
 
static Activity findRealActBefore (MobsimAgent agent, int index)
 
static Integer getCurrentPlanElementIndex (MobsimAgent agent)
 
static List< LegfindLegsWithModeInFuture (MobsimAgent agent, String mode)
 

Private Member Functions

void checkIfNotStageActivity (Activity origAct)
 

Static Private Member Functions

static boolean checkIfTripHasAlreadyStarted (MobsimAgent agent, final List< PlanElement > currentTripElements)
 
static void checkIfNotInPastOrCurrent (MobsimAgent agent, int index)
 
static void checkIfSameMode (String upstreamMode, final String currentMode)
 

Private Attributes

final QSim mobsim
 
final EditTrips editTrips
 
final PopulationFactory pf
 

Static Private Attributes

static final Logger log = LogManager.getLogger( EditPlans.class )
 

Detailed Description

Definition at line 44 of file EditPlans.java.

Constructor & Destructor Documentation

◆ EditPlans() [1/4]

org.matsim.withinday.utils.EditPlans.EditPlans ( QSim  mobsim,
TripRouter  tripRouter,
EditTrips  editTrips,
PopulationFactory  pf 
)

◆ EditPlans() [2/4]

org.matsim.withinday.utils.EditPlans.EditPlans ( QSim  mobsim,
TripRouter  tripRouter,
EditTrips  editTrips,
Scenario  sc 
)

◆ EditPlans() [3/4]

org.matsim.withinday.utils.EditPlans.EditPlans ( QSim  mobsim,
TripRouter  tripRouter,
EditTrips  editTrips 
)

◆ EditPlans() [4/4]

org.matsim.withinday.utils.EditPlans.EditPlans ( QSim  mobsim,
EditTrips  editTrips 
)

Definition at line 62 of file EditPlans.java.

References org.matsim.core.gbl.Gbl.assertNotNull(), org.matsim.api.core.v01.population.Population.getFactory(), org.matsim.api.core.v01.Scenario.getPopulation(), and org.matsim.core.mobsim.qsim.QSim.getScenario().

62  {
63  Gbl.assertNotNull( this.mobsim = mobsim );
64  Gbl.assertNotNull( this.editTrips = editTrips ) ;
65  Gbl.assertNotNull( this.pf = mobsim.getScenario().getPopulation().getFactory() ) ;
66  }
final PopulationFactory pf
Definition: EditPlans.java:49
Here is the call graph for this function:

Member Function Documentation

◆ addActivityAtEnd()

boolean org.matsim.withinday.utils.EditPlans.addActivityAtEnd ( MobsimAgent  agent,
Activity  activity,
String  routingMode 
)

Definition at line 67 of file EditPlans.java.

References org.matsim.api.core.v01.population.PopulationFactory.createLeg(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.core.mobsim.qsim.QSim.getSimTimer(), org.matsim.core.mobsim.framework.MobsimTimer.getTimeOfDay(), org.matsim.withinday.utils.EditPlans.isAtRealActivity(), org.matsim.withinday.utils.EditTrips.replanCurrentTrip(), org.matsim.core.mobsim.qsim.QSim.rescheduleActivityEnd(), and org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.resetCaches().

67  {
68  log.debug("entering addActivityAtEnd with routingMode=" + routingMode) ;
69 
70  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent);
71  List<PlanElement> planElements = plan.getPlanElements();
72 
73  boolean retVal1 = false;
74 
75  if (isAtRealActivity(agent)) {
76  retVal1 = planElements.add(pf.createLeg(routingMode));
77  }
78 
79  final boolean retVal = planElements.add(activity);
80  // (need the terminating activity in order to find the current trip. kai, nov'17)
81 
82  if (!isAtRealActivity(agent)) {
83  retVal1 = editTrips.replanCurrentTrip(agent,mobsim.getSimTimer().getTimeOfDay(),routingMode);
84  }
85 
86 
87  WithinDayAgentUtils.resetCaches(agent);
88  this.mobsim.rescheduleActivityEnd(agent);
89  return (retVal1 && retVal);
90  }
final PopulationFactory pf
Definition: EditPlans.java:49
List< PlanElement > getPlanElements()
final void rescheduleActivityEnd(MobsimAgent agent)
Definition: QSim.java:185
boolean isAtRealActivity(MobsimAgent agent)
Definition: EditPlans.java:318
final boolean replanCurrentTrip(MobsimAgent agent, double now, String routingMode)
Definition: EditTrips.java:144
Here is the call graph for this function:

◆ removeActivity() [1/2]

PlanElement org.matsim.withinday.utils.EditPlans.removeActivity ( MobsimAgent  agent,
int  index,
String  mode 
)

Definition at line 91 of file EditPlans.java.

References org.matsim.withinday.utils.EditPlans.checkIfNotInPastOrCurrent(), org.matsim.withinday.utils.EditPlans.checkIfTripHasAlreadyStarted(), org.matsim.core.router.TripStructureUtils.findTripEndingAtActivity(), org.matsim.core.router.TripStructureUtils.findTripStartingAtActivity(), org.matsim.core.router.TripStructureUtils.Trip.getDestinationActivity(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.core.router.TripStructureUtils.Trip.getOriginActivity(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.core.mobsim.qsim.QSim.getSimTimer(), org.matsim.core.mobsim.framework.MobsimTimer.getTimeOfDay(), org.matsim.core.router.TripStructureUtils.Trip.getTripElements(), org.matsim.core.router.TripStructureUtils.identifyMainMode(), org.matsim.withinday.utils.EditTrips.insertEmptyTrip(), org.matsim.withinday.utils.EditTrips.replanCurrentTrip(), org.matsim.core.mobsim.qsim.QSim.rescheduleActivityEnd(), and org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.resetCaches().

Referenced by org.matsim.withinday.utils.EditPlans.removeActivity().

91  {
92  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
93  List<PlanElement> planElements = plan.getPlanElements() ;
94 
95  checkIfNotInPastOrCurrent(agent, index);
96 
97  final Trip tripBefore = TripStructureUtils.findTripEndingAtActivity( (Activity) planElements.get(index),plan );
98  final Trip tripAfter = TripStructureUtils.findTripStartingAtActivity( (Activity)planElements.get(index),plan );
99  if ( mode==null ) {
100  final String mainModeBefore = TripStructureUtils.identifyMainMode( tripBefore.getTripElements() );
101  final String mainModeAfter = TripStructureUtils.identifyMainMode( tripAfter.getTripElements() );
102  if ( mainModeBefore.equals( mainModeAfter ) ) {
103  mode = mainModeBefore ;
104  } else {
105  throw new ReplanningException("mode not given and mode before removed activity != mode after removed activity; don't know which mode to use") ;
106  }
107  }
108  PlanElement pe = planElements.remove(index) ;
109  if ( checkIfTripHasAlreadyStarted( agent, tripBefore.getTripElements() ) ) {
111  } else {
112  editTrips.insertEmptyTrip(plan, tripBefore.getOriginActivity(), tripAfter.getDestinationActivity(), mode ) ;
113  }
114  WithinDayAgentUtils.resetCaches(agent);
115  this.mobsim.rescheduleActivityEnd(agent);
116  return pe ;
117  }
static void checkIfNotInPastOrCurrent(MobsimAgent agent, int index)
Definition: EditPlans.java:245
static boolean checkIfTripHasAlreadyStarted(MobsimAgent agent, final List< PlanElement > currentTripElements)
Definition: EditPlans.java:242
List< PlanElement > getPlanElements()
static boolean insertEmptyTrip(Plan plan, Activity fromActivity, Activity toActivity, String mainMode, PopulationFactory pf)
Definition: EditTrips.java:604
final void rescheduleActivityEnd(MobsimAgent agent)
Definition: QSim.java:185
final boolean replanCurrentTrip(MobsimAgent agent, double now, String routingMode)
Definition: EditTrips.java:144
Here is the call graph for this function:

◆ rescheduleActivityEndtime()

final void org.matsim.withinday.utils.EditPlans.rescheduleActivityEndtime ( MobsimAgent  agent,
int  index,
double  newEndTime 
)

Definition at line 118 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.rescheduleActivityEnd(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.resetCaches(), and org.matsim.api.core.v01.population.Activity.setEndTime().

Referenced by org.matsim.withinday.utils.EditPlans.rescheduleCurrentActivityEndtime().

118  {
119  Activity activity = (Activity) WithinDayAgentUtils.getModifiablePlan(agent).getPlanElements().get(index) ;
120  activity.setEndTime(newEndTime);
121  WithinDayAgentUtils.resetCaches(agent);
122  WithinDayAgentUtils.rescheduleActivityEnd(agent, mobsim);
123  }
void setEndTime(final double seconds)
Here is the call graph for this function:

◆ replaceActivity() [1/2]

final Activity org.matsim.withinday.utils.EditPlans.replaceActivity ( MobsimAgent  agent,
int  index,
Activity  newAct,
String  upstreamMode,
String  downstreamMode 
)

Definition at line 124 of file EditPlans.java.

References org.matsim.core.gbl.Gbl.assertIf(), org.matsim.core.gbl.Gbl.assertNotNull(), org.matsim.withinday.utils.EditPlans.checkIfNotInPastOrCurrent(), org.matsim.withinday.utils.EditPlans.checkIfNotStageActivity(), org.matsim.withinday.utils.EditPlans.checkIfSameMode(), org.matsim.withinday.utils.EditPlans.checkIfTripHasAlreadyStarted(), org.matsim.core.router.TripStructureUtils.findTripEndingAtActivity(), org.matsim.core.router.TripStructureUtils.findTripStartingAtActivity(), org.matsim.core.router.TripStructureUtils.Trip.getDestinationActivity(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.core.router.TripStructureUtils.Trip.getOriginActivity(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.core.mobsim.qsim.QSim.getSimTimer(), org.matsim.core.mobsim.framework.MobsimTimer.getTimeOfDay(), org.matsim.core.router.TripStructureUtils.Trip.getTripElements(), org.matsim.core.router.TripStructureUtils.identifyMainMode(), org.matsim.withinday.utils.EditTrips.insertEmptyTrip(), org.matsim.withinday.utils.EditPlans.pf, org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.printPlan(), org.matsim.withinday.utils.EditTrips.replanCurrentTrip(), org.matsim.core.mobsim.qsim.QSim.rescheduleActivityEnd(), and org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.resetCaches().

Referenced by org.matsim.withinday.utils.EditPlans.replaceActivity().

124  {
125  System.err.println("here310");
126  WithinDayAgentUtils.printPlan(agent) ;
127  System.err.println("here320");
128  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
129  WithinDayAgentUtils.printPlan(plan) ;
130  System.err.println("here330");
131 
132 
133  List<PlanElement> planElements = plan.getPlanElements() ;
134 
135  // make sure we have indeed an activity position:
136  if ( ! ( planElements.get(index) instanceof Activity ) ) {
137  throw new ReplanningException("trying to replace a non-activity in the plan by an activity; this is not possible") ;
138  }
139  Activity origAct = (Activity) planElements.get(index) ;
140 
141  checkIfNotStageActivity(origAct);
142 
143  checkIfNotInPastOrCurrent(agent, index);
144 
145  // set the new activity:
146  planElements.set(index, newAct) ;
147  System.err.println("here340");
148  WithinDayAgentUtils.printPlan(plan) ;
149 
150  // trip before (if any):
151  if ( index > 0 ) {
152  Trip tripBeforeAct = TripStructureUtils.findTripEndingAtActivity( newAct,plan );
153  Gbl.assertNotNull( tripBeforeAct ); // there could also just be a sequence of activities?!
154 
155  final List<PlanElement> currentTripElements = tripBeforeAct.getTripElements();
156  final String currentMode = TripStructureUtils.identifyMainMode( currentTripElements ) ;
157 
158  if ( checkIfTripHasAlreadyStarted(agent, currentTripElements) ) {
159  // trip has already started
160  checkIfSameMode(upstreamMode, currentMode);
161  this.editTrips.replanCurrentTrip(agent, this.mobsim.getSimTimer().getTimeOfDay(), currentMode );
162  } else {
163  // trip has not yet started
164  if ( upstreamMode == null ) {
165  upstreamMode = currentMode ;
166  }
167  this.editTrips.insertEmptyTrip( plan, tripBeforeAct.getOriginActivity(), newAct, upstreamMode );
168  }
169  }
170  // trip after (if any):
171  if ( index < planElements.size()-1 ) {
172  Trip tripAfterAct = TripStructureUtils.findTripStartingAtActivity(origAct,plan);
173  Gbl.assertIf( tripAfterAct!=null ); // there could also just be a sequence of activities?!
174  if ( downstreamMode==null ) {
175  final String currentMainMode = TripStructureUtils.identifyMainMode( tripAfterAct.getTripElements() );
176  EditTrips.insertEmptyTrip(plan, newAct, tripAfterAct.getDestinationActivity(), currentMainMode, pf);
177  } else {
178  EditTrips.insertEmptyTrip(plan, newAct, tripAfterAct.getDestinationActivity(), downstreamMode, pf);
179  }
180  }
181  WithinDayAgentUtils.resetCaches(agent);
182  this.mobsim.rescheduleActivityEnd(agent);
183  return origAct ;
184  }
final PopulationFactory pf
Definition: EditPlans.java:49
void checkIfNotStageActivity(Activity origAct)
Definition: EditPlans.java:237
static void checkIfNotInPastOrCurrent(MobsimAgent agent, int index)
Definition: EditPlans.java:245
static boolean checkIfTripHasAlreadyStarted(MobsimAgent agent, final List< PlanElement > currentTripElements)
Definition: EditPlans.java:242
static void checkIfSameMode(String upstreamMode, final String currentMode)
Definition: EditPlans.java:253
List< PlanElement > getPlanElements()
static boolean insertEmptyTrip(Plan plan, Activity fromActivity, Activity toActivity, String mainMode, PopulationFactory pf)
Definition: EditTrips.java:604
final void rescheduleActivityEnd(MobsimAgent agent)
Definition: QSim.java:185
final boolean replanCurrentTrip(MobsimAgent agent, double now, String routingMode)
Definition: EditTrips.java:144
Here is the call graph for this function:

◆ insertActivity() [1/2]

void org.matsim.withinday.utils.EditPlans.insertActivity ( MobsimAgent  agent,
int  index,
Activity  activity,
String  upstreamMode,
String  downstreamMode 
)

Definition at line 185 of file EditPlans.java.

References org.matsim.withinday.utils.EditPlans.checkIfNotInPastOrCurrent(), org.matsim.withinday.utils.EditPlans.findRealActAfter(), org.matsim.withinday.utils.EditPlans.findRealActBefore(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElementIndex(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.core.mobsim.qsim.QSim.getSimTimer(), org.matsim.core.mobsim.framework.MobsimTimer.getTimeOfDay(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.indexOfPlanElement(), org.matsim.withinday.utils.EditTrips.insertEmptyTrip(), org.matsim.withinday.utils.EditTrips.replanCurrentTrip(), org.matsim.core.mobsim.qsim.QSim.rescheduleActivityEnd(), and org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.resetCaches().

Referenced by org.matsim.withinday.utils.EditPlans.insertActivity().

185  {
186  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
187  List<PlanElement> planElements = plan.getPlanElements() ;
188 
189  checkIfNotInPastOrCurrent(agent, index) ;
190  planElements.add( index, activity ) ;
191  {
192  // activity before:
193  Activity actBefore = findRealActBefore(agent, index);
194  if ( actBefore != null ) {
195  if ( WithinDayAgentUtils.indexOfPlanElement(agent, actBefore) < WithinDayAgentUtils.getCurrentPlanElementIndex(agent) ) {
196  // we are already under way
197  editTrips.replanCurrentTrip(agent, this.mobsim.getSimTimer().getTimeOfDay(), upstreamMode );
198  } else {
199  // we are not yet under way; inserting empty trip:
200  EditTrips.insertEmptyTrip(plan, actBefore, activity, upstreamMode, pf ) ;
201  }
202  }
203  }
204  {
205  // activity after:
206  Activity actAfter = findRealActAfter(agent, index);
207  if ( actAfter != null ) {
208  EditTrips.insertEmptyTrip(plan, activity, actAfter, downstreamMode, pf ) ;
209  }
210  }
211  WithinDayAgentUtils.resetCaches(agent);
212  this.mobsim.rescheduleActivityEnd(agent);
213  }
static Activity findRealActBefore(MobsimAgent agent, int index)
Definition: EditPlans.java:288
final PopulationFactory pf
Definition: EditPlans.java:49
static void checkIfNotInPastOrCurrent(MobsimAgent agent, int index)
Definition: EditPlans.java:245
List< PlanElement > getPlanElements()
final void rescheduleActivityEnd(MobsimAgent agent)
Definition: QSim.java:185
static Activity findRealActAfter(MobsimAgent agent, int index)
Definition: EditPlans.java:268
final boolean replanCurrentTrip(MobsimAgent agent, double now, String routingMode)
Definition: EditTrips.java:144
Here is the call graph for this function:

◆ removeActivity() [2/2]

PlanElement org.matsim.withinday.utils.EditPlans.removeActivity ( MobsimAgent  agent,
int  index 
)

Convenience method, clarifying that this can be called without giving the mode.

Definition at line 219 of file EditPlans.java.

References org.matsim.withinday.utils.EditPlans.removeActivity().

219  {
220  return removeActivity( agent, index, null ) ;
221  }
PlanElement removeActivity(MobsimAgent agent, int index, String mode)
Definition: EditPlans.java:91
Here is the call graph for this function:

◆ replaceActivity() [2/2]

final Activity org.matsim.withinday.utils.EditPlans.replaceActivity ( MobsimAgent  agent,
int  index,
Activity  newAct 
)

Convenience method, clarifying that this can be called without giving the mode.

Definition at line 225 of file EditPlans.java.

References org.matsim.withinday.utils.EditPlans.replaceActivity().

225  {
226  return replaceActivity( agent, index, newAct, null, null ) ;
227  }
final Activity replaceActivity(MobsimAgent agent, int index, Activity newAct, String upstreamMode, String downstreamMode)
Definition: EditPlans.java:124
Here is the call graph for this function:

◆ insertActivity() [2/2]

void org.matsim.withinday.utils.EditPlans.insertActivity ( MobsimAgent  agent,
int  index,
Activity  activity 
)

Convenience method, clarifying that this can be called without giving the mode.

Definition at line 231 of file EditPlans.java.

References org.matsim.withinday.utils.EditTrips.findCurrentTrip(), org.matsim.core.router.TripStructureUtils.Trip.getTripElements(), org.matsim.core.router.TripStructureUtils.identifyMainMode(), and org.matsim.withinday.utils.EditPlans.insertActivity().

231  {
232  String mode = TripStructureUtils.identifyMainMode( EditTrips.findCurrentTrip(agent ).getTripElements() ) ;
233  insertActivity( agent, index, activity, mode, mode ) ;
234  }
void insertActivity(MobsimAgent agent, int index, Activity activity, String upstreamMode, String downstreamMode)
Definition: EditPlans.java:185
Here is the call graph for this function:

◆ checkIfNotStageActivity()

void org.matsim.withinday.utils.EditPlans.checkIfNotStageActivity ( Activity  origAct)
private

Definition at line 237 of file EditPlans.java.

References org.matsim.api.core.v01.population.Activity.getType(), and org.matsim.core.router.StageActivityTypeIdentifier.isStageActivity().

Referenced by org.matsim.withinday.utils.EditPlans.replaceActivity().

237  {
238  if( StageActivityTypeIdentifier.isStageActivity(origAct.getType()) ){
239  throw new ReplanningException("trying to replace a helper activity (stage activity) by a real activity; this is not possible") ;
240  }
241  }
Here is the call graph for this function:

◆ checkIfTripHasAlreadyStarted()

static boolean org.matsim.withinday.utils.EditPlans.checkIfTripHasAlreadyStarted ( MobsimAgent  agent,
final List< PlanElement currentTripElements 
)
staticprivate

Definition at line 242 of file EditPlans.java.

Referenced by org.matsim.withinday.utils.EditPlans.removeActivity(), and org.matsim.withinday.utils.EditPlans.replaceActivity().

242  {
243  return currentTripElements.contains( ((PlanAgent)agent).getCurrentPlanElement() ) ;
244  }

◆ checkIfNotInPastOrCurrent()

static void org.matsim.withinday.utils.EditPlans.checkIfNotInPastOrCurrent ( MobsimAgent  agent,
int  index 
)
staticprivate

Definition at line 245 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElementIndex().

Referenced by org.matsim.withinday.utils.EditPlans.insertActivity(), org.matsim.withinday.utils.EditPlans.removeActivity(), and org.matsim.withinday.utils.EditPlans.replaceActivity().

245  {
246  final Integer currentIndex = WithinDayAgentUtils.getCurrentPlanElementIndex(agent);
247 
248  // make sure we are not yet beyond the to-be-replanned activity:
249  if ( index <= currentIndex ) {
250  throw new ReplanningException("trying to replace an activity that lies in the past or is current; this is not possible") ;
251  }
252  }
Here is the call graph for this function:

◆ checkIfSameMode()

static void org.matsim.withinday.utils.EditPlans.checkIfSameMode ( String  upstreamMode,
final String  currentMode 
)
staticprivate

Definition at line 253 of file EditPlans.java.

Referenced by org.matsim.withinday.utils.EditPlans.replaceActivity().

253  {
254  if ( upstreamMode!=null && !upstreamMode.equals(currentMode) ) {
255  throw new ReplanningException( "cannot change mode in trip that has already started. Don't set the mode in the request, "
256  + "or somehow make the agent to abort the current trip first." ) ;
257  }
258  }

◆ findRealActAfter()

static Activity org.matsim.withinday.utils.EditPlans.findRealActAfter ( MobsimAgent  agent,
int  index 
)
static

Definition at line 268 of file EditPlans.java.

References org.matsim.withinday.utils.EditPlans.findIndexOfRealActAfter(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), and org.matsim.api.core.v01.population.Plan.getPlanElements().

Referenced by org.matsim.withinday.utils.EditPlans.insertActivity().

268  {
269  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
270  List<PlanElement> planElements = plan.getPlanElements() ;
271  return (Activity) planElements.get( findIndexOfRealActAfter(agent, index) ) ;
272  }
static int findIndexOfRealActAfter(MobsimAgent agent, int index)
Definition: EditPlans.java:273
List< PlanElement > getPlanElements()
Here is the call graph for this function:

◆ findIndexOfRealActAfter()

static int org.matsim.withinday.utils.EditPlans.findIndexOfRealActAfter ( MobsimAgent  agent,
int  index 
)
static

Definition at line 273 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.api.core.v01.population.Activity.getType(), and org.matsim.core.router.StageActivityTypeIdentifier.isStageActivity().

Referenced by org.matsim.withinday.utils.EditPlans.findRealActAfter().

273  {
274  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
275  List<PlanElement> planElements = plan.getPlanElements() ;
276 
277  int theIndex = -1 ;
278  for ( int ii=planElements.size()-1 ; ii>index; ii-- ) {
279  if ( planElements.get(ii) instanceof Activity ) {
280  Activity act = (Activity) planElements.get(ii) ;
281  if ( !StageActivityTypeIdentifier.isStageActivity( act.getType() ) ) {
282  theIndex = ii ;
283  }
284  }
285  }
286  return theIndex ;
287  }
List< PlanElement > getPlanElements()
Here is the call graph for this function:

◆ findRealActBefore()

static Activity org.matsim.withinday.utils.EditPlans.findRealActBefore ( MobsimAgent  agent,
int  index 
)
static

Definition at line 288 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.api.core.v01.population.Activity.getType(), and org.matsim.core.router.StageActivityTypeIdentifier.isStageActivity().

Referenced by org.matsim.withinday.utils.EditPlans.insertActivity().

288  {
289  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent) ;
290  List<PlanElement> planElements = plan.getPlanElements() ;
291 
292  Activity prevAct = null ;
293  for ( int ii=0 ; ii<index ; ii++ ) {
294  if ( planElements.get(ii) instanceof Activity ) {
295  Activity act = (Activity) planElements.get(ii) ;
296  if ( !StageActivityTypeIdentifier.isStageActivity( act.getType() ) ) {
297  prevAct = act ;
298  }
299  }
300  }
301  return prevAct;
302  }
List< PlanElement > getPlanElements()
Here is the call graph for this function:

◆ rescheduleActivityEnd()

void org.matsim.withinday.utils.EditPlans.rescheduleActivityEnd ( MobsimAgent  agent)

Definition at line 314 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.QSim.rescheduleActivityEnd().

Referenced by org.matsim.core.mobsim.qsim.PreplanningEngine.decide(), and org.matsim.core.mobsim.qsim.PreplanningEngine.updateAgentPlan().

314  {
315  // this is mostly for retrofitting existing code. but maybe also useful by itself
316  this.mobsim.rescheduleActivityEnd(agent);
317  }
final void rescheduleActivityEnd(MobsimAgent agent)
Definition: QSim.java:185
Here is the call graph for this function:

◆ isAtRealActivity()

boolean org.matsim.withinday.utils.EditPlans.isAtRealActivity ( MobsimAgent  agent)

Definition at line 318 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElement(), and org.matsim.withinday.utils.EditPlans.isRealActivity().

Referenced by org.matsim.withinday.utils.EditPlans.addActivityAtEnd(), and org.matsim.withinday.utils.EditPlans.getModeOfCurrentOrNextTrip().

318  {
319  PlanElement pe = WithinDayAgentUtils.getCurrentPlanElement(agent) ;
320  if ( isRealActivity(pe) ) {
321  return true ;
322  } else {
323  return false ;
324  }
325  }
boolean isRealActivity(PlanElement pe)
Definition: EditPlans.java:326
Here is the call graph for this function:

◆ isRealActivity()

boolean org.matsim.withinday.utils.EditPlans.isRealActivity ( PlanElement  pe)

Definition at line 326 of file EditPlans.java.

References org.matsim.core.router.StageActivityTypeIdentifier.isStageActivity().

Referenced by org.matsim.withinday.utils.EditPlans.isAtRealActivity().

326  {
327  return pe instanceof Activity && ! ( StageActivityTypeIdentifier.isStageActivity( ((Activity)pe).getType() ) );
328  }
Here is the call graph for this function:

◆ getModeOfCurrentOrNextTrip()

String org.matsim.withinday.utils.EditPlans.getModeOfCurrentOrNextTrip ( MobsimAgent  agent)

Definition at line 330 of file EditPlans.java.

References org.matsim.withinday.utils.EditTrips.findCurrentTrip(), org.matsim.withinday.utils.EditTrips.findTripAfterActivity(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElement(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), org.matsim.core.router.TripStructureUtils.Trip.getTripElements(), org.matsim.core.router.TripStructureUtils.identifyMainMode(), and org.matsim.withinday.utils.EditPlans.isAtRealActivity().

330  {
331  Trip trip ;
332  if ( isAtRealActivity( agent ) ) {
333  Activity activity = (Activity) WithinDayAgentUtils.getCurrentPlanElement(agent) ;
334  trip = editTrips.findTripAfterActivity(WithinDayAgentUtils.getModifiablePlan(agent), activity) ;
335  } else {
336  trip = EditTrips.findCurrentTrip(agent ) ;
337  }
338  return TripStructureUtils.identifyMainMode(trip.getTripElements()) ;
339  }
Trip findTripAfterActivity(Plan plan, Activity activity)
Definition: EditTrips.java:756
boolean isAtRealActivity(MobsimAgent agent)
Definition: EditPlans.java:318
Here is the call graph for this function:

◆ flushEverythingBeyondCurrent()

void org.matsim.withinday.utils.EditPlans.flushEverythingBeyondCurrent ( MobsimAgent  agent)

Definition at line 340 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElementIndex(), org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan(), and org.matsim.api.core.v01.population.Plan.getPlanElements().

340  {
341  List<PlanElement> pes = WithinDayAgentUtils.getModifiablePlan(agent).getPlanElements() ;
342  Integer index = WithinDayAgentUtils.getCurrentPlanElementIndex(agent) ;
343  for ( int ii=pes.size()-1 ; ii>index ; ii-- ) {
344  pes.remove(ii) ;
345  }
346  }
Here is the call graph for this function:

◆ rescheduleCurrentActivityEndtime()

void org.matsim.withinday.utils.EditPlans.rescheduleCurrentActivityEndtime ( MobsimAgent  agent,
double  newEndTime 
)

Definition at line 347 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElementIndex(), and org.matsim.withinday.utils.EditPlans.rescheduleActivityEndtime().

347  {
348  Integer index = WithinDayAgentUtils.getCurrentPlanElementIndex(agent) ;
349  this.rescheduleActivityEndtime(agent, index, newEndTime);
350  }
final void rescheduleActivityEndtime(MobsimAgent agent, int index, double newEndTime)
Definition: EditPlans.java:118
Here is the call graph for this function:

◆ createFinalActivity()

Activity org.matsim.withinday.utils.EditPlans.createFinalActivity ( String  type,
Id< Link newLinkId 
)

Definition at line 352 of file EditPlans.java.

References org.matsim.api.core.v01.population.PopulationFactory.createActivityFromLinkId(), and org.matsim.api.core.v01.population.Activity.setEndTime().

352  {
353  Activity newAct = this.pf.createActivityFromLinkId(type, newLinkId);
354  newAct.setEndTime( Double.POSITIVE_INFINITY ) ;
355  return newAct ;
356  }
final PopulationFactory pf
Definition: EditPlans.java:49
Activity createActivityFromLinkId(String actType, Id< Link > linkId)
void setEndTime(final double seconds)
Here is the call graph for this function:

◆ getCurrentPlanElementIndex()

static Integer org.matsim.withinday.utils.EditPlans.getCurrentPlanElementIndex ( MobsimAgent  agent)
static

Definition at line 362 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElementIndex().

362  {
363  return WithinDayAgentUtils.getCurrentPlanElementIndex( agent ) ;
364  }
Here is the call graph for this function:

◆ findLegsWithModeInFuture()

static List<Leg> org.matsim.withinday.utils.EditPlans.findLegsWithModeInFuture ( MobsimAgent  agent,
String  mode 
)
static

Definition at line 366 of file EditPlans.java.

References org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getCurrentPlanElementIndex(), and org.matsim.core.mobsim.qsim.agents.WithinDayAgentUtils.getModifiablePlan().

Referenced by org.matsim.core.mobsim.qsim.PreplanningEngine.decide().

366  {
367  List<Leg> retVal = new ArrayList<>();
368  Plan plan = WithinDayAgentUtils.getModifiablePlan(agent);
369  for (int ii = WithinDayAgentUtils.getCurrentPlanElementIndex(agent); ii < plan.getPlanElements().size(); ii++) {
370  PlanElement pe = plan.getPlanElements().get(ii);
371  if (pe instanceof Leg) {
372  if ( Objects.equals(mode, ((Leg)pe).getMode() )) {
373  retVal.add((Leg)pe);
374  }
375  }
376  }
377  return retVal;
378  }
Here is the call graph for this function:

Member Data Documentation

◆ log

final Logger org.matsim.withinday.utils.EditPlans.log = LogManager.getLogger( EditPlans.class )
staticprivate

Definition at line 45 of file EditPlans.java.

◆ mobsim

final QSim org.matsim.withinday.utils.EditPlans.mobsim
private

Definition at line 47 of file EditPlans.java.

Referenced by org.matsim.withinday.utils.EditPlans.EditPlans().

◆ editTrips

final EditTrips org.matsim.withinday.utils.EditPlans.editTrips
private

Definition at line 48 of file EditPlans.java.

Referenced by org.matsim.withinday.utils.EditPlans.EditPlans().

◆ pf

final PopulationFactory org.matsim.withinday.utils.EditPlans.pf
private

Definition at line 49 of file EditPlans.java.

Referenced by org.matsim.withinday.utils.EditPlans.replaceActivity().


The documentation for this class was generated from the following file: