From fa4639edcc50dd58f2f1cb8ac02e892fd7339d60 Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Tue, 15 Aug 2023 16:23:06 -0300 Subject: [PATCH 1/8] Adds comment on the test that lead to the discovery of the issue (mostly just to open the PR) --- .../agentsim/agents/ElectricVehicleChargingBehaviorTest.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala b/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala index 56dfd5fb3d5..e4aaceb9d95 100644 --- a/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala +++ b/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala @@ -379,6 +379,8 @@ class ElectricVehicleChargingBehaviorTest ", expecting most of the 4 legs for each of the 50 people to be ride hail legs." } + // this test gets stuck on CI, investigation lead to the conclusion that the culprit is AV RH + // getting stuck when beam simulations are running in parallel "Ride Hail Electric vehicles" should "pick chargers choosing smaller DrivingTimeCost." in { // this config is only interested on the first charging plugin event when, // vehicles are at known coordinates, population plans are set to walk to not interfere with ride hail. From b693f7456697dc158f7cc3250793e0e306ee0742 Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Tue, 29 Aug 2023 17:53:13 -0300 Subject: [PATCH 2/8] Adds scenario configurations for testing AV RH getting stuck. --- test/input/beamville/beam-av-rh-10k.conf | 77 +++++++++++++++++++ test/input/beamville/beam-av-rh-3k.conf | 77 +++++++++++++++++++ .../AVRH/10k/householdAttributes.xml | 3 + test/test-resources/AVRH/10k/households.xml | 3 + test/test-resources/AVRH/10k/population.xml | 3 + .../AVRH/10k/populationAttributes.xml | 3 + .../test-resources/AVRH/10k/rideHailFleet.csv | 3 + .../AVRH/3k/householdAttributes.xml | 3 + test/test-resources/AVRH/3k/households.xml | 3 + test/test-resources/AVRH/3k/population.xml | 3 + .../AVRH/3k/populationAttributes.xml | 3 + test/test-resources/AVRH/3k/rideHailFleet.csv | 3 + .../AVRH/vehicleTypes-60km-range.csv | 3 + 13 files changed, 187 insertions(+) create mode 100644 test/input/beamville/beam-av-rh-10k.conf create mode 100644 test/input/beamville/beam-av-rh-3k.conf create mode 100644 test/test-resources/AVRH/10k/householdAttributes.xml create mode 100644 test/test-resources/AVRH/10k/households.xml create mode 100644 test/test-resources/AVRH/10k/population.xml create mode 100644 test/test-resources/AVRH/10k/populationAttributes.xml create mode 100644 test/test-resources/AVRH/10k/rideHailFleet.csv create mode 100644 test/test-resources/AVRH/3k/householdAttributes.xml create mode 100644 test/test-resources/AVRH/3k/households.xml create mode 100644 test/test-resources/AVRH/3k/population.xml create mode 100644 test/test-resources/AVRH/3k/populationAttributes.xml create mode 100644 test/test-resources/AVRH/3k/rideHailFleet.csv create mode 100644 test/test-resources/AVRH/vehicleTypes-60km-range.csv diff --git a/test/input/beamville/beam-av-rh-10k.conf b/test/input/beamville/beam-av-rh-10k.conf new file mode 100644 index 00000000000..93404454275 --- /dev/null +++ b/test/input/beamville/beam-av-rh-10k.conf @@ -0,0 +1,77 @@ +include "beam.conf" + +beam.physsim.name = "AV RH beamville 10k" +beam.agentsim.endTime = "24:00:00" + +# base config +matsim.modules.global.randomSeed = 654154 +beam.outputs.events.fileOutputFormats = xml +beam.physsim.skipPhysSim = true +beam.agentsim.lastIteration = 0 +beam.agentsim.agents.vehicles.sharedFleets = [] +beam.agentsim.taz.filePath=${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/taz-centers.csv" + +# rideHailConfig +beam.agentsim.agents.rideHail.managers = [ + { + iterationStats.timeBinSizeInSec = 3600 + defaultCostPerMile = 1.25 + defaultCostPerMinute = 0.75 + rideHailManager.radiusInMeters = 50000 + # allocationManager(DEFAULT_MANAGER | EV_MANAGER | POOLING_ALONSO_MORA) + allocationManager.name = "POOLING_ALONSO_MORA" + allocationManager.requestBufferTimeoutInSeconds = 200 + allocationManager.maxWaitingTimeInSec = 18000 + allocationManager.maxExcessRideTime = 0.5 # up to +50% + allocationManager.matchingAlgorithm = "ALONSO_MORA_MATCHING_WITH_ASYNC_GREEDY_ASSIGNMENT" + allocationManager.alonsoMora.maxRequestsPerVehicle = 5 + repositioningManager.name = "DEMAND_FOLLOWING_REPOSITIONING_MANAGER" + repositioningManager.timeout = 300 + # DEMAND_FOLLOWING_REPOSITIONING_MANAGER + repositioningManager.demandFollowingRepositioningManager.sensitivityOfRepositioningToDemand = 1 + repositioningManager.demandFollowingRepositioningManager.numberOfClustersForDemand = 30 + # REPOSITIONING_LOW_WAITING_TIMES + allocationManager.repositionLowWaitingTimes.percentageOfVehiclesToReposition = 0.0 + allocationManager.repositionLowWaitingTimes.repositionCircleRadiusInMeters = 100 + allocationManager.repositionLowWaitingTimes.timeWindowSizeInSecForDecidingAboutRepositioning = 12000 + allocationManager.repositionLowWaitingTimes.allowIncreasingRadiusIfDemandInRadiusLow = true + allocationManager.repositionLowWaitingTimes.minDemandPercentageInRadius = 0.1 + allocationManager.repositionLowWaitingTimes.minimumNumberOfIdlingVehiclesThresholdForRepositioning = 1000 + allocationManager.repositionLowWaitingTimes.repositioningMethod = "TOP_SCORES" + allocationManager.repositionLowWaitingTimes.keepMaxTopNScores = 5 + allocationManager.repositionLowWaitingTimes.minScoreThresholdForRepositioning = 100000000.0 + allocationManager.repositionLowWaitingTimes.distanceWeight = 0.01 + allocationManager.repositionLowWaitingTimes.waitingTimeWeight = 4.0 + allocationManager.repositionLowWaitingTimes.demandWeight = 4.0 + allocationManager.repositionLowWaitingTimes.produceDebugImages = true + initialization.filePath = ${beam.inputDirectory}"/../../test-resources/AVRH/10k/rideHailFleet.csv" + initialization.initType="FILE" + initialization.parking.filePath=${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/taz-parking-empty.csv" + } +] +beam.agentsim.agents.plans { + inputPlansFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/10k/population.xml" + inputPersonAttributesFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/10k/populationAttributes.xml" +} +beam.agentsim.agents.households { + inputFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/10k/households.xml" + inputHouseholdAttributesFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/10k/householdAttributes.xml" +} +beam.agentsim.agents.vehicles.vehiclesFilePath = ${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/vehicles-empty.csv" +beam.agentsim.agents.parking.minSearchRadius = 8000 + +# test config +beam.agentsim.agents.plans.inputPlansFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/10k/population.xml" +beam.agentsim.taz.parkingFilePath = ${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/taz-parking-ride-hail-driving-time-cost.csv" +# 15 Km range +#beam.agentsim.agents.vehicles.vehicleTypesFilePath = ${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/vehicleTypes-low-capacity.csv" +beam.agentsim.agents.vehicles.vehicleTypesFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/vehicleTypes-60km-range.csv" +#beam.agentsim.agents.vehicles.vehicleTypesFilePath = ${beam.inputDirectory}"/vehicleTypes_withL5.csv" +beam.agentsim.agents.rideHail.charging.multinomialLogit.params.drivingTimeMultiplier = -0.01666667 # default +# initial SoC is 0.7 or 10.5 Km, vehicles should immediately pick a charging station +beam.agentsim.agents.modalBehaviors.multinomialLogit.params.ride_hail_intercept = 0 +#beam.agentsim.agents.rideHail.human.refuelRequiredThresholdInMeters = 11000.0 +#beam.agentsim.agents.rideHail.human.noRefuelThresholdInMeters = 12000.0 +#beam.agentsim.agents.rideHail.cav.refuelRequiredThresholdInMeters = 11000.0 +#beam.agentsim.agents.rideHail.cav.noRefuelThresholdInMeters = 12000.0 +#beam.agentsim.agents.rideHail.rangeBufferForDispatchInMeters = 0 \ No newline at end of file diff --git a/test/input/beamville/beam-av-rh-3k.conf b/test/input/beamville/beam-av-rh-3k.conf new file mode 100644 index 00000000000..27fb16bc876 --- /dev/null +++ b/test/input/beamville/beam-av-rh-3k.conf @@ -0,0 +1,77 @@ +include "beam.conf" + +beam.physsim.name = "AV RH beamville 3k" +beam.agentsim.endTime = "24:00:00" + +# base config +matsim.modules.global.randomSeed = 654154 +beam.outputs.events.fileOutputFormats = xml +beam.physsim.skipPhysSim = true +beam.agentsim.lastIteration = 0 +beam.agentsim.agents.vehicles.sharedFleets = [] +beam.agentsim.taz.filePath=${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/taz-centers.csv" + +# rideHailConfig +beam.agentsim.agents.rideHail.managers = [ + { + iterationStats.timeBinSizeInSec = 3600 + defaultCostPerMile = 1.25 + defaultCostPerMinute = 0.75 + rideHailManager.radiusInMeters = 50000 + # allocationManager(DEFAULT_MANAGER | EV_MANAGER | POOLING_ALONSO_MORA) + allocationManager.name = "POOLING_ALONSO_MORA" + allocationManager.requestBufferTimeoutInSeconds = 200 + allocationManager.maxWaitingTimeInSec = 18000 + allocationManager.maxExcessRideTime = 0.5 # up to +50% + allocationManager.matchingAlgorithm = "ALONSO_MORA_MATCHING_WITH_ASYNC_GREEDY_ASSIGNMENT" + allocationManager.alonsoMora.maxRequestsPerVehicle = 5 + repositioningManager.name = "DEMAND_FOLLOWING_REPOSITIONING_MANAGER" + repositioningManager.timeout = 300 + # DEMAND_FOLLOWING_REPOSITIONING_MANAGER + repositioningManager.demandFollowingRepositioningManager.sensitivityOfRepositioningToDemand = 1 + repositioningManager.demandFollowingRepositioningManager.numberOfClustersForDemand = 30 + # REPOSITIONING_LOW_WAITING_TIMES + allocationManager.repositionLowWaitingTimes.percentageOfVehiclesToReposition = 0.0 + allocationManager.repositionLowWaitingTimes.repositionCircleRadiusInMeters = 100 + allocationManager.repositionLowWaitingTimes.timeWindowSizeInSecForDecidingAboutRepositioning = 12000 + allocationManager.repositionLowWaitingTimes.allowIncreasingRadiusIfDemandInRadiusLow = true + allocationManager.repositionLowWaitingTimes.minDemandPercentageInRadius = 0.1 + allocationManager.repositionLowWaitingTimes.minimumNumberOfIdlingVehiclesThresholdForRepositioning = 1000 + allocationManager.repositionLowWaitingTimes.repositioningMethod = "TOP_SCORES" + allocationManager.repositionLowWaitingTimes.keepMaxTopNScores = 5 + allocationManager.repositionLowWaitingTimes.minScoreThresholdForRepositioning = 100000000.0 + allocationManager.repositionLowWaitingTimes.distanceWeight = 0.01 + allocationManager.repositionLowWaitingTimes.waitingTimeWeight = 4.0 + allocationManager.repositionLowWaitingTimes.demandWeight = 4.0 + allocationManager.repositionLowWaitingTimes.produceDebugImages = true + initialization.filePath = ${beam.inputDirectory}"/../../test-resources/AVRH/3k/rideHailFleet.csv" + initialization.initType="FILE" + initialization.parking.filePath=${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/taz-parking-empty.csv" + } +] +beam.agentsim.agents.plans { + inputPlansFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/3k/population.xml" + inputPersonAttributesFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/3k/populationAttributes.xml" +} +beam.agentsim.agents.households { + inputFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/3k/households.xml" + inputHouseholdAttributesFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/3k/householdAttributes.xml" +} +beam.agentsim.agents.vehicles.vehiclesFilePath = ${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/vehicles-empty.csv" +beam.agentsim.agents.parking.minSearchRadius = 8000 + +# test config +beam.agentsim.agents.plans.inputPlansFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/3k/population.xml" +beam.agentsim.taz.parkingFilePath = ${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/taz-parking-ride-hail-driving-time-cost.csv" +# 15 Km range +#beam.agentsim.agents.vehicles.vehicleTypesFilePath = ${beam.inputDirectory}"/../../test-resources/ElectricVehicleChargingBehaviorTestData/vehicleTypes-low-capacity.csv" +beam.agentsim.agents.vehicles.vehicleTypesFilePath = ${beam.inputDirectory}"/../../test-resources/AVRH/vehicleTypes-60km-range.csv" +#beam.agentsim.agents.vehicles.vehicleTypesFilePath = ${beam.inputDirectory}"/vehicleTypes_withL5.csv" +beam.agentsim.agents.rideHail.charging.multinomialLogit.params.drivingTimeMultiplier = -0.01666667 # default +# initial SoC is 0.7 or 10.5 Km, vehicles should immediately pick a charging station +beam.agentsim.agents.modalBehaviors.multinomialLogit.params.ride_hail_intercept = 0 +#beam.agentsim.agents.rideHail.human.refuelRequiredThresholdInMeters = 11000.0 +#beam.agentsim.agents.rideHail.human.noRefuelThresholdInMeters = 12000.0 +#beam.agentsim.agents.rideHail.cav.refuelRequiredThresholdInMeters = 11000.0 +#beam.agentsim.agents.rideHail.cav.noRefuelThresholdInMeters = 12000.0 +#beam.agentsim.agents.rideHail.rangeBufferForDispatchInMeters = 0 \ No newline at end of file diff --git a/test/test-resources/AVRH/10k/householdAttributes.xml b/test/test-resources/AVRH/10k/householdAttributes.xml new file mode 100644 index 00000000000..9d63f63a47f --- /dev/null +++ b/test/test-resources/AVRH/10k/householdAttributes.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96c521e5464a08ae6751a07f61d5f4bbac4131f3f4ed02efa89f11e7e3c2b558 +size 2890147 diff --git a/test/test-resources/AVRH/10k/households.xml b/test/test-resources/AVRH/10k/households.xml new file mode 100644 index 00000000000..c4cdfe1e7b2 --- /dev/null +++ b/test/test-resources/AVRH/10k/households.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4049226318e9f601966bbd8b430776b37c93b8017a2299af35ee0349092083c4 +size 1850226 diff --git a/test/test-resources/AVRH/10k/population.xml b/test/test-resources/AVRH/10k/population.xml new file mode 100644 index 00000000000..5c57eaa7616 --- /dev/null +++ b/test/test-resources/AVRH/10k/population.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d22fb8e8192f47dc5b2305cbd72fa546ae5614eae3572c8a23c1e973e03023c +size 6540353 diff --git a/test/test-resources/AVRH/10k/populationAttributes.xml b/test/test-resources/AVRH/10k/populationAttributes.xml new file mode 100644 index 00000000000..655cb7be5fc --- /dev/null +++ b/test/test-resources/AVRH/10k/populationAttributes.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:340ee114629d56d42ee03f873af9f68197865f78acea5b04cd81975ace11a1a9 +size 2720173 diff --git a/test/test-resources/AVRH/10k/rideHailFleet.csv b/test/test-resources/AVRH/10k/rideHailFleet.csv new file mode 100644 index 00000000000..e7ed33758f9 --- /dev/null +++ b/test/test-resources/AVRH/10k/rideHailFleet.csv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b0ec6e8857d60c81000a0bcceda02a5dac08a4ebe5e7dbd9ab19d1feb958ea2 +size 496089 diff --git a/test/test-resources/AVRH/3k/householdAttributes.xml b/test/test-resources/AVRH/3k/householdAttributes.xml new file mode 100644 index 00000000000..d88b18296ca --- /dev/null +++ b/test/test-resources/AVRH/3k/householdAttributes.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2e0ffbc5cab27eda49691d2c37a0288c21e3343e9adeb760931a9c76c142351 +size 864147 diff --git a/test/test-resources/AVRH/3k/households.xml b/test/test-resources/AVRH/3k/households.xml new file mode 100644 index 00000000000..c38906db16c --- /dev/null +++ b/test/test-resources/AVRH/3k/households.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91ac277f01adaa1aa8f6397d52d34409c78abe040667c1fd7fdc8776caeb1048 +size 549226 diff --git a/test/test-resources/AVRH/3k/population.xml b/test/test-resources/AVRH/3k/population.xml new file mode 100644 index 00000000000..56e7196779c --- /dev/null +++ b/test/test-resources/AVRH/3k/population.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e44e07e79b33061e3e47986f970e1b50797ac9ea7ab4c87f71e919af4d12a1b +size 1959353 diff --git a/test/test-resources/AVRH/3k/populationAttributes.xml b/test/test-resources/AVRH/3k/populationAttributes.xml new file mode 100644 index 00000000000..7f3112aab9e --- /dev/null +++ b/test/test-resources/AVRH/3k/populationAttributes.xml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5bf527e6ce4555046d21dbcf5f8cc740df7827ca4ad99bdf26159bac0e462613 +size 813173 diff --git a/test/test-resources/AVRH/3k/rideHailFleet.csv b/test/test-resources/AVRH/3k/rideHailFleet.csv new file mode 100644 index 00000000000..3570fc51a39 --- /dev/null +++ b/test/test-resources/AVRH/3k/rideHailFleet.csv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eac0fb9c3bf9a40260b225cf04cda2fce8c0836d6de119e0dd011ec1e7ac0a62 +size 148889 diff --git a/test/test-resources/AVRH/vehicleTypes-60km-range.csv b/test/test-resources/AVRH/vehicleTypes-60km-range.csv new file mode 100644 index 00000000000..a3604f9e354 --- /dev/null +++ b/test/test-resources/AVRH/vehicleTypes-60km-range.csv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54fcff896a76ddcb78bb1f43ed5b15f235f1e44e4fcf8ea02db6d7ebe3cbaac7 +size 2106 From 60eb7c7ea20c072759e9b54171c00114b7b949ec Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Wed, 11 Oct 2023 11:15:54 -0300 Subject: [PATCH 3/8] Doubles Beamville's stuckAgentDetection timeout from 20s to 40s to specified classes. The default was kept as 60s. --- test/input/beamville/beam.conf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/input/beamville/beam.conf b/test/input/beamville/beam.conf index 43e5fa8cb80..44ac13f42b6 100755 --- a/test/input/beamville/beam.conf +++ b/test/input/beamville/beam.conf @@ -222,7 +222,7 @@ beam.debug.debugActorTimerIntervalInSec = 10 beam.debug.actor.logDepth = 12 beam.debug.stuckAgentDetection { - checkIntervalMs = 200 + checkIntervalMs = 400 checkMaxNumberOfMessagesEnabled = true defaultTimeoutMs = 60000 enabled = true @@ -234,42 +234,42 @@ beam.debug.stuckAgentDetection { rideHailAgent = 1 transitDriverAgent = 1 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.InitializeTrigger" }, { actorTypeToMaxNumberOfMessages { population = 11 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.PersonAgent$ActivityEndTrigger" }, { actorTypeToMaxNumberOfMessages { population = 1 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.PersonAgent$ActivityStartTrigger" }, { actorTypeToMaxNumberOfMessages { population = 60 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.PersonAgent$PersonDepartureTrigger" }, { actorTypeToMaxNumberOfMessages { population = 20 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$AlightVehicleTrigger" }, { actorTypeToMaxNumberOfMessages { population = 20 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$BoardVehicleTrigger" }, { @@ -278,7 +278,7 @@ beam.debug.stuckAgentDetection { rideHailAgent = 400 transitDriverAgent = 114 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$EndLegTrigger" }, { @@ -287,14 +287,14 @@ beam.debug.stuckAgentDetection { rideHailAgent = 400 transitDriverAgent = 114 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$StartLegTrigger" }, { actorTypeToMaxNumberOfMessages { transitDriverAgent = 1 } - markAsStuckAfterMs = 20000 + markAsStuckAfterMs = 40000 triggerType = "beam.agentsim.scheduler.BeamAgentScheduler$KillTrigger" } From 4fecbb00bf1de1bbeaaac8480ca2f3bdee56ebd9 Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Wed, 11 Oct 2023 12:07:57 -0300 Subject: [PATCH 4/8] THIS SHOULD BE ROLLED BACK BEFORE MERGING Modifies stuck finder code to log the maximum timeout observed on CI. --- src/main/scala/beam/utils/StuckFinder.scala | 8 +++++++- .../agents/ElectricVehicleChargingBehaviorTest.scala | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/scala/beam/utils/StuckFinder.scala b/src/main/scala/beam/utils/StuckFinder.scala index 0d6536eded3..e6f764e9188 100644 --- a/src/main/scala/beam/utils/StuckFinder.scala +++ b/src/main/scala/beam/utils/StuckFinder.scala @@ -130,13 +130,19 @@ class StuckFinder(val cfg: StuckAgentDetection) extends LazyLogging { result } + private var maxTimeoutObserved = 0L + def isStuckAgent(st: ScheduledTrigger, startedAtMs: Long, currentTimeMs: Long): Boolean = { val diff = currentTimeMs - startedAtMs val threshold = class2Threshold.getOrElse(toKey(st), cfg.defaultTimeoutMs) - val isStuck = diff > threshold + val isStuck = diff > threshold * 750 if (isStuck) { logger.warn(s"$st is stuck. Diff: $diff ms, Threshold: $threshold ms") } + if (maxTimeoutObserved < diff) { + maxTimeoutObserved = diff + logger.error(s"$st just set a new maximum observed timeout of $maxTimeoutObserved milliseconds") + } isStuck } diff --git a/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala b/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala index 1c339114f0b..ec90e42ee78 100644 --- a/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala +++ b/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala @@ -6,6 +6,7 @@ import beam.utils.EventReader import beam.utils.TestConfigUtils.testConfig import com.typesafe.config.ConfigFactory import org.matsim.api.core.v01.Id +import org.scalatest.BeforeAndAfterAll import org.matsim.api.core.v01.events.Event import org.matsim.vehicles.Vehicle import org.scalatest.AppendedClues.convertToClueful @@ -20,6 +21,7 @@ import scala.util.matching.Regex class ElectricVehicleChargingBehaviorTest extends AnyFlatSpec with Matchers + with BeforeAndAfterAll with BeamHelper with BeforeAndAfterAllConfigMap { @@ -579,6 +581,14 @@ class ElectricVehicleChargingBehaviorTest ", vehicles should be picking the faster chargers (more power output) more often than the slower ones." } + override def beforeAll(): Unit = { + logger.error("ElectricVehicleChargingBehaviorTest started.") + } + + override def afterAll(): Unit = { + logger.error("ElectricVehicleChargingBehaviorTest ended.") + } + def filterEvents(events: IndexedSeq[Event], filters: (String, String => Boolean)*): IndexedSeq[Event] = { events.filter(event => filters.forall(filter => From ed37a8492fb3e0e90f2f7160037b4468e21ed195 Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Wed, 11 Oct 2023 12:26:32 -0300 Subject: [PATCH 5/8] THIS SHOULD BE ROLLED BACK BEFORE MERGING fixes compile issue --- .../agentsim/agents/ElectricVehicleChargingBehaviorTest.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala b/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala index ec90e42ee78..f4e07782b1f 100644 --- a/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala +++ b/src/test/scala/beam/agentsim/agents/ElectricVehicleChargingBehaviorTest.scala @@ -581,12 +581,16 @@ class ElectricVehicleChargingBehaviorTest ", vehicles should be picking the faster chargers (more power output) more often than the slower ones." } + override val invokeBeforeAllAndAfterAllEvenIfNoTestsAreExpected = true + override def beforeAll(): Unit = { logger.error("ElectricVehicleChargingBehaviorTest started.") + super.beforeAll() } override def afterAll(): Unit = { logger.error("ElectricVehicleChargingBehaviorTest ended.") + super.afterAll() } def filterEvents(events: IndexedSeq[Event], filters: (String, String => Boolean)*): IndexedSeq[Event] = { From 10b9074f6171672d19b8966b945747d69efc591a Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Wed, 11 Oct 2023 14:38:49 -0300 Subject: [PATCH 6/8] Increasing beamville's stuckfinder timeout to 5 minutes just to observe the logs and see if ChargingSpec will pass. --- src/main/scala/beam/utils/StuckFinder.scala | 2 +- test/input/beamville/beam.conf | 24 ++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/beam/utils/StuckFinder.scala b/src/main/scala/beam/utils/StuckFinder.scala index e6f764e9188..da4ad1a09a3 100644 --- a/src/main/scala/beam/utils/StuckFinder.scala +++ b/src/main/scala/beam/utils/StuckFinder.scala @@ -135,7 +135,7 @@ class StuckFinder(val cfg: StuckAgentDetection) extends LazyLogging { def isStuckAgent(st: ScheduledTrigger, startedAtMs: Long, currentTimeMs: Long): Boolean = { val diff = currentTimeMs - startedAtMs val threshold = class2Threshold.getOrElse(toKey(st), cfg.defaultTimeoutMs) - val isStuck = diff > threshold * 750 + val isStuck = diff > threshold if (isStuck) { logger.warn(s"$st is stuck. Diff: $diff ms, Threshold: $threshold ms") } diff --git a/test/input/beamville/beam.conf b/test/input/beamville/beam.conf index 44ac13f42b6..6b7fd9c9dbe 100755 --- a/test/input/beamville/beam.conf +++ b/test/input/beamville/beam.conf @@ -222,11 +222,11 @@ beam.debug.debugActorTimerIntervalInSec = 10 beam.debug.actor.logDepth = 12 beam.debug.stuckAgentDetection { - checkIntervalMs = 400 + checkIntervalMs = 200 checkMaxNumberOfMessagesEnabled = true - defaultTimeoutMs = 60000 + defaultTimeoutMs = 300000 enabled = true - overallSimulationTimeoutMs = 100000 + overallSimulationTimeoutMs = 300000 thresholds = [ { actorTypeToMaxNumberOfMessages { @@ -234,42 +234,42 @@ beam.debug.stuckAgentDetection { rideHailAgent = 1 transitDriverAgent = 1 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.InitializeTrigger" }, { actorTypeToMaxNumberOfMessages { population = 11 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.PersonAgent$ActivityEndTrigger" }, { actorTypeToMaxNumberOfMessages { population = 1 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.PersonAgent$ActivityStartTrigger" }, { actorTypeToMaxNumberOfMessages { population = 60 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.PersonAgent$PersonDepartureTrigger" }, { actorTypeToMaxNumberOfMessages { population = 20 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$AlightVehicleTrigger" }, { actorTypeToMaxNumberOfMessages { population = 20 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$BoardVehicleTrigger" }, { @@ -278,7 +278,7 @@ beam.debug.stuckAgentDetection { rideHailAgent = 400 transitDriverAgent = 114 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$EndLegTrigger" }, { @@ -287,14 +287,14 @@ beam.debug.stuckAgentDetection { rideHailAgent = 400 transitDriverAgent = 114 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$StartLegTrigger" }, { actorTypeToMaxNumberOfMessages { transitDriverAgent = 1 } - markAsStuckAfterMs = 40000 + markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.scheduler.BeamAgentScheduler$KillTrigger" } From d09f658b794613f4efc6434459b595bdde67e92d Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Wed, 18 Oct 2023 10:40:55 -0300 Subject: [PATCH 7/8] Further modifies beamville's stuckfinder config to test CI stuckness. --- test/input/beamville/beam.conf | 61 ---------------------------------- 1 file changed, 61 deletions(-) diff --git a/test/input/beamville/beam.conf b/test/input/beamville/beam.conf index 6b7fd9c9dbe..18813971630 100755 --- a/test/input/beamville/beam.conf +++ b/test/input/beamville/beam.conf @@ -236,67 +236,6 @@ beam.debug.stuckAgentDetection { } markAsStuckAfterMs = 300000 triggerType = "beam.agentsim.agents.InitializeTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 11 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.PersonAgent$ActivityEndTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 1 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.PersonAgent$ActivityStartTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 60 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.PersonAgent$PersonDepartureTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 20 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$AlightVehicleTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 20 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$BoardVehicleTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 80 - rideHailAgent = 400 - transitDriverAgent = 114 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$EndLegTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - population = 80 - rideHailAgent = 400 - transitDriverAgent = 114 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.agents.modalbehaviors.DrivesVehicle$StartLegTrigger" - }, - { - actorTypeToMaxNumberOfMessages { - transitDriverAgent = 1 - } - markAsStuckAfterMs = 300000 - triggerType = "beam.agentsim.scheduler.BeamAgentScheduler$KillTrigger" - } ] } From 81bb4fc2918d0f372555d6240b10d621144208d7 Mon Sep 17 00:00:00 2001 From: Heric Farias Date: Wed, 18 Oct 2023 12:49:35 -0300 Subject: [PATCH 8/8] Adds some code to prevent Beam simulations to start close to simultaneously. Testing showed this could be a source of locking as well. --- src/main/scala/beam/sim/BeamHelper.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/scala/beam/sim/BeamHelper.scala b/src/main/scala/beam/sim/BeamHelper.scala index 8f615757ae2..2c429d3e6ac 100755 --- a/src/main/scala/beam/sim/BeamHelper.scala +++ b/src/main/scala/beam/sim/BeamHelper.scala @@ -694,6 +694,18 @@ trait BeamHelper extends LazyLogging with BeamValidationHelper { outputDir: String, plansMerged: Boolean ): Unit = { + BeamHelper.synchronized { + if ( + BeamHelper.lastSimulationStartTime > 0 && + System.currentTimeMillis() - BeamHelper.lastSimulationStartTime < BeamHelper.simulationStartupWaitMs + ) { + val wait = + BeamHelper.simulationStartupWaitMs - (System.currentTimeMillis() - BeamHelper.lastSimulationStartTime) + logger.error(s"Waiting for $wait ms before starting a new Beam simulation.") + Thread.sleep(wait) + } + BeamHelper.lastSimulationStartTime = System.currentTimeMillis() + } if (!beamScenario.beamConfig.beam.agentsim.fractionOfPlansWithSingleActivity.equals(0d)) { applyFractionOfPlansWithSingleActivity(scenario, beamServices.beamConfig, scenario.getConfig) } @@ -1074,6 +1086,9 @@ trait BeamHelper extends LazyLogging with BeamValidationHelper { object BeamHelper { + var lastSimulationStartTime: Long = -1L + val simulationStartupWaitMs: Int = 5000 + /** * We need to copy the old config values to the first element of rideHail.managers collection. * It helps workaround the typesafe config limitation that one cannot access array elements via paths