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

install the drt zonalsystem module independently of the rebalancing module #3173

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,53 +53,55 @@ public DrtModeZonalSystemModule(DrtConfigGroup drtCfg) {

@Override
public void install() {
DrtZonalSystemParams params = drtCfg.getZonalSystemParams().orElseThrow();

bindModal(DrtZonalSystem.class).toProvider(modalProvider(getter -> {
Network network = getter.getModal(Network.class);
switch (params.zonesGeneration) {
case ShapeFile:
final List<PreparedGeometry> preparedGeometries = loadPreparedGeometries(
if (drtCfg.getZonalSystemParams().isPresent()) {
DrtZonalSystemParams params = drtCfg.getZonalSystemParams().get();

bindModal(DrtZonalSystem.class).toProvider(modalProvider(getter -> {
Network network = getter.getModal(Network.class);
switch (params.zonesGeneration) {
case ShapeFile:
final List<PreparedGeometry> preparedGeometries = loadPreparedGeometries(
ConfigGroup.getInputFileURL(getConfig().getContext(), params.zonesShapeFile));
return DrtZonalSystem.createFromPreparedGeometries(network,
return DrtZonalSystem.createFromPreparedGeometries(network,
EntryStream.of(preparedGeometries).mapKeys(i -> (i + 1) + "").toMap());

case GridFromNetwork:
Preconditions.checkNotNull(params.cellSize);
var gridZones = drtCfg.operationalScheme == OperationalScheme.serviceAreaBased ?
case GridFromNetwork:
Preconditions.checkNotNull(params.cellSize);
var gridZones = drtCfg.operationalScheme == OperationalScheme.serviceAreaBased ?
createGridFromNetworkWithinServiceArea(network, params.cellSize,
loadPreparedGeometries(ConfigGroup.getInputFileURL(getConfig().getContext(),
drtCfg.drtServiceAreaShapeFile))) :
loadPreparedGeometries(ConfigGroup.getInputFileURL(getConfig().getContext(),
drtCfg.drtServiceAreaShapeFile))) :
createGridFromNetwork(network, params.cellSize);
return DrtZonalSystem.createFromPreparedGeometries(network, gridZones);

default:
throw new RuntimeException("Unsupported zone generation");
}
})).asEagerSingleton();

bindModal(DrtZoneTargetLinkSelector.class).toProvider(modalProvider(getter -> {
switch (params.targetLinkSelection) {
case mostCentral:
return new MostCentralDrtZoneTargetLinkSelector(getter.getModal(DrtZonalSystem.class));
case random:
return new RandomDrtZoneTargetLinkSelector();
default:
throw new RuntimeException(
return DrtZonalSystem.createFromPreparedGeometries(network, gridZones);

default:
throw new RuntimeException("Unsupported zone generation");
}
})).asEagerSingleton();

bindModal(DrtZoneTargetLinkSelector.class).toProvider(modalProvider(getter -> {
switch (params.targetLinkSelection) {
case mostCentral:
return new MostCentralDrtZoneTargetLinkSelector(getter.getModal(DrtZonalSystem.class));
case random:
return new RandomDrtZoneTargetLinkSelector();
default:
throw new RuntimeException(
"Unsupported target link selection = " + params.targetLinkSelection);
}
})).asEagerSingleton();
}
})).asEagerSingleton();

//zonal analysis
bindModal(ZonalIdleVehicleXYVisualiser.class).toProvider(modalProvider(
//zonal analysis
bindModal(ZonalIdleVehicleXYVisualiser.class).toProvider(modalProvider(
getter -> new ZonalIdleVehicleXYVisualiser(getter.get(MatsimServices.class), drtCfg.getMode(),
getter.getModal(DrtZonalSystem.class)))).asEagerSingleton();
addControlerListenerBinding().to(modalKey(ZonalIdleVehicleXYVisualiser.class));
addEventHandlerBinding().to(modalKey(ZonalIdleVehicleXYVisualiser.class));
getter.getModal(DrtZonalSystem.class)))).asEagerSingleton();
addControlerListenerBinding().to(modalKey(ZonalIdleVehicleXYVisualiser.class));
addEventHandlerBinding().to(modalKey(ZonalIdleVehicleXYVisualiser.class));

bindModal(DrtZonalWaitTimesAnalyzer.class).toProvider(modalProvider(
bindModal(DrtZonalWaitTimesAnalyzer.class).toProvider(modalProvider(
getter -> new DrtZonalWaitTimesAnalyzer(drtCfg, getter.getModal(DrtEventSequenceCollector.class),
getter.getModal(DrtZonalSystem.class)))).asEagerSingleton();
addControlerListenerBinding().to(modalKey(DrtZonalWaitTimesAnalyzer.class));
getter.getModal(DrtZonalSystem.class)))).asEagerSingleton();
addControlerListenerBinding().to(modalKey(DrtZonalWaitTimesAnalyzer.class));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public RebalancingModule(DrtConfigGroup drtCfg) {
public void install() {
if (drtCfg.getRebalancingParams().isPresent()) {
RebalancingParams rebalancingParams = drtCfg.getRebalancingParams().get();
install(new DrtModeZonalSystemModule(drtCfg));

if (rebalancingParams.getRebalancingStrategyParams() instanceof MinCostFlowRebalancingStrategyParams) {
install(new DrtModeMinCostFlowRebalancingModule(drtCfg));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.inject.name.Names;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.analysis.DrtEventSequenceCollector;
import org.matsim.contrib.drt.analysis.zonal.DrtModeZonalSystemModule;
import org.matsim.contrib.drt.fare.DrtFareHandler;
import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingModule;
import org.matsim.contrib.drt.prebooking.analysis.PrebookingModeAnalysisModule;
Expand Down Expand Up @@ -65,6 +66,7 @@ public void install() {
null :
ConfigGroup.getInputFileURL(getConfig().getContext(), drtCfg.vehiclesFile),
drtCfg.changeStartLinkToLastLinkInSchedule));
install(new DrtModeZonalSystemModule(drtCfg));
install(new RebalancingModule(drtCfg));
install(new DrtModeRoutingModule(drtCfg));

Expand Down
Loading