Skip to content

Commit

Permalink
Hl/#1857 test vehiclesharing repositioning (#1865)
Browse files Browse the repository at this point in the history
* WIP

* walking distance as a parameter

* WIP

* fmt

* bug fix

* merge fix

* merge done

* merge issue + reposition bug solved

* fmt

* resolving conflicts

* fmt

* following @michaz comments

* read vehicle shares from csv file only
  • Loading branch information
haitamlaarabi authored and michaz committed Jun 5, 2019
1 parent 6f7e289 commit 7c66909
Show file tree
Hide file tree
Showing 15 changed files with 515 additions and 282 deletions.
25 changes: 16 additions & 9 deletions src/main/resources/beam-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,33 @@ beam.agentsim.agents.vehicles.sharedFleets = [
managerType = "fixed-non-reserving"
#@optional
fixed-non-reserving {
vehicleTypeId = "sharedCar"
vehicleTypeId = "String | sharedCar",
maxWalkingDistance = "int | 500"
}
#@optional
inexhaustible-reserving {
vehicleTypeId = "sharedCar"
}

#@optional
fixed-non-reserving-fleet-from-file {
filePathCSV = ""
vehicleTypeId = "sharedCar"
fixed-non-reserving-fleet-by-taz {
vehicleTypeId = "String | sharedCar",
vehiclesSharePerTAZFromCSV = "String? |",
maxWalkingDistance = "int | 500",
fleetSize = "int | 10"
}

#@optional
fixed-non-reserving-randomly-distributed {
fleetSize = "int | 10"
vehicleTypeId = "sharedCar"
reposition {
name = "my-reposition-algorithm"
repositionTimeBin = "int | 3600",
statTimeBin = "int | 300",
#@optional
min-availability-undersupply-algorithm {
matchLimit = "int | 99999"
}
}
}
]

beam.agentsim.agents.population.useVehicleSampling = "boolean | false"

beam.exchange.scenario {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ object AlonsoMoraPoolingAlgForRideHail {
BeamVehicleType.defaultCarBeamVehicleType.id
)
.time
.toInt
CustomerRequest(
vehiclePersonId,
MobilityRequest(
Expand Down
13 changes: 13 additions & 0 deletions src/main/scala/beam/agentsim/infrastructure/taz/TAZTreeMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,17 @@ object TAZTreeMap {
}
res
}

def randomLocationInTAZ(
taz: TAZ,
rand: scala.util.Random = new scala.util.Random(System.currentTimeMillis())
): Coord = {
val radius = Math.sqrt(taz.areaInSquareMeters / Math.PI) / 2
val a = 2 * Math.PI * rand.nextDouble()
val r = radius * Math.sqrt(rand.nextDouble())
val x = r * Math.cos(a)
val y = r * Math.sin(a)
new Coord(taz.coord.getX + x, taz.coord.getY + y)
}

}
1 change: 1 addition & 0 deletions src/main/scala/beam/router/BeamSkimmer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class BeamSkimmer @Inject()(val beamConfig: BeamConfig, val beamServices: BeamSe
skims = new TrieMap()
previousSkimsPlus = skimsPlus
skimsPlus = new TrieMap()
trackSkimsPlusTS = -1
}

def getExcerptData(
Expand Down
110 changes: 72 additions & 38 deletions src/main/scala/beam/sim/config/BeamConfig.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated by tscfg 0.9.4 on Fri May 31 13:32:06 BST 2019
// generated by tscfg 0.9.4 on Tue Jun 04 11:44:52 PDT 2019
// source: src/main/resources/beam-template.conf

package beam.sim.config
Expand Down Expand Up @@ -979,21 +979,20 @@ object BeamConfig {
fixed_non_reserving: scala.Option[
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReserving
],
fixed_non_reserving_fleet_from_file: scala.Option[
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingFleetFromFile
],
fixed_non_reserving_randomly_distributed: scala.Option[
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingRandomlyDistributed
fixed_non_reserving_fleet_by_taz: scala.Option[
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingFleetByTaz
],
inexhaustible_reserving: scala.Option[
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.InexhaustibleReserving
],
managerType: java.lang.String,
name: java.lang.String
name: java.lang.String,
reposition: scala.Option[BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition]
)

object SharedFleets$Elm {
case class FixedNonReserving(
maxWalkingDistance: scala.Int,
vehicleTypeId: java.lang.String
)

Expand All @@ -1003,56 +1002,92 @@ object BeamConfig {
c: com.typesafe.config.Config
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReserving = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReserving(
maxWalkingDistance =
if (c.hasPathOrNull("maxWalkingDistance")) c.getInt("maxWalkingDistance") else 500,
vehicleTypeId = if (c.hasPathOrNull("vehicleTypeId")) c.getString("vehicleTypeId") else "sharedCar"
)
}
}

case class FixedNonReservingFleetFromFile(
filePathCSV: java.lang.String,
vehicleTypeId: java.lang.String
case class FixedNonReservingFleetByTaz(
fleetSize: scala.Int,
maxWalkingDistance: scala.Int,
vehicleTypeId: java.lang.String,
vehiclesSharePerTAZFromCSV: scala.Option[java.lang.String]
)

object FixedNonReservingFleetFromFile {
object FixedNonReservingFleetByTaz {

def apply(
c: com.typesafe.config.Config
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingFleetFromFile = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingFleetFromFile(
filePathCSV = if (c.hasPathOrNull("filePathCSV")) c.getString("filePathCSV") else "",
vehicleTypeId = if (c.hasPathOrNull("vehicleTypeId")) c.getString("vehicleTypeId") else "sharedCar"
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingFleetByTaz = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingFleetByTaz(
fleetSize = if (c.hasPathOrNull("fleetSize")) c.getInt("fleetSize") else 10,
maxWalkingDistance =
if (c.hasPathOrNull("maxWalkingDistance")) c.getInt("maxWalkingDistance") else 500,
vehicleTypeId = if (c.hasPathOrNull("vehicleTypeId")) c.getString("vehicleTypeId") else "sharedCar",
vehiclesSharePerTAZFromCSV =
if (c.hasPathOrNull("vehiclesSharePerTAZFromCSV")) Some(c.getString("vehiclesSharePerTAZFromCSV"))
else None
)
}
}

case class FixedNonReservingRandomlyDistributed(
fleetSize: scala.Int,
case class InexhaustibleReserving(
vehicleTypeId: java.lang.String
)

object FixedNonReservingRandomlyDistributed {
object InexhaustibleReserving {

def apply(
c: com.typesafe.config.Config
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingRandomlyDistributed = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.FixedNonReservingRandomlyDistributed(
fleetSize = if (c.hasPathOrNull("fleetSize")) c.getInt("fleetSize") else 10,
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.InexhaustibleReserving = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.InexhaustibleReserving(
vehicleTypeId = if (c.hasPathOrNull("vehicleTypeId")) c.getString("vehicleTypeId") else "sharedCar"
)
}
}

case class InexhaustibleReserving(
vehicleTypeId: java.lang.String
case class Reposition(
min_availability_undersupply_algorithm: scala.Option[
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition.MinAvailabilityUndersupplyAlgorithm
],
name: java.lang.String,
repositionTimeBin: scala.Int,
statTimeBin: scala.Int
)

object InexhaustibleReserving {
object Reposition {
case class MinAvailabilityUndersupplyAlgorithm(
matchLimit: scala.Int
)

object MinAvailabilityUndersupplyAlgorithm {

def apply(
c: com.typesafe.config.Config
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition.MinAvailabilityUndersupplyAlgorithm = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition
.MinAvailabilityUndersupplyAlgorithm(
matchLimit = if (c.hasPathOrNull("matchLimit")) c.getInt("matchLimit") else 99999
)
}
}

def apply(
c: com.typesafe.config.Config
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.InexhaustibleReserving = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.InexhaustibleReserving(
vehicleTypeId = if (c.hasPathOrNull("vehicleTypeId")) c.getString("vehicleTypeId") else "sharedCar"
): BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition = {
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition(
min_availability_undersupply_algorithm =
if (c.hasPathOrNull("min-availability-undersupply-algorithm"))
scala.Some(
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition
.MinAvailabilityUndersupplyAlgorithm(c.getConfig("min-availability-undersupply-algorithm"))
)
else None,
name = if (c.hasPathOrNull("name")) c.getString("name") else "my-reposition-algorithm",
repositionTimeBin = if (c.hasPathOrNull("repositionTimeBin")) c.getInt("repositionTimeBin") else 3600,
statTimeBin = if (c.hasPathOrNull("statTimeBin")) c.getInt("statTimeBin") else 300
)
}
}
Expand All @@ -1066,18 +1101,11 @@ object BeamConfig {
.FixedNonReserving(c.getConfig("fixed-non-reserving"))
)
else None,
fixed_non_reserving_fleet_from_file =
if (c.hasPathOrNull("fixed-non-reserving-fleet-from-file"))
scala.Some(
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm
.FixedNonReservingFleetFromFile(c.getConfig("fixed-non-reserving-fleet-from-file"))
)
else None,
fixed_non_reserving_randomly_distributed =
if (c.hasPathOrNull("fixed-non-reserving-randomly-distributed"))
fixed_non_reserving_fleet_by_taz =
if (c.hasPathOrNull("fixed-non-reserving-fleet-by-taz"))
scala.Some(
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm
.FixedNonReservingRandomlyDistributed(c.getConfig("fixed-non-reserving-randomly-distributed"))
.FixedNonReservingFleetByTaz(c.getConfig("fixed-non-reserving-fleet-by-taz"))
)
else None,
inexhaustible_reserving =
Expand All @@ -1088,7 +1116,13 @@ object BeamConfig {
)
else None,
managerType = if (c.hasPathOrNull("managerType")) c.getString("managerType") else "fixed-non-reserving",
name = if (c.hasPathOrNull("name")) c.getString("name") else "my-fixed-non-reserving-fleet"
name = if (c.hasPathOrNull("name")) c.getString("name") else "my-fixed-non-reserving-fleet",
reposition =
if (c.hasPathOrNull("reposition"))
scala.Some(
BeamConfig.Beam.Agentsim.Agents.Vehicles.SharedFleets$Elm.Reposition(c.getConfig("reposition"))
)
else None
)
}
}
Expand Down
Loading

0 comments on commit 7c66909

Please sign in to comment.