Skip to content

Commit

Permalink
Merge pull request #3821 from LBNL-UCB-STI/do/fix-multiple-rhm-file-w…
Browse files Browse the repository at this point in the history
…riting

Fixed not writing rideHailInitialLocation files
  • Loading branch information
dimaopen authored Feb 7, 2024
2 parents b77bdf0 + 3d0a248 commit e3dd8f3
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions src/main/scala/beam/agentsim/agents/ridehail/RideHailManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import scala.collection.mutable
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.duration._
import scala.util.Random
import scala.util.{Random, Try}

object RideHailManager {
val INITIAL_RIDE_HAIL_LOCATION_HOME = "HOME"
Expand Down Expand Up @@ -416,34 +416,44 @@ class RideHailManager(
writeMetric("beam-run-RH-non-ev-cav", cntnEVCAV)
writeMetric("beam-run-RH-non-ev-non-cav", cntnEVnCAV)

private val rideHailResourceAllocationManager = RideHailResourceAllocationManager(
managerConfig.allocationManager.name,
this
)

private val rideHailBeamVehicleIdToShiftsOpt = mutable.Map.empty[Id[BeamVehicle], Option[List[Shift]]]

val numRideHailAgents: Int = initializeRideHailFleet()

if (
beamServices.matsimServices != null &&
new File(
beamServices.matsimServices.getControlerIO.getIterationPath(beamServices.matsimServices.getIterationNumber)
).exists()
) {
rideHailinitialLocationSpatialPlot.writeCSV(
beamServices.matsimServices.getControlerIO
.getIterationFilename(beamServices.matsimServices.getIterationNumber, fileBaseName + ".csv")
)

if (beamServices.beamConfig.beam.outputs.writeGraphs) {
rideHailinitialLocationSpatialPlot.writeImage(
Try(
rideHailinitialLocationSpatialPlot.writeCSV(
beamServices.matsimServices.getControlerIO
.getIterationFilename(beamServices.matsimServices.getIterationNumber, fileBaseName + ".png")
.getIterationFilename(
beamServices.matsimServices.getIterationNumber,
s"$fileBaseName-${managerConfig.name}.csv"
)
)
).recover { case exception => log.error(exception, s"Cannot write $fileBaseName-${managerConfig.name}.csv") }

if (beamServices.beamConfig.beam.outputs.writeGraphs) {
Try(
rideHailinitialLocationSpatialPlot.writeImage(
beamServices.matsimServices.getControlerIO
.getIterationFilename(
beamServices.matsimServices.getIterationNumber,
s"$fileBaseName-${managerConfig.name}.png"
)
)
).recover { case exception => log.error(exception, s"Cannot write $fileBaseName-${managerConfig.name}.png") }
}
}

private val rideHailResourceAllocationManager = RideHailResourceAllocationManager(
managerConfig.allocationManager.name,
this
)

private val rideHailBeamVehicleIdToShiftsOpt = mutable.Map.empty[Id[BeamVehicle], Option[List[Shift]]]

val numRideHailAgents: Int = initializeRideHailFleet()

var requestedRideHail: Int = 0
var servedRideHail: Int = 0

Expand Down

0 comments on commit e3dd8f3

Please sign in to comment.