Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HL/#2115-boost-pooling-runtime' …
Browse files Browse the repository at this point in the history
…into production-sfbay-develop-pooling
  • Loading branch information
haitamlaarabi committed Aug 24, 2019
2 parents 4aed807 + f5b6618 commit f2676f1
Show file tree
Hide file tree
Showing 3 changed files with 2,021 additions and 1,107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,11 @@ object AlonsoMoraPoolingAlgForRideHail {
def getRequestWithCurrentVehiclePosition: MobilityRequest = schedule.find(_.tag == EnRoute).getOrElse(schedule.head)
}
// Trip that can be satisfied by one or more ride hail vehicle
case class RideHailTrip(requests: List[CustomerRequest], schedule: List[MobilityRequest], vehicle: Option[VehicleAndSchedule])
extends DefaultEdge
case class RideHailTrip(
requests: List[CustomerRequest],
schedule: List[MobilityRequest],
vehicle: Option[VehicleAndSchedule]
) extends DefaultEdge
with RTVGraphNode {
override def getId: String = requests.foldLeft(s"trip:") { case (c, x) => c + s"$x -> " }
val sumOfDelays: Int = schedule.foldLeft(0) { case (c, r) => c + (r.serviceTime - r.baselineNonPooledTime) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AsyncAlonsoMoraAlgForRideHail(
skimmer: BeamSkimmer
) {

//case class AlternativeOptionsScore(personId: Id[Person], score: Double)
var alternativeOptionsScore = immutable.HashMap.empty[Id[Person], Double]

private def matchVehicleRequests(v: VehicleAndSchedule): (List[RTVGraphNode], List[(RTVGraphNode, RTVGraphNode)]) = {
Expand Down Expand Up @@ -55,7 +54,14 @@ class AsyncAlonsoMoraAlgForRideHail(
spatialDemand.getDisk(center.getX, center.getY, searchRadius).asScala.toList
}
requests
.filter(x => !alternativeOptionsScore.filter(_._2 > beamServices.beamConfig.beam.agentsim.agents.rideHail.allocationManager.alonsoMora.ratioOfSolutionSpaceToRequest).exists(_._1 == x.person.personId))
.filter(
x =>
!alternativeOptionsScore
.filter(
_._2 > beamServices.beamConfig.beam.agentsim.agents.rideHail.allocationManager.alonsoMora.ratioOfSolutionSpaceToRequest
)
.exists(_._1 == x.person.personId)
)
.sortBy(x => GeoUtils.minkowskiDistFormula(center, x.pickup.activity.getCoord))
.take(solutionSpaceSizePerVehicle) foreach (
r =>
Expand Down Expand Up @@ -103,16 +109,14 @@ class AsyncAlonsoMoraAlgForRideHail(
finalRequestsList.appendAll(kRequestsList)
}
val personChecked = mutable.IndexedSeq.empty[Id[Person]]
finalRequestsList.sortBy(- _.schedule.size).foreach {
alternative =>
val score = alternative.requests.size/alternative.vehicle.get.getFreeSeats
alternative.requests.foreach {
request =>
if(!personChecked.contains(request.person.personId)) {
val prevScore = alternativeOptionsScore.getOrElse(request.person.personId, 0.0)
alternativeOptionsScore = alternativeOptionsScore + (request.person.personId -> (prevScore + score))
}
finalRequestsList.sortBy(-_.schedule.size).foreach { alternative =>
val score = alternative.requests.size / alternative.vehicle.get.getFreeSeats
alternative.requests.foreach { request =>
if (!personChecked.contains(request.person.personId)) {
val prevScore = alternativeOptionsScore.getOrElse(request.person.personId, 0.0)
alternativeOptionsScore = alternativeOptionsScore + (request.person.personId -> (prevScore + score))
}
}
}
}
(vertices.toList, edges.toList)
Expand Down
Loading

0 comments on commit f2676f1

Please sign in to comment.