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

Hl/#1654 H3 Skimmer + Simple relocation algorithm for veh sharing #2264

Merged
merged 41 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f8e7368
WIP
haitamlaarabi Jun 28, 2019
f14ce36
WIP
haitamlaarabi Jun 29, 2019
4b2c0bc
WIP
haitamlaarabi Jul 3, 2019
3f9f052
first prototype works fine for now
haitamlaarabi Jul 3, 2019
e7fab93
fmt
haitamlaarabi Jul 3, 2019
6b51266
move Event class into compagnion
haitamlaarabi Jul 3, 2019
0980eaa
typo
haitamlaarabi Jul 3, 2019
7850e27
backing off from abstraction
haitamlaarabi Jul 12, 2019
47276b9
changes
haitamlaarabi Aug 10, 2019
fc7e5ce
update
haitamlaarabi Oct 25, 2019
f5130ae
fix merge
haitamlaarabi Oct 25, 2019
80b8a1f
fix
haitamlaarabi Oct 25, 2019
c265942
removing abstraction
haitamlaarabi Oct 26, 2019
aed3402
fix carshare repositiong test fail
haitamlaarabi Oct 31, 2019
b09c23f
refractoring beamskimmer WIP
haitamlaarabi Nov 2, 2019
7ae9be8
design issue WIP
haitamlaarabi Nov 2, 2019
0c7eb1c
read only skim
haitamlaarabi Nov 2, 2019
571938f
Skimmer & ODSkimmer operational but still WIP
haitamlaarabi Nov 5, 2019
e47e372
fmt
haitamlaarabi Nov 5, 2019
9d498dd
beamconfig merge
haitamlaarabi Nov 5, 2019
f73e617
fix
haitamlaarabi Nov 5, 2019
8149372
WIP
haitamlaarabi Nov 8, 2019
9204df4
WIP
haitamlaarabi Nov 13, 2019
a6204ac
fmt
haitamlaarabi Nov 13, 2019
762822c
Skimmer restructured
haitamlaarabi Nov 14, 2019
2e374ab
bug fixed
haitamlaarabi Nov 15, 2019
0f2ba60
Merge remote-tracking branch 'origin/develop' into HL/#1654-beam-h3-bis
haitamlaarabi Nov 15, 2019
edff0fc
fix default configuration for skimmer
haitamlaarabi Nov 18, 2019
e3a11ae
fmt
haitamlaarabi Nov 19, 2019
7b7bd26
WIP
haitamlaarabi Nov 23, 2019
29640f6
tests are passing now
haitamlaarabi Nov 26, 2019
4841103
fixes after JustinPihony comments
haitamlaarabi Nov 26, 2019
6a25765
Merge remote-tracking branch 'origin/develop' into HL/#1654-beam-h3-bis
haitamlaarabi Nov 26, 2019
5ee8cd8
I have just finished refractoring both BeamSkimmer & TravelTimeObserved
haitamlaarabi Nov 27, 2019
6d330b6
renaming CountSkimmer to TAZSkimmer and TravelTimeSkimmer to DriveTim…
haitamlaarabi Nov 28, 2019
68b4b52
fix test
haitamlaarabi Nov 28, 2019
dc75e17
fmt
haitamlaarabi Nov 28, 2019
a115128
roll back
haitamlaarabi Nov 28, 2019
2245558
Fixed the test by expecting new messages like `ODSkimmerEvent` and `D…
REASY Nov 28, 2019
ad2f4c9
spec passing locally
haitamlaarabi Dec 2, 2019
2580294
Merge branch 'develop' into HL/#1654-beam-h3-bis
haitamlaarabi Jan 6, 2020
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ dependencies {

compile "com.sigopt:sigopt-java:4.9.0"

compile("com.uber:h3:3.4.1")

testCompile group: 'junit', name: 'junit', version: '4.8'
testCompile group: 'org.mockito', name: 'mockito-inline', version: '2.27.0'
testCompile group: "org.mockito", name: "mockito-core", version: "2.+"
Expand Down
33 changes: 26 additions & 7 deletions src/main/resources/beam-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ beam.agentsim.agents.rideHail.allocationManager.repositionLowWaitingTimes.waitin
beam.agentsim.agents.rideHail.allocationManager.repositionLowWaitingTimes.demandWeight = "double | 4.0"
beam.agentsim.agents.rideHail.allocationManager.repositionLowWaitingTimes.produceDebugImages = true
beam.agentsim.agents.rideHail.allocationManager.alonsoMora.waitingTimeInSec = "int | 360"
beam.agentsim.agents.rideHail.allocationManager.alonsoMora.travelTimeDelayAsFraction= "double | 0.2"
beam.agentsim.agents.rideHail.allocationManager.alonsoMora.solutionSpaceSizePerVehicle = "int | 5"
beam.agentsim.agents.rideHail.allocationManager.alonsoMora.excessRideTimeAsFraction= "double | 0.2"
beam.agentsim.agents.rideHail.allocationManager.alonsoMora.numRequestsPerVehicle = "int | 5"
beam.agentsim.agents.rideHail.pooledToRegularRideCostRatio = 0.6

# human value of time taken from # https://theicct.org/sites/default/files/publications/Electric_shared_mobility_20190114.pdf
Expand Down Expand Up @@ -286,11 +286,30 @@ beam.replanning.ModuleProbability_4 = 0.0
beam.replanning.fractionOfIterationsToDisableInnovation = "double | Double.PositiveInfinity"
beam.replanning.cleanNonCarModesInIteration = "int | 0"

#Skimmer
beam.beamskimmer.writeObservedSkimsInterval = "int | 0"
beam.beamskimmer.writeAllModeSkimsForPeakNonPeakPeriodsInterval = "int | 0"
beam.beamskimmer.writeObservedSkimsPlusInterval = "int | 0" # Generic skimmer with a "label" and a "value" of type Double
beam.beamskimmer.writeFullSkimsInterval = "int | 0"
#h3
beam.h3.resolution = "int | 10"
beam.h3.lowerBoundResolution = "int | 10"

#skims
beam.router.skim = {
keepKLatestSkims = "int | 1"
writeSkimsInterval = "int | 0"
writeAggregatedSkimsInterval = "int | 0"
drive-time-skimmer {
name = "drive-time-skimmer"
fileBaseName = "String | skimsTravelTimeObservedVsSimulated"
}
origin-destination-skimmer {
name = "od-skimmer"
fileBaseName = "String | skimsOD"
writeAllModeSkimsForPeakNonPeakPeriodsInterval = "int | 0"
writeFullSkimsInterval = "int | 0"
}
taz-skimmer {
name = "taz-skimmer"
fileBaseName = "String | skimsTAZ"
}
}

##################################################################
# Warm Mode
Expand Down
46 changes: 23 additions & 23 deletions src/main/scala/beam/agentsim/agents/PersonAgent.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package beam.agentsim.agents

import scala.annotation.tailrec
import akka.actor.FSM.Failure
import akka.actor.{ActorRef, FSM, Props, Stash, Status}
import beam.agentsim.Resource._
Expand All @@ -22,17 +21,20 @@ import beam.agentsim.agents.vehicles.VehicleCategory.Bike
import beam.agentsim.agents.vehicles._
import beam.agentsim.events._
import beam.agentsim.events.resources.{ReservationError, ReservationErrorCode}
import beam.agentsim.infrastructure.parking.ParkingMNL
import beam.agentsim.infrastructure.{ParkingInquiryResponse, ParkingStall}
import beam.agentsim.scheduler.BeamAgentScheduler.{CompletionNotice, IllegalTriggerGoToError, ScheduleTrigger}
import beam.agentsim.scheduler.Trigger
import beam.agentsim.scheduler.Trigger.TriggerWithId
import beam.router.Modes.BeamMode
import beam.router.Modes.BeamMode.{CAR, CAV, RIDE_HAIL, RIDE_HAIL_POOLED, RIDE_HAIL_TRANSIT, WALK, WALK_TRANSIT}
import beam.router.RouteHistory
import beam.router.model.{EmbodiedBeamLeg, EmbodiedBeamTrip}
import beam.router.osm.TollCalculator
import beam.router.{BeamSkimmer, RouteHistory, TravelTimeObserved}
import beam.router.skim.{DriveTimeSkimmerEvent, ODSkimmerEvent, ODSkims, Skims}
import beam.sim.population.AttributesOfIndividual
import beam.sim.{BeamScenario, BeamServices, Geofence}
import beam.utils.logging.ExponentialLazyLogging
import com.conveyal.r5.transit.TransportNetwork
import com.vividsolutions.jts.geom.Envelope
import org.matsim.api.core.v01.Id
Expand All @@ -42,9 +44,8 @@ import org.matsim.core.api.experimental.events.{EventsManager, TeleportationArri
import org.matsim.core.utils.misc.Time
import org.matsim.vehicles.Vehicle

import scala.annotation.tailrec
import scala.concurrent.duration._
import beam.agentsim.infrastructure.parking.ParkingMNL
import beam.utils.logging.ExponentialLazyLogging

/**
*/
Expand All @@ -67,9 +68,7 @@ object PersonAgent {
householdRef: ActorRef,
plan: Plan,
sharedVehicleFleets: Seq[ActorRef],
beamSkimmer: BeamSkimmer,
routeHistory: RouteHistory,
travelTimeObserved: TravelTimeObserved,
boundingBox: Envelope
): Props = {
Props(
Expand All @@ -88,9 +87,7 @@ object PersonAgent {
tollCalculator,
householdRef,
sharedVehicleFleets,
beamSkimmer,
routeHistory,
travelTimeObserved,
boundingBox
)
)
Expand Down Expand Up @@ -245,9 +242,7 @@ class PersonAgent(
val tollCalculator: TollCalculator,
val householdRef: ActorRef,
val vehicleFleets: Seq[ActorRef] = Vector(),
val beamSkimmer: BeamSkimmer,
val routeHistory: RouteHistory,
val travelTimeObserved: TravelTimeObserved,
val boundingBox: Envelope
) extends DrivesVehicle[PersonData]
with ChoosesMode
Expand Down Expand Up @@ -344,13 +339,14 @@ class PersonAgent(
.foldLeft(tomorrowFirstLegDistance) { (sum, pair) =>
sum + Math
.ceil(
beamSkimmer
Skims.od_skimmer
.getTimeDistanceAndCost(
pair.head.activity.getCoord,
pair.last.activity.getCoord,
0,
CAR,
currentBeamVehicle.beamVehicleType.id
currentBeamVehicle.beamVehicleType.id,
beamServices
)
.distance
)
Expand Down Expand Up @@ -964,18 +960,22 @@ class PersonAgent(
val generalizedCost = modeChoiceCalculator.getNonTimeCost(correctedTrip) + attributes
.getVOT(generalizedTime)
// Correct the trip to deal with ride hail / disruptions and then register to skimmer
beamSkimmer.observeTrip(
correctedTrip,
generalizedTime,
generalizedCost,
curFuelConsumed.primaryFuel + curFuelConsumed.secondaryFuel
)
travelTimeObserved.observeTrip(
correctedTrip,
generalizedTime,
generalizedCost,
curFuelConsumed.primaryFuel + curFuelConsumed.secondaryFuel
eventsManager.processEvent(
ODSkimmerEvent(
tick,
beamServices,
correctedTrip,
generalizedTime,
generalizedCost,
curFuelConsumed.primaryFuel + curFuelConsumed.secondaryFuel
)
)

correctedTrip.legs.filter(x => x.beamLeg.mode == BeamMode.CAR || x.beamLeg.mode == BeamMode.CAV).foreach {
carLeg =>
eventsManager.processEvent(DriveTimeSkimmerEvent(tick, beamServices, carLeg))
}

resetFuelConsumed()

eventsManager.processEvent(
Expand Down
10 changes: 1 addition & 9 deletions src/main/scala/beam/agentsim/agents/Population.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import beam.agentsim.agents.household.HouseholdActor
import beam.agentsim.agents.vehicles.BeamVehicle
import beam.agentsim.scheduler.BeamAgentScheduler.{CompletionNotice, ScheduleTrigger}
import beam.agentsim.scheduler.Trigger.TriggerWithId
import beam.router.RouteHistory
import beam.router.osm.TollCalculator
import beam.router.{BeamSkimmer, RouteHistory, TravelTimeObserved}
import beam.sim.{BeamScenario, BeamServices}
import com.conveyal.r5.transit.TransportNetwork
import com.vividsolutions.jts.geom.Envelope
Expand All @@ -32,8 +32,6 @@ class Population(
val sharedVehicleFleets: Seq[ActorRef],
val eventsManager: EventsManager,
val routeHistory: RouteHistory,
val beamSkimmer: BeamSkimmer,
val travelTimeObserved: TravelTimeObserved,
boundingBox: Envelope
) extends Actor
with ActorLogging {
Expand Down Expand Up @@ -119,8 +117,6 @@ class Population(
homeCoord,
sharedVehicleFleets,
routeHistory,
beamSkimmer,
travelTimeObserved,
boundingBox
),
household.getId.toString
Expand Down Expand Up @@ -165,8 +161,6 @@ object Population {
sharedVehicleFleets: Seq[ActorRef],
eventsManager: EventsManager,
routeHistory: RouteHistory,
beamSkimmer: BeamSkimmer,
travelTimeObserved: TravelTimeObserved,
boundingBox: Envelope
): Props = {
Props(
Expand All @@ -183,8 +177,6 @@ object Population {
sharedVehicleFleets,
eventsManager,
routeHistory,
beamSkimmer,
travelTimeObserved,
boundingBox
)
)
Expand Down
Loading