Skip to content

Commit

Permalink
fix #14884
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed May 18, 2024
1 parent 04dae9c commit ed834d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/microsim/MSFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ MSFrame::fillOptions() {
oc.doRegister("max-num-vehicles", new Option_Integer(-1));
oc.addDescription("max-num-vehicles", "Processing", TL("Delay vehicle insertion to stay within the given maximum number"));

oc.doRegister("max-num-persons", new Option_Integer(-1));
oc.addDescription("max-num-persons", "Processing", TL("Delay person insertion to stay within the given maximum number"));

oc.doRegister("max-num-teleports", new Option_Integer(-1));
oc.addDescription("max-num-teleports", "Processing", TL("Abort the simulation if the given maximum number of teleports is exceeded"));

Expand Down
7 changes: 7 additions & 0 deletions src/microsim/transportables/MSTransportableControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ MSTransportableControl::MSTransportableControl(const bool isPerson):
OutputDevice::createDeviceByOption("personinfo-output", "tripinfos", "tripinfo_file.xsd");
}
myAbortWaitingTimeout = string2time(oc.getString("time-to-teleport.ride"));
myMaxTransportableNumber = isPerson ? oc.getInt("max-num-persons") : -1;
}


Expand Down Expand Up @@ -198,6 +199,12 @@ MSTransportableControl::checkWaiting(MSNet* net, const SUMOTime time) {
// we cannot use an iterator here because there might be additions to the vector while proceeding
for (auto it = transportables.begin(); it != transportables.end();) {
MSTransportable* t = *it;
if (myMaxTransportableNumber > 0 && myRunningNumber >= myMaxTransportableNumber) {
TransportableVector& nextStep = myWaiting4Departure[time + DELTA_T];
nextStep.insert(nextStep.begin(), transportables.begin(), transportables.end());
transportables.clear();
break;
}
it = transportables.erase(it);
myWaitingForDepartureNumber--;
const bool isPerson = t->isPerson();
Expand Down
3 changes: 3 additions & 0 deletions src/microsim/transportables/MSTransportableControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ class MSTransportableControl {
/// @brief whether a new transportable waiting for a vehicle has been added in the last step
bool myHaveNewWaiting;

/// @brief maximum transportable count
int myMaxTransportableNumber;

private:
MSPModel* myMovementModel;

Expand Down

0 comments on commit ed834d2

Please sign in to comment.