-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3790 from LBNL-UCB-STI/inm/ride_hail_transit_fix_…
…3781 Fix: ride hail transit re-enable
- Loading branch information
Showing
42 changed files
with
719 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,204 @@ | ||
package beam.integration | ||
|
||
import beam.sim.BeamHelper | ||
import beam.utils.TestConfigUtils.testConfig | ||
import com.typesafe.config.{Config, ConfigValueFactory} | ||
import org.scalatest.AppendedClues | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpecLike | ||
|
||
/** | ||
* Created by fdariasm on 29/08/2017 | ||
*/ | ||
class ModeChoiceSpec extends AnyWordSpecLike with Matchers with BeamHelper with IntegrationSpecCommon { | ||
|
||
// "Running beam with modeChoiceClass ModeChoiceDriveIfAvailable" must { | ||
// "prefer mode choice car type than other modes" in { | ||
// val theRun = new StartWithCustomConfig( | ||
// baseConfig.withValue(TestConstants.KEY_AGENT_MODAL_BEHAVIORS_MODE_CHOICE_CLASS, ConfigValueFactory.fromAnyRef | ||
// ("ModeChoiceDriveIfAvailable")) | ||
// ) | ||
// val testModeCount = theRun.groupedCount.getOrElse("car", 0) | ||
// val otherModesCount = theRun.groupedCount.getOrElse("ride_hail", 0) + | ||
// theRun.groupedCount.getOrElse("walk_transit", 0) + theRun.groupedCount.getOrElse("drive_transit", 0) + | ||
// theRun.groupedCount.getOrElse("bike", 0) | ||
// testModeCount should be >= otherModesCount | ||
// } | ||
// } | ||
class ModeChoiceSpec | ||
extends AnyWordSpecLike | ||
with Matchers | ||
with BeamHelper | ||
with IntegrationSpecCommon | ||
with AppendedClues { | ||
|
||
def getModesOtherThan(excludedMode: String, simulationModes: Map[String, Int]): Int = { | ||
simulationModes.foldLeft(0) { | ||
case (countOfModes, (mode, _)) if mode == excludedMode => countOfModes | ||
case (countOfModes, (_, count)) => countOfModes + count | ||
} | ||
} | ||
|
||
def getClueText(simulationModes: Map[String, Int]): String = { | ||
val allModesString = simulationModes.map { case (mode, count) => s"$mode:$count" }.mkString(", ") | ||
s", all modes are: $allModesString" | ||
} | ||
|
||
def baseBeamvilleUrbansimConfig: Config = testConfig("test/input/beamville/beam-urbansimv2-modechoicespec.conf") | ||
// .withValue("beam.agentsim.lastIteration", ConfigValueFactory.fromAnyRef("0")) | ||
// .withValue("beam.urbansim.fractionOfModesToClear.allModes", ConfigValueFactory.fromAnyRef("1.0")) | ||
// .withValue("beam.outputs.events.fileOutputFormats", ConfigValueFactory.fromAnyRef("xml")) | ||
// .withValue("beam.agentsim.agents.vehicles.fractionOfInitialVehicleFleet", ConfigValueFactory.fromAnyRef("10.0")) | ||
// .withValue("beam.agentsim.agents.vehicles.fractionOfPeopleWithBicycle", ConfigValueFactory.fromAnyRef("10.0")) | ||
|
||
// these should be as low as possible | ||
val test_mode_multiplier = 2 | ||
val test_mode_transit_multiplier = 20 | ||
|
||
def resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor( | ||
selectedMode: String, | ||
router: String, | ||
highIntercept: Int = 999999 | ||
): Config = { | ||
baseBeamvilleUrbansimConfig | ||
.withValue( | ||
s"beam.agentsim.agents.modalBehaviors.multinomialLogit.params.$selectedMode", | ||
ConfigValueFactory.fromAnyRef(highIntercept) | ||
) | ||
.withValue( | ||
s"beam.routing.carRouter", | ||
ConfigValueFactory.fromAnyRef(router) | ||
) | ||
.resolve() | ||
} | ||
|
||
"Running beam with high intercepts for drive transit" must { | ||
"use drive transit with R5 router" ignore { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("drive_transit_intercept", "R5") | ||
) | ||
|
||
val driveTransitModeCount = theRun.groupedCount.getOrElse("drive_transit", 0) | ||
val theRestModes = getModesOtherThan("drive_transit", theRun.groupedCount) | ||
driveTransitModeCount * test_mode_transit_multiplier should be >= theRestModes withClue getClueText( | ||
theRun.groupedCount | ||
) | ||
} | ||
|
||
"use drive transit with GH router" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("drive_transit_intercept", "staticGH") | ||
) | ||
|
||
val driveTransitModeCount = theRun.groupedCount.getOrElse("drive_transit", 0) | ||
val theRestModes = getModesOtherThan("drive_transit", theRun.groupedCount) | ||
driveTransitModeCount * test_mode_transit_multiplier should be >= theRestModes withClue getClueText( | ||
theRun.groupedCount | ||
) | ||
} | ||
} | ||
|
||
"Running beam with high intercepts for RH transit" must { | ||
"use RH transit with R5 router" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("ride_hail_transit_intercept", "R5") | ||
) | ||
|
||
val RHTransitCount = theRun.groupedCount.getOrElse("ride_hail_transit", 0) | ||
val theRestModes = getModesOtherThan("ride_hail_transit", theRun.groupedCount) | ||
RHTransitCount * test_mode_transit_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
} | ||
|
||
"Running beam with high intercepts for CAV" must { | ||
"use cav with R5 router" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("cav_intercept", "R5") | ||
) | ||
|
||
val cavModeCount = theRun.groupedCount.getOrElse("cav", 0) | ||
val theRestModes = getModesOtherThan("cav", theRun.groupedCount) | ||
cavModeCount * test_mode_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
} | ||
|
||
"Running beam with high intercepts for bike transit" must { | ||
"use bike transit with R5 router" ignore { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("bike_transit_intercept", "R5") | ||
) | ||
|
||
val bikeTransitModeCount = theRun.groupedCount.getOrElse("bike_transit", 0) | ||
val theRestModes = getModesOtherThan("bike_transit", theRun.groupedCount) | ||
bikeTransitModeCount * test_mode_transit_multiplier should be >= theRestModes withClue getClueText( | ||
theRun.groupedCount | ||
) | ||
} | ||
} | ||
|
||
"Running beam with high intercepts for CAR" must { | ||
"prefer mode choice car more than other modes (with ModeChoiceDriveIfAvailable)" in { | ||
val theRun = new StartWithCustomConfig( | ||
baseBeamvilleUrbansimConfig | ||
.withValue( | ||
TestConstants.KEY_AGENT_MODAL_BEHAVIORS_MODE_CHOICE_CLASS, | ||
ConfigValueFactory.fromAnyRef("ModeChoiceDriveIfAvailable") | ||
) | ||
.resolve() | ||
) | ||
|
||
val carModeCount = theRun.groupedCount.getOrElse("car", 0) | ||
val theRestModes = getModesOtherThan("car", theRun.groupedCount) | ||
carModeCount * test_mode_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
|
||
"use car with R5 router" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("car_intercept", "R5") | ||
) | ||
|
||
val carModeCount = theRun.groupedCount.getOrElse("car", 0) | ||
val theRestModes = getModesOtherThan("car", theRun.groupedCount) | ||
carModeCount * test_mode_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
} | ||
|
||
"Running beam with specified intercept" must { | ||
"prefer mode choice bike more than other modes" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("bike_intercept", "R5") | ||
) | ||
|
||
val bikeModeCount = theRun.groupedCount.getOrElse("bike", 0) | ||
val theRestModes = getModesOtherThan("bike", theRun.groupedCount) | ||
bikeModeCount * test_mode_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
|
||
"prefer mode choice walk more than other modes" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("walk_intercept", "R5") | ||
) | ||
|
||
val walkModeCount = theRun.groupedCount.getOrElse("walk", 0) | ||
val theRestModes = getModesOtherThan("walk", theRun.groupedCount) | ||
walkModeCount * test_mode_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
|
||
"prefer mode choice RH more than other modes" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("ride_hail_intercept", "R5") | ||
) | ||
|
||
val RHModeCount = theRun.groupedCount.getOrElse("ride_hail", 0) | ||
val theRestModes = getModesOtherThan("ride_hail", theRun.groupedCount) | ||
RHModeCount * test_mode_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
|
||
"prefer mode choice walk transit more than other modes" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("walk_transit_intercept", "R5") | ||
) | ||
|
||
val walkTransitModeCount = theRun.groupedCount.getOrElse("walk_transit", 0) | ||
val theRestModes = getModesOtherThan("walk_transit", theRun.groupedCount) | ||
walkTransitModeCount * test_mode_transit_multiplier should be >= theRestModes withClue getClueText( | ||
theRun.groupedCount | ||
) | ||
} | ||
|
||
"prefer mode choice RH pooled more than other modes" in { | ||
val theRun: StartWithCustomConfig = new StartWithCustomConfig( | ||
resolvedBaseBeamvilleUrbansimConfigWithHighInterceptFor("ride_hail_pooled_intercept", "R5") | ||
) | ||
|
||
val RHPooledCount = theRun.groupedCount.getOrElse("ride_hail_pooled", 0) | ||
val theRestModes = getModesOtherThan("ride_hail_pooled", theRun.groupedCount) | ||
RHPooledCount * test_mode_transit_multiplier should be >= theRestModes withClue getClueText(theRun.groupedCount) | ||
} | ||
} | ||
} |
Oops, something went wrong.