From 12be97cbab74499b9cdf61382970841e5712f2ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:58:36 +0000 Subject: [PATCH 1/7] Bump org.matsim:matsim-all from 2025.0-2024w34 to 2025.0-2024w35 Bumps [org.matsim:matsim-all](https://github.com/matsim-org/matsim) from 2025.0-2024w34 to 2025.0-2024w35. - [Release notes](https://github.com/matsim-org/matsim/releases) - [Commits](https://github.com/matsim-org/matsim/commits) --- updated-dependencies: - dependency-name: org.matsim:matsim-all dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 539b2a3f..1a4b4328 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.matsim matsim-all - 2025.0-2024w34 + 2025.0-2024w35 From 62fda4363e1d573fccb2ac0115306e7c0dcbbb64 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 2 Sep 2024 10:54:09 +0200 Subject: [PATCH 2/7] for debugging --- ...leTwoLspsGroceryDeliveryMultipleChainsWithToll.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java index 7b1c9c1e..c9ca9550 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java @@ -103,14 +103,12 @@ public static void main(String[] args) { log.info("Add LSP(s) to the scenario"); Collection lsps = new LinkedList<>(); lsps.add(createLspWithTwoChains(scenario, "Edeka", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierEdeka), getDepotLinkFromVehicle(carrierEdeka), HUB_LINK_ID_NEUKOELLN, vehicleTypes, vehicleTypes, vehicleTypes)); - lsps.add(createLspWithTwoChains(scenario, "Kaufland", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierKaufland), getDepotLinkFromVehicle(carrierKaufland), HUB_LINK_ID_NEUKOELLN, vehicleTypes, vehicleTypes, vehicleTypes)); - lsps.add(createLspWithDirectChain(scenario, "Edeka_DIRECT", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierEdeka), getDepotLinkFromVehicle(carrierEdeka), vehicleTypes)); - lsps.add(createLspWithDirectChain(scenario, "Kaufland_DIRECT", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierKaufland), getDepotLinkFromVehicle(carrierKaufland), vehicleTypes)); +// lsps.add(createLspWithTwoChains(scenario, "Kaufland", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierKaufland), getDepotLinkFromVehicle(carrierKaufland), HUB_LINK_ID_NEUKOELLN, vehicleTypes, vehicleTypes, vehicleTypes)); +// lsps.add(createLspWithDirectChain(scenario, "Edeka_DIRECT", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierEdeka), getDepotLinkFromVehicle(carrierEdeka), vehicleTypes)); +// lsps.add(createLspWithDirectChain(scenario, "Kaufland_DIRECT", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierKaufland), getDepotLinkFromVehicle(carrierKaufland), vehicleTypes)); LSPUtils.addLSPs(scenario, new LSPs(lsps)); - - log.info("Prepare controler"); Controler controler = new Controler(scenario); controler.addOverridingModule( @@ -217,7 +215,7 @@ private static Config prepareConfig(String[] args) { ConfigUtils.applyCommandline(config, args); } else { config.controller().setOutputDirectory(OUTPUT_DIRECTORY); - config.controller().setLastIteration(1); + config.controller().setLastIteration(0); } config.network().setInputFile( From f098eb9e969e334b63405d94a8d5032308611acf Mon Sep 17 00:00:00 2001 From: Kai Nagel Date: Mon, 2 Sep 2024 12:05:03 +0200 Subject: [PATCH 3/7] pass money and additionalScore events through to carrierScoringFunction --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1a4b4328..a1e4d0f8 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,8 @@ org.matsim matsim-all - 2025.0-2024w35 - + + 2025.0-SNAPSHOT From 44e3f8d24571fbfd5fc1d1a6f3aaf8e1101409ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 10:18:55 +0000 Subject: [PATCH 4/7] Bump org.matsim:matsim-all from 2025.0-2024w35 to 2025.0-2024w36 Bumps [org.matsim:matsim-all](https://github.com/matsim-org/matsim) from 2025.0-2024w35 to 2025.0-2024w36. - [Release notes](https://github.com/matsim-org/matsim/releases) - [Commits](https://github.com/matsim-org/matsim/commits) --- updated-dependencies: - dependency-name: org.matsim:matsim-all dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1a4b4328..bd6f2ef0 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.matsim matsim-all - 2025.0-2024w35 + 2025.0-2024w36 From c60206d4e6623236c79cc863cc64ab75873490f9 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 2 Sep 2024 16:36:09 +0200 Subject: [PATCH 5/7] avoid null pointers --- ...dCarrierScorer4MultipleChainsInclToll.java | 116 +++++++++--------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java index 3b3c3712..ec5d9fab 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java @@ -43,6 +43,7 @@ import org.matsim.freight.carriers.events.CarrierTourStartEvent; import org.matsim.freight.logistics.analysis.Driver2VehicleEventHandler; import org.matsim.freight.logistics.analysis.Vehicle2CarrierEventHandler; +import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; @@ -60,8 +61,8 @@ public ScoringFunction createScoringFunction(Carrier carrier) { this.carrierId = carrier.getId(); SumScoringFunction sf = new SumScoringFunction(); sf.addScoringFunction(new EventBasedScoring()); - sf.addScoringFunction(new FindOtherEventsForDebuggingOnly_NO_Scoring()); - sf.addScoringFunction(new TollMoneyScoringForDebuggingOnly_NO_Scoring()); +// sf.addScoringFunction(new FindOtherEventsForDebuggingOnly_NO_Scoring()); +// sf.addScoringFunction(new TollMoneyScoringForDebuggingOnly_NO_Scoring()); return sf; } @@ -147,85 +148,90 @@ private void handleEvent(PersonMoneyEvent event) { double tollValue = 0; if (event.getPurpose().equals("toll")) { - if (carrierId.equals(v2c.getCarrierOfVehicle(d2v.getVehicleOfDriver(event.getPersonId())))) { + Id vehicleId = d2v.getVehicleOfDriver(event.getPersonId()); + if (vehicleId != null) { + Id carrierIdOfVehicle = v2c.getCarrierOfVehicle(vehicleId); + if (carrierId.equals(carrierIdOfVehicle)) { // toll a person only once. - if (!tolledPersons.contains(event.getPersonId())) { - log.info("Tolling caused by event: {}", event); - tolledPersons.add(event.getPersonId()); - tollValue = event.getAmount(); + if (!tolledPersons.contains(event.getPersonId())) { + log.info("Tolling caused by event: {}", event); + tolledPersons.add(event.getPersonId()); + tollValue = event.getAmount(); + } } + score = score - tollValue; } } - score = score - tollValue; } + } - /** - * Versuche nur mit dem Debugger die PersonMoneyEvents zu entdecken, die eigentlich da sein sollten. - */ - private class FindOtherEventsForDebuggingOnly_NO_Scoring implements ArbitraryEventScoring { +/** + * Versuche nur mit dem Debugger die PersonMoneyEvents zu entdecken, die eigentlich da sein sollten. + */ +private class FindOtherEventsForDebuggingOnly_NO_Scoring implements ArbitraryEventScoring { - final Logger log = LogManager.getLogger(FindOtherEventsForDebuggingOnly_NO_Scoring.class); + final Logger log = LogManager.getLogger(FindOtherEventsForDebuggingOnly_NO_Scoring.class); - public FindOtherEventsForDebuggingOnly_NO_Scoring() { - super(); - } + public FindOtherEventsForDebuggingOnly_NO_Scoring() { + super(); + } - @Override - public void finish() {} + @Override + public void finish() {} - @Override - public double getScore() { - return Double.MIN_VALUE; - } + @Override + public double getScore() { + return Double.MIN_VALUE; + } - @Override - public void handleEvent(Event event) { - log.debug(event.toString()); + @Override + public void handleEvent(Event event) { + log.debug(event.toString()); - switch (event) { - case CarrierTourStartEvent carrierTourStartEvent -> {} + switch (event) { + case CarrierTourStartEvent carrierTourStartEvent -> {} // case CarrierTourEndEvent carrierTourEndEvent -> {} - case CarrierServiceStartEvent carrierServiceStartEvent -> {} - case CarrierServiceEndEvent carrierServiceEndEvent -> {} - case LinkEnterEvent linkEnterEvent ->{} - case LinkLeaveEvent linkLeaveEvent ->{} + case CarrierServiceStartEvent carrierServiceStartEvent -> {} + case CarrierServiceEndEvent carrierServiceEndEvent -> {} + case LinkEnterEvent linkEnterEvent ->{} + case LinkLeaveEvent linkLeaveEvent ->{} // case PersonMoneyEvent personMoneyEvent -> handleEvent(personMoneyEvent); - default -> {handleOtherEvent(event);} - } - } - - private void handleOtherEvent(Event event) { - log.info("Found another event: {}", event.toString()); + default -> {handleOtherEvent(event);} } + } + private void handleOtherEvent(Event event) { + log.info("Found another event: {}", event.toString()); } +} - /** - * Versuche nur mit dem Debugger die Einträge aus den PersonMoneyEvents zu entdecken, die eigentlich da sein sollten. - */ - private static class TollMoneyScoringForDebuggingOnly_NO_Scoring implements SumScoringFunction.MoneyScoring, PersonMoneyEventHandler { - private double score = 0.0; - @Override - public void addMoney(double amount) { - // TODO Auto-generated method stub - } +/** + * Versuche nur mit dem Debugger die Einträge aus den PersonMoneyEvents zu entdecken, die eigentlich da sein sollten. + */ +private static class TollMoneyScoringForDebuggingOnly_NO_Scoring implements SumScoringFunction.MoneyScoring, PersonMoneyEventHandler { - @Override - public void finish() { } + private double score = 0.0; + @Override + public void addMoney(double amount) { + // TODO Auto-generated method stub + } - @Override - public double getScore() { - return this.score; - } + @Override + public void finish() { } - @Override - public void handleEvent(PersonMoneyEvent event) { + @Override + public double getScore() { + return this.score; + } + + @Override + public void handleEvent(PersonMoneyEvent event) { // Todo: implement - } } +} } From 134c896aa38b29e9f53bcdcdd93682b5ad3be0fb Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 2 Sep 2024 16:46:02 +0200 Subject: [PATCH 6/7] cleanup --- ...dCarrierScorer4MultipleChainsInclToll.java | 77 +------------------ 1 file changed, 1 insertion(+), 76 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java index ec5d9fab..2b95f38f 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.events.*; -import org.matsim.api.core.v01.events.handler.PersonMoneyEventHandler; import org.matsim.api.core.v01.network.Network; import org.matsim.api.core.v01.population.Person; import org.matsim.core.scoring.ScoringFunction; @@ -37,8 +36,6 @@ import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.Tour; import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.events.CarrierServiceEndEvent; -import org.matsim.freight.carriers.events.CarrierServiceStartEvent; import org.matsim.freight.carriers.events.CarrierTourEndEvent; import org.matsim.freight.carriers.events.CarrierTourStartEvent; import org.matsim.freight.logistics.analysis.Driver2VehicleEventHandler; @@ -61,8 +58,6 @@ public ScoringFunction createScoringFunction(Carrier carrier) { this.carrierId = carrier.getId(); SumScoringFunction sf = new SumScoringFunction(); sf.addScoringFunction(new EventBasedScoring()); -// sf.addScoringFunction(new FindOtherEventsForDebuggingOnly_NO_Scoring()); -// sf.addScoringFunction(new TollMoneyScoringForDebuggingOnly_NO_Scoring()); return sf; } @@ -117,8 +112,7 @@ private void handleEvent(CarrierTourStartEvent event) { private void handleEvent(CarrierTourEndEvent event) { v2c.handleEvent(event); // Fix costs for vehicle usage - final VehicleType vehicleType = - (VehicleUtils.findVehicle(event.getVehicleId(), scenario)).getType(); + final VehicleType vehicleType = (VehicleUtils.findVehicle(event.getVehicleId(), scenario)).getType(); double tourDuration = event.getTime() - tourStartTime.get(event.getTourId()); @@ -163,75 +157,6 @@ private void handleEvent(PersonMoneyEvent event) { } } } - - } - -/** - * Versuche nur mit dem Debugger die PersonMoneyEvents zu entdecken, die eigentlich da sein sollten. - */ -private class FindOtherEventsForDebuggingOnly_NO_Scoring implements ArbitraryEventScoring { - - final Logger log = LogManager.getLogger(FindOtherEventsForDebuggingOnly_NO_Scoring.class); - - - public FindOtherEventsForDebuggingOnly_NO_Scoring() { - super(); - } - - @Override - public void finish() {} - - @Override - public double getScore() { - return Double.MIN_VALUE; - } - - @Override - public void handleEvent(Event event) { - log.debug(event.toString()); - - switch (event) { - case CarrierTourStartEvent carrierTourStartEvent -> {} -// case CarrierTourEndEvent carrierTourEndEvent -> {} - case CarrierServiceStartEvent carrierServiceStartEvent -> {} - case CarrierServiceEndEvent carrierServiceEndEvent -> {} - case LinkEnterEvent linkEnterEvent ->{} - case LinkLeaveEvent linkLeaveEvent ->{} -// case PersonMoneyEvent personMoneyEvent -> handleEvent(personMoneyEvent); - default -> {handleOtherEvent(event);} - } - } - - private void handleOtherEvent(Event event) { - log.info("Found another event: {}", event.toString()); } } - - -/** - * Versuche nur mit dem Debugger die Einträge aus den PersonMoneyEvents zu entdecken, die eigentlich da sein sollten. - */ -private static class TollMoneyScoringForDebuggingOnly_NO_Scoring implements SumScoringFunction.MoneyScoring, PersonMoneyEventHandler { - - private double score = 0.0; - @Override - public void addMoney(double amount) { - // TODO Auto-generated method stub - } - - @Override - public void finish() { } - - @Override - public double getScore() { - return this.score; - } - - @Override - public void handleEvent(PersonMoneyEvent event) { - // Todo: implement - } -} - -} From 531763d976075f16c6bd43efb2ca17a56b5494e6 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 2 Sep 2024 16:52:13 +0200 Subject: [PATCH 7/7] use MATSim PR version 3443, with the fix on matsim-libs --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a1e4d0f8..f87cf66f 100644 --- a/pom.xml +++ b/pom.xml @@ -14,9 +14,9 @@ org.matsim matsim-all - + 2025.0-PR3443 - 2025.0-SNAPSHOT +