Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
reformatting; add a (design) comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kainagel committed Mar 25, 2024
1 parent 12fa85d commit 5d8f96a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,41 +80,30 @@ public void install() {
}
});

// @formatter:off
controler.addOverridingModule(
new AbstractModule() {
@Override
public void install() {
final EventBasedCarrierScorer_MultipleChains carrierScorer =
new EventBasedCarrierScorer_MultipleChains();
final EventBasedCarrierScorer_MultipleChains carrierScorer = new EventBasedCarrierScorer_MultipleChains();
bind(CarrierScoringFunctionFactory.class).toInstance(carrierScorer);
bind(LSPScorerFactory.class).toInstance(MyLSPScorer::new);
bind(CarrierStrategyManager.class)
.toProvider(
() -> {
CarrierStrategyManager strategyManager =
CarrierControlerUtils.createDefaultCarrierStrategyManager();
strategyManager.addStrategy(
new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1);
bind(CarrierStrategyManager.class).toProvider( () -> {
CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager();
strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1);
return strategyManager;
});
bind(LSPStrategyManager.class)
.toProvider(
() -> {
bind(LSPStrategyManager.class).toProvider( () -> {
LSPStrategyManager strategyManager = new LSPStrategyManagerImpl();
strategyManager.addStrategy(
new GenericPlanStrategyImpl<>(
new ExpBetaPlanSelector<>(new ScoringConfigGroup())),
null,
1);
strategyManager.addStrategy(
ProximityStrategyFactory.createStrategy(scenario.getNetwork()), null, 1);
strategyManager.addStrategy( new GenericPlanStrategyImpl<>( new ExpBetaPlanSelector<>(new ScoringConfigGroup())), null, 1);
strategyManager.addStrategy( ProximityStrategyFactory.createStrategy(scenario.getNetwork()), null, 1);
strategyManager.setMaxPlansPerAgent(5);
strategyManager.setPlanSelectorForRemoval(
new LSPWorstPlanForRemovalSelector());
strategyManager.setPlanSelectorForRemoval( new LSPWorstPlanForRemovalSelector());
return strategyManager;
});
}
});
// @formatter:on

log.info("Run MATSim");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@

final class ProximityStrategyFactory {

// yyyy This factory class contains a long anonymous class. It seems that it should be the other way round: The anonymous class should be a proper
// class, and the factory method (or maybe just normal constructor) should be contained in the class. At some point, try to exchange. kmt & kai, mar'24

// @formatter:off

private ProximityStrategyFactory() {} // class contains only static methods; do not instantiate

static GenericPlanStrategy<LSPPlan, LSP> createStrategy(Network network) {

GenericPlanStrategyImpl<LSPPlan, LSP> strategy =
new GenericPlanStrategyImpl<>(new ExpBetaPlanSelector<>(new ScoringConfigGroup()));
GenericPlanStrategyModule<LSPPlan> randomModule =
new GenericPlanStrategyModule<>() {
GenericPlanStrategyImpl<LSPPlan, LSP> strategy = new GenericPlanStrategyImpl<>(new ExpBetaPlanSelector<>(new ScoringConfigGroup()));
GenericPlanStrategyModule<LSPPlan> randomModule = new GenericPlanStrategyModule<>() {

@Override
public void prepareReplanning(ReplanningContext replanningContext) {}
Expand Down

0 comments on commit 5d8f96a

Please sign in to comment.