Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed not writing rideHailInitialLocation files #3821

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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