From fe7bf4be33d5aa7e0ac60b23c3423369582182dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:10:58 +0000 Subject: [PATCH 1/9] Bump org.matsim:matsim-all from 2025.0-2024w42 to 2025.0-2024w46 Bumps [org.matsim:matsim-all](https://github.com/matsim-org/matsim) from 2025.0-2024w42 to 2025.0-2024w46. - [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 80da70fa..49b88cf9 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.matsim matsim-all - 2025.0-2024w42 + 2025.0-2024w46 From 90831d3ca60d10bacab7c442a4529184ced390e2 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 11 Nov 2024 13:03:33 +0100 Subject: [PATCH 2/9] update based on changes in MATSim-libs --- .../ExampleTwoLspsGroceryDeliveryMultipleChains.java | 2 +- .../ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java index e017ce43..fb877baf 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java @@ -217,7 +217,7 @@ public void install() { private static void runCarrierAnalysis(String outputPath, Config config) { RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(outputPath +"/", outputPath +"/Analysis/", config.global().getCoordinateSystem()); try { - freightAnalysis.runAnalysis(); + freightAnalysis.runCompleteAnalysis(); } catch (IOException e) { throw new RuntimeException(e); } 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 e40e8394..78bedf94 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 @@ -244,7 +244,7 @@ private static RoadPricingSchemeUsingTollFactor setUpRoadpricing(Scenario scenar private static void runCarrierAnalysis(String outputPath, Config config) { RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(outputPath +"/", outputPath +"/Analysis/", config.global().getCoordinateSystem()); try { - freightAnalysis.runAnalysis(); + freightAnalysis.runCompleteAnalysis(); } catch (IOException e) { throw new RuntimeException(e); } From 3c091b6d6ef1f70c5b05a52fb0c609a2e6daaf0a Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 12:16:30 +0100 Subject: [PATCH 3/9] add networkMode to vehicleType. Do not use CarrierVehicleType.Builder any more. --- .../ExampleSchedulingOfInitialPlan.java | 18 +++--- .../ExampleSchedulingOfTransportChain.java | 59 +++++++++---------- ...chedulingOfTransportChainHubsVsDirect.java | 12 ++-- .../ExampleMobsimOfSimpleLSP.java | 18 +++--- .../ExampleMobsimOfTransportChain.java | 57 ++++++++---------- .../ExampleCheckRequirementsOfAssigner.java | 23 ++++---- .../ExampleSimulationTrackers.java | 20 ++++--- .../adapterTests/CollectionResourceTest.java | 36 +++++------ .../DistributionResourceTest.java | 33 ++++++----- .../adapterTests/MainRunResourceTest.java | 17 +++--- .../CollectionLSPReplanningTest.java | 19 +++--- .../lspScoring/CollectionLSPScoringTest.java | 4 +- ...pleIterationsCollectionLSPScoringTest.java | 17 +++--- .../AssignerRequirementsTest.java | 20 ++++--- .../CollectionTrackerTest.java | 19 +++--- .../CollectionElementTest.java | 19 +++--- .../DistributionElementTest.java | 17 +++--- .../MainRunElementTest.java | 17 +++--- .../CollectionChainTest.java | 17 +++--- .../CompleteLogisticChainTest.java | 40 ++++++------- .../CollectionLSPCreationTest.java | 17 +++--- .../CompleteLSPCreationTest.java | 52 ++++++++-------- .../CollectionLSPMobsimTest.java | 19 +++--- .../lspMobsimTests/CompleteLSPMobsimTest.java | 53 ++++++++--------- .../FirstAndSecondReloadLSPMobsimTest.java | 36 +++++------ .../FirstReloadLSPMobsimTest.java | 19 +++--- .../lspMobsimTests/MainRunLSPMobsimTest.java | 36 +++++------ .../MainRunOnlyLSPMobsimTest.java | 19 +++--- ...ipleIterationsCollectionLSPMobsimTest.java | 17 +++--- ...ltipleIterationsCompleteLSPMobsimTest.java | 53 ++++++++--------- ...ionsFirstAndSecondReloadLSPMobsimTest.java | 36 +++++------ ...pleIterationsFirstReloadLSPMobsimTest.java | 19 +++--- ...ultipleIterationsMainRunLSPMobsimTest.java | 36 +++++------ ...tipleShipmentsCollectionLSPMobsimTest.java | 19 +++--- ...ultipleShipmentsCompleteLSPMobsimTest.java | 53 ++++++++--------- ...entsFirstAndSecondReloadLSPMobsimTest.java | 36 +++++------ ...ipleShipmentsFirstReloadLSPMobsimTest.java | 19 +++--- ...MultipleShipmentsMainRunLSPMobsimTest.java | 38 ++++++------ ...ultipleShipmentsCompleteLSPMobsimTest.java | 53 ++++++++--------- .../lspPlanTests/CollectionLSPPlanTest.java | 19 +++--- .../lspPlanTests/CompleteLSPPlanTest.java | 51 ++++++++-------- .../CollectionLspShipmentAssigmentTest.java | 19 +++--- .../CompleteLspShipmentAssignerTest.java | 51 ++++++++-------- .../CollectionLSPSchedulingTest.java | 19 +++--- .../CompleteLSPSchedulingTest.java | 53 ++++++++--------- .../FirstReloadLSPSchedulingTest.java | 19 +++--- .../MainRunLSPSchedulingTest.java | 36 +++++------ ...eShipmentsCollectionLSPSchedulingTest.java | 19 +++--- ...pleShipmentsCompleteLSPSchedulingTest.java | 53 ++++++++--------- ...ShipmentsFirstReloadLSPSchedulingTest.java | 19 +++--- ...ipleShipmentsMainRunLSPSchedulingTest.java | 36 +++++------ ...hipmentsSecondReloadLSPSchedulingTest.java | 36 +++++------ .../SecondReloadLSPSchedulingTest.java | 36 +++++------ 53 files changed, 796 insertions(+), 782 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfInitialPlan.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfInitialPlan.java index 0aaa8b0f..8715df32 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfInitialPlan.java +++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfInitialPlan.java @@ -27,6 +27,7 @@ import java.util.Random; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -41,6 +42,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /*package-private*/ class ExampleSchedulingOfInitialPlan { @@ -49,19 +51,17 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for the resource of the sole LogisticsSolutionElement of the LSP is created Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = - CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); CarrierVehicle carrierVehicle = - CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(carrierVehicle) diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChain.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChain.java index 533b3d38..eb01dda6 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChain.java +++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChain.java @@ -27,6 +27,7 @@ import java.util.Random; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -43,6 +44,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /*A transport chain with five elements (collection-> reloading -> main run -> reloading -> delivery) is created and scheduled * @@ -57,19 +59,17 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for collection is created Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = - CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType collectionType = vehicleTypeBuilder.build(); + VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); CarrierVehicle carrierVehicle = - CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); @@ -124,20 +124,20 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for the main run Resource is created Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - final VehicleType mainRunType = - CarrierVehicleType.Builder.newInstance( - Id.create("MainRunCarrierVehicleType", VehicleType.class)) - .setCapacity(30) - .setCostPerDistanceUnit(0.0002) - .setCostPerTimeUnit(0.38) - .setFixCost(120) - .setMaxVelocity(50 / 3.6) - .build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + final VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); + mainRunVehType.setNetworkMode(TransportMode.car); + Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); CarrierVehicle mainRunCarrierVehicle = - CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities mainRunCapabilities = CarrierCapabilities.Builder.newInstance() @@ -190,21 +190,20 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for distribution is created Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = - Id.create("DistributionCarrierVehicleType", VehicleType.class); - VehicleType distributionType = - CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId) - .setCapacity(10) - .setCostPerDistanceUnit(0.0004) - .setCostPerTimeUnit(0.38) - .setFixCost(49) - .setMaxVelocity(50 / 3.6) - .build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + final VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); + distributionVehType.setNetworkMode(TransportMode.car); + Id distributionLinkId = Id.createLinkId("(14 2) (14 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); CarrierVehicle distributionCarrierVehicle = - CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder distributionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java index 6c359b32..392845d6 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java +++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java @@ -240,7 +240,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType Carrier mainRunCarrier = CarriersUtils.createCarrier(Id.create("MainRunCarrier", Carrier.class)); - VehicleType mainRunVehicleType = + VehicleType mainRunVehType = CarrierVehicleType.Builder.newInstance( Id.create("MainRunCarrierVehicleType", VehicleType.class)) .setCapacity(30) @@ -252,7 +252,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.Builder.newInstance( - Id.createVehicleId("MainRunVehicle"), depotLinkId, mainRunVehicleType) + Id.createVehicleId("MainRunVehicle"), depotLinkId, mainRunVehType) .build(); mainRunCarrier.setCarrierCapabilities( @@ -309,12 +309,12 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType LogisticChainElement distributionElement; { // The Carrier for distribution from reloading Point is created - VehicleType distributionVehicleType = + VehicleType distributionVehType = createCarrierVehicleType("DistributionCarrierVehicleType"); CarrierVehicle distributionCarrierVehicle = CarrierVehicle.Builder.newInstance( - Id.createVehicleId("DistributionVehicle"), hubLinkId, distributionVehicleType) + Id.createVehicleId("DistributionVehicle"), hubLinkId, distributionVehType) .build(); Carrier distributionCarrier = @@ -349,14 +349,14 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType LogisticChainElement directDistributionElement; { // The Carrier for distribution from reloading Point is created - VehicleType directDistributionVehicleType = + VehicleType directdistributionVehType = createCarrierVehicleType("DirectDistributionCarrierVehicleType"); CarrierVehicle directDistributionCarrierVehicle = CarrierVehicle.Builder.newInstance( Id.createVehicleId("DirectDistributionVehicle"), depotLinkId, - directDistributionVehicleType) + directdistributionVehType) .build(); CarrierCapabilities directDistributionCarrierCapabilities = diff --git a/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java b/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java index 06daf2db..74a5990c 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java +++ b/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java @@ -27,6 +27,7 @@ import java.util.Random; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -46,6 +47,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /*package-private*/ class ExampleMobsimOfSimpleLSP { @@ -157,19 +159,17 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for the resource of the sole LogisticsSolutionElement of the LSP is created Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = - CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); CarrierVehicle carrierVehicle = - CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(carrierVehicle) diff --git a/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java b/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java index 0e2fc449..1e81d985 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java +++ b/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java @@ -27,6 +27,7 @@ import java.util.Random; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -47,6 +48,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /*package-private*/ class ExampleMobsimOfTransportChain { @@ -57,19 +59,17 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for collection is created Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = - CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType collectionType = vehicleTypeBuilder.build(); + VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); CarrierVehicle carrierVehicle = - CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(carrierVehicle) @@ -124,21 +124,18 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for the main run Resource is created final Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - final Id mainRunVehicleTypeId = - Id.create("MainRunCarrierVehicleType", VehicleType.class); - final VehicleType mainRunType = - CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId) - .setCapacity(30) - .setCostPerDistanceUnit(0.0002) - .setCostPerTimeUnit(0.38) - .setFixCost(120) - .setMaxVelocity(50 / 3.6) - .build(); + final Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + final VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); + mainRunVehType.setNetworkMode(TransportMode.car); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = - CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities mainRunCapabilities = CarrierCapabilities.Builder.newInstance() @@ -192,21 +189,19 @@ private static LSP createInitialLSP(Scenario scenario) { // The Carrier for distribution is created Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = - CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + VehicleType distributionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); CarrierVehicle distributionCarrierVehicle = - CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities distributionCapabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(distributionCarrierVehicle) diff --git a/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/ExampleCheckRequirementsOfAssigner.java b/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/ExampleCheckRequirementsOfAssigner.java index 0274903a..a918de5f 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/ExampleCheckRequirementsOfAssigner.java +++ b/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/ExampleCheckRequirementsOfAssigner.java @@ -48,6 +48,7 @@ import java.util.Random; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -61,6 +62,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; class ExampleCheckRequirementsOfAssigner { @@ -72,20 +74,19 @@ private static LSP createLSPWithProperties(Scenario scenario) { // Create red LogisticsSolution which has the corresponding info final Id redCarrierId = Id.create("RedCarrier", Carrier.class); - final VehicleType collectionType = - CarrierVehicleType.Builder.newInstance( - Id.create("RedCarrierVehicleType", VehicleType.class)) - .setCapacity(10) - .setCostPerDistanceUnit(0.0004) - .setCostPerTimeUnit(0.38) - .setFixCost(49) - .setMaxVelocity(50 / 3.6) - .build(); + final Id collectionVehTypeId = Id.create("RedCarrierVehicleType", VehicleType.class); + final VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); + collectionVehType.setNetworkMode(TransportMode.car); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id redVehicleId = Id.createVehicleId("RedVehicle"); CarrierVehicle redVehicle = - CarrierVehicle.newInstance(redVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(redVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities redCapabilities = CarrierCapabilities.Builder.newInstance() @@ -121,7 +122,7 @@ private static LSP createLSPWithProperties(Scenario scenario) { Id blueCarrierId = Id.create("BlueCarrier", Carrier.class); Id blueVehicleId = Id.createVehicleId("BlueVehicle"); CarrierVehicle blueVehicle = - CarrierVehicle.newInstance(blueVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(blueVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities blueCapabilities = CarrierCapabilities.Builder.newInstance() diff --git a/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java b/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java index 19b38fd0..b58d1315 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java +++ b/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java @@ -25,8 +25,11 @@ import java.util.Collection; import java.util.Collections; import java.util.Random; +import java.util.concurrent.TransferQueue; + import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -43,6 +46,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /*package-private*/ class ExampleSimulationTrackers { @@ -52,19 +56,17 @@ static LSP createLSPWithTracker(Scenario scenario) { // The Carrier for the resource of the sole LogisticsSolutionElement of the LSP is created Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = - CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); CarrierVehicle carrierVehicle = - CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(carrierVehicle) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index f044ca9d..5d1d12ab 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -37,13 +38,13 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionResourceTest { //Die Tracker sind ja erst ein Bestandteil des Scheduling bzw. Replanning und kommen hier noch nicht rein. //Man kann sie deshalb ja extra außerhalb des Builders einsetzen. - - private org.matsim.vehicles.VehicleType collectionType; + private VehicleType collectionVehType; private CarrierVehicle collectionCarrierVehicle; private Carrier collectionCarrier; private LSPCarrierResource carrierResource; @@ -59,18 +60,17 @@ public void initialize() { scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); - collectionCarrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + collectionCarrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -112,18 +112,18 @@ public void testCollectionResource() { assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { - assertSame(types.getFirst(), collectionType); - assertEquals(10, collectionType.getCapacity().getOther().intValue()); - assertEquals(0.0004, collectionType.getCostInformation().getCostsPerMeter(), 0.0); - assertEquals(0.38, collectionType.getCostInformation().getCostsPerSecond(), 0.0); - assertEquals(49, collectionType.getCostInformation().getFixedCosts(), 0.0); - assertEquals((50 / 3.6), collectionType.getMaximumVelocity(), 0.0); + assertSame(types.getFirst(), collectionVehType); + assertEquals(10, collectionVehType.getCapacity().getOther().intValue()); + assertEquals(0.0004, collectionVehType.getCostInformation().getCostsPerMeter(), 0.0); + assertEquals(0.38, collectionVehType.getCostInformation().getCostsPerSecond(), 0.0); + assertEquals(49, collectionVehType.getCostInformation().getFixedCosts(), 0.0); + assertEquals((50 / 3.6), collectionVehType.getMaximumVelocity(), 0.0); } ArrayList vehicles = new ArrayList<>(capabilities.getCarrierVehicles().values()); if (vehicles.size() == 1) { assertSame(vehicles.getFirst(), collectionCarrierVehicle); - assertSame(collectionCarrierVehicle.getType(), collectionType); + assertSame(collectionCarrierVehicle.getType(), collectionVehType); assertSame(collectionCarrierVehicle.getLinkId(), collectionLinkId); } } diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index 4e764d60..a5b2bf9a 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -38,13 +39,14 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.DistributionCarrierResourceBuilder; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class DistributionResourceTest { //Die Tracker sind ja erst ein Bestandteil des Scheduling bzw. Replanning und kommen hier noch nicht rein. //Man kann sie deshalb ja extra außerhalb des Builders einsetzen. - private org.matsim.vehicles.VehicleType distributionType; + private org.matsim.vehicles.VehicleType distributionVehType; private CarrierVehicle distributionCarrierVehicle; private CarrierCapabilities capabilities; private Carrier distributionCarrier; @@ -61,17 +63,16 @@ public void initialize() { Id carrierId = Id.create("DistributionCarrier", Carrier.class); Id vehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - distributionType = vehicleTypeBuilder.build(); + distributionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, this.distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); @@ -113,18 +114,18 @@ public void testCollectionResource() { assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { - assertSame(types.getFirst(), distributionType); - assertEquals(10, distributionType.getCapacity().getOther().intValue()); - assertEquals(0.0004, distributionType.getCostInformation().getCostsPerMeter(), 0.0); - assertEquals(0.38, distributionType.getCostInformation().getCostsPerSecond(), 0.0); - assertEquals(49, distributionType.getCostInformation().getFixedCosts(), 0.0); - assertEquals((50 / 3.6), distributionType.getMaximumVelocity(), 0.0); + assertSame(types.getFirst(), distributionVehType); + assertEquals(10, distributionVehType.getCapacity().getOther().intValue()); + assertEquals(0.0004, distributionVehType.getCostInformation().getCostsPerMeter(), 0.0); + assertEquals(0.38, distributionVehType.getCostInformation().getCostsPerSecond(), 0.0); + assertEquals(49, distributionVehType.getCostInformation().getFixedCosts(), 0.0); + assertEquals((50 / 3.6), distributionVehType.getMaximumVelocity(), 0.0); } ArrayList vehicles = new ArrayList<>(capabilities.getCarrierVehicles().values()); if (vehicles.size() == 1) { assertSame(vehicles.getFirst(), distributionCarrierVehicle); - assertSame(distributionCarrierVehicle.getType(), distributionType); + assertSame(distributionCarrierVehicle.getType(), distributionVehType); assertSame(distributionCarrierVehicle.getLinkId(), distributionLinkId); } } diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index 05cf35e5..24eec24b 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -37,6 +38,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MainRunResourceTest { @@ -59,18 +61,17 @@ public void initialize() { Id carrierId = Id.create("MainRunCarrier", Carrier.class); Id vehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(30); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0008); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(120); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - mainRunType = vehicleTypeBuilder.build(); + mainRunType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + mainRunType.getCapacity().setOther(30); + mainRunType.getCostInformation().setCostsPerMeter(0.0008); + mainRunType.getCostInformation().setCostsPerSecond(0.38); + mainRunType.getCostInformation().setFixedCost(120.); + mainRunType.setMaximumVelocity(50 / 3.6); toLinkId = Id.createLinkId("(14 2) (14 3)"); fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("MainRunVehicle"); - carrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, fromLinkId, mainRunType); + carrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, fromLinkId, this.mainRunType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java index fa77bb1e..c3600d60 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -53,6 +54,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /** * This class is deprecated and will be removed in the future. @@ -89,21 +91,20 @@ public void initialize() { Network network = scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Link collectionLink = network.getLinks().get(collectionLinkId); if (collectionLink == null) { System.exit(1); } - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java index 15180dda..50431487 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java @@ -69,12 +69,12 @@ public void initialize() { Scenario scenario = ScenarioUtils.loadScenario(config); Network network = scenario.getNetwork(); - VehicleType collectionVehicleType = CarrierVehicleType.Builder.newInstance(Id.create("CollectionCarrierVehicleType", VehicleType.class)) + VehicleType collectionVehType = CarrierVehicleType.Builder.newInstance(Id.create("CollectionCarrierVehicleType", VehicleType.class)) .setCapacity(10).setCostPerDistanceUnit(0.0004).setCostPerTimeUnit(0.38).setFixCost(49).setMaxVelocity(50 / 3.6).build(); Link collectionLink = network.getLinks().get(Id.createLinkId("(4 2) (4 3)")); // (make sure that the link exists) - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehicleType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehType); Carrier carrier = CarriersUtils.createCarrier(Id.create("CollectionCarrier", Carrier.class)); carrier.setCarrierCapabilities(CarrierCapabilities.Builder.newInstance() diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java index 7c2b37ab..ee949451 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -52,6 +53,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleIterationsCollectionLSPScoringTest { @@ -77,20 +79,19 @@ public void initialize() { Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Link collectionLink = network.getLinks().get(collectionLinkId); if (collectionLink == null) { System.exit(1); } - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index 7968f1f8..37588adb 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -43,6 +44,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class AssignerRequirementsTest { @@ -60,17 +62,17 @@ public void initialize() { Id redCarrierId = Id.create("RedCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); + collectionVehType.setNetworkMode(TransportMode.car); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id redVehicleId = Id.createVehicleId("RedVehicle"); - CarrierVehicle redVehicle = CarrierVehicle.newInstance(redVehicleId, collectionLinkId, collectionType); + CarrierVehicle redVehicle = CarrierVehicle.newInstance(redVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities redCapabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(redVehicle) @@ -101,7 +103,7 @@ public void initialize() { Id blueCarrierId = Id.create("BlueCarrier", Carrier.class); Id blueVehicleId = Id.createVehicleId("BlueVehicle"); - CarrierVehicle blueVehicle = CarrierVehicle.newInstance(blueVehicleId, collectionLinkId, collectionType); + CarrierVehicle blueVehicle = CarrierVehicle.newInstance(blueVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities blueCapabilities = CarrierCapabilities.Builder.newInstance() .addVehicle(blueVehicle) diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index f55f5a8d..b6695f53 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; import static org.junit.jupiter.api.Assertions.*; @@ -81,19 +83,18 @@ public void initialize() { this.network = scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Link collectionLink = network.getLinks().get(collectionLinkId); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java index 9f425365..40ab28db 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -37,6 +38,7 @@ import org.matsim.freight.logistics.LogisticChainElement; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionElementTest { @@ -53,17 +55,16 @@ public void initialize() { scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java index a816d633..ca387a10 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -39,6 +40,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class DistributionElementTest { @@ -56,17 +58,16 @@ public void initialize() { Id carrierId = Id.create("DistributionCarrier", Carrier.class); Id vehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType distributionType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java index 1e83c360..26694cac 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -38,6 +39,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MainRunElementTest { @@ -55,18 +57,17 @@ public void initialize() { Id carrierId = Id.create("MainRunCarrier", Carrier.class); Id vehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(30); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(120); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, fromLinkId, mainRunType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java index df06fa8f..2d0a981f 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -39,6 +40,7 @@ import org.matsim.freight.logistics.LogisticChainElement; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionChainTest { @@ -54,16 +56,15 @@ public void initialize() { Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java index cea7f72d..6ae4fd07 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -43,6 +44,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TransshipmentHubBuilder; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CompleteLogisticChainTest { @@ -63,19 +65,17 @@ public void initialize() { scenario.getNetwork(); Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder - .newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -114,7 +114,7 @@ public void initialize() { .build(); VehicleType mainRunType = CarrierVehicleType.Builder - .newInstance(collectionVehicleTypeId) + .newInstance(collectionVehTypeId) .setCapacity(30) .setCostPerDistanceUnit(0.0002) .setCostPerTimeUnit(0.38) @@ -162,19 +162,17 @@ public void initialize() { secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = CarrierVehicleType.Builder - .newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java index e7634cf6..7272fa36 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -37,6 +38,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.CollectionCarrierResourceBuilder; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionLSPCreationTest { @@ -55,16 +57,15 @@ public void initialize() { Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java index 32db2031..9b347e50 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -39,6 +40,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TransshipmentHubBuilder; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CompleteLSPCreationTest { private LSP completeLSP; @@ -55,18 +57,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -102,18 +103,17 @@ public void initialize() { firstHubElementBuilder.setResource(firstTranshipmentHubResource); LogisticChainElement firstHubElement = firstHubElementBuilder.build(); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - VehicleType mainRunType = collectionVehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -152,18 +152,18 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - VehicleType distributionType = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId) - .setCapacity(10) - .setCostPerDistanceUnit(0.0004) - .setCostPerTimeUnit(0.38) - .setFixCost(49) - .setMaxVelocity(50/3.6) - .build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); + distributionVehType.setNetworkMode(TransportMode.car); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java index bf98cbda..c97220d0 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java @@ -35,6 +35,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; @@ -55,6 +56,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionLSPMobsimTest { @@ -82,20 +84,19 @@ public void initialize() { Scenario scenario = ScenarioUtils.loadScenario(config); // define vehicle type: - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); // define starting link (?): Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Link collectionLink = scenario.getNetwork().getLinks().get(collectionLinkId); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLink.getId(), collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLink.getId(), collectionVehType); // define carrier: Id carrierId = Id.create("CollectionCarrier", Carrier.class); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java index 7e435277..aff14551 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -50,6 +51,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CompleteLSPMobsimTest { @@ -72,18 +74,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -120,18 +121,17 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); @@ -169,18 +169,17 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(14 2) (14 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java index 79e2751f..de67d122 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class FirstAndSecondReloadLSPMobsimTest { @@ -76,18 +78,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -124,19 +125,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java index 7155658e..f32adf07 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class FirstReloadLSPMobsimTest { @@ -77,18 +79,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java index 9022a2d9..0717249e 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MainRunLSPMobsimTest { @@ -76,18 +78,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -124,18 +125,17 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java index 961f9020..2ddbb434 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -52,6 +53,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MainRunOnlyLSPMobsimTest { @@ -73,19 +75,18 @@ public void initialize() { Network network = scenario.getNetwork(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java index b76d11ca..70386183 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -56,6 +57,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleIterationsCollectionLSPMobsimTest { @@ -80,17 +82,16 @@ public void initialize() { Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Link collectionLink = network.getLinks().get(collectionLinkId); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java index 0e25899e..8c914933 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -59,6 +60,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleIterationsCompleteLSPMobsimTest { @@ -81,18 +83,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -129,19 +130,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -180,18 +180,17 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(14 2) (14 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java index 050dda7d..0741c46e 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -59,6 +60,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleIterationsFirstAndSecondReloadLSPMobsimTest { @@ -82,18 +84,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -130,19 +131,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java index 96e68e1e..30c1ca58 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -58,6 +59,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleIterationsFirstReloadLSPMobsimTest { @@ -81,17 +83,16 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java index 9a25f460..1046eefc 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -59,6 +60,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; @SuppressWarnings("ALL") public class MultipleIterationsMainRunLSPMobsimTest { @@ -82,18 +84,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -130,19 +131,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java index 3a051156..c0a54bf9 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -52,6 +53,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsCollectionLSPMobsimTest { @@ -74,18 +76,17 @@ public void initialize() { Network network = scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType vehicleType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + vehicleType.getCapacity().setOther(10); + vehicleType.getCostInformation().setCostsPerMeter(0.0004); + vehicleType.getCostInformation().setCostsPerSecond(0.38); + vehicleType.getCostInformation().setFixedCost(49.); + vehicleType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Link collectionLink = network.getLinks().get(collectionLinkId); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), vehicleType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java index 1f6257e3..c15ce76c 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -61,6 +62,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsCompleteLSPMobsimTest { @@ -84,18 +86,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -132,19 +133,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -183,18 +183,17 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder distributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - distributionVehicleTypeBuilder.setCapacity(10); - distributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - distributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - distributionVehicleTypeBuilder.setFixCost(49); - distributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType distributionType = distributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(14 2) (14 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java index 352674b7..0cf80a23 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -59,6 +60,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsFirstAndSecondReloadLSPMobsimTest { @@ -81,18 +83,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -129,19 +130,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java index 5d949c0a..c9857e22 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsFirstReloadLSPMobsimTest { @@ -76,18 +78,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java index 4b9c04a2..8c5767d0 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsMainRunLSPMobsimTest { @@ -76,18 +78,18 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); + collectionVehType.setNetworkMode(TransportMode.car); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -124,19 +126,19 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java index a4521fc2..7018f2e6 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class RepeatedMultipleShipmentsCompleteLSPMobsimTest { @@ -76,18 +78,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -124,19 +125,18 @@ public void initialize() { LogisticChainElement firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -175,18 +175,17 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(14 2) (14 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java index ee000e6f..06e9f39b 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -36,6 +37,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.CollectionCarrierResourceBuilder; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionLSPPlanTest { @@ -53,17 +55,16 @@ public void initialize() { scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java index 2d811c99..58f82a24 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; @@ -38,6 +39,7 @@ import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TransshipmentHubBuilder; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CompleteLSPPlanTest { @@ -55,18 +57,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -103,18 +104,17 @@ public void initialize() { firstHubElementBuilder.setResource(firstTransshipmentHubBuilder.build()); LogisticChainElement firstHubElement = firstHubElementBuilder.build(); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = collectionVehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -153,18 +153,17 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java index 36f8e395..c7f62763 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -42,6 +43,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionLspShipmentAssigmentTest { @@ -58,17 +60,16 @@ public void initialize() { Network network = scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java index a3b520d4..5e2348ae 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -44,6 +45,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CompleteLspShipmentAssignerTest { @@ -61,18 +63,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -108,18 +109,17 @@ public void initialize() { firstHubElementBuilder.setResource(firstTranshipmentHubResource); LogisticChainElement firstHubElement = firstHubElementBuilder.build(); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType mainRunType = collectionVehicleTypeBuilder.build(); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -158,18 +158,17 @@ public void initialize() { LogisticChainElement secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder distributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - distributionVehicleTypeBuilder.setCapacity(10); - distributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - distributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - distributionVehicleTypeBuilder.setFixCost(49); - distributionVehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType distributionType = distributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50 / 3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 400ab067..5e071b89 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -43,6 +44,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentPlanElement; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionLSPSchedulingTest { @@ -60,17 +62,16 @@ public void initialize() { Network network = scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50 / 3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index 885a2d4f..43b715df 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -47,6 +48,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CompleteLSPSchedulingTest { @@ -72,18 +74,17 @@ public void initialize() { Network network = scenario.getNetwork(); Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -119,20 +120,19 @@ public void initialize() { firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); toLinkId = Id.createLinkId("(14 2) (14 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -170,18 +170,17 @@ public void initialize() { secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder dsitributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - dsitributionVehicleTypeBuilder.setCapacity(10); - dsitributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - dsitributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - dsitributionVehicleTypeBuilder.setFixCost(49); - dsitributionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType distributionType = dsitributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50/3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 90254732..00a65c68 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -46,6 +47,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class FirstReloadLSPSchedulingTest { private LSP lsp; @@ -64,18 +66,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index de0c1643..a99a92d7 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -46,6 +47,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MainRunLSPSchedulingTest { private LSP lsp; @@ -66,18 +68,17 @@ public void initialize() { Network network = scenario.getNetwork(); Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -112,20 +113,19 @@ public void initialize() { firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); toLinkId = Id.createLinkId("(14 2) (14 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index 173fa089..d30d608f 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -44,6 +45,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsCollectionLSPSchedulingTest { @@ -61,18 +63,17 @@ public void initialize() { Network network = scenario.getNetwork(); Id carrierId = Id.create("CollectionCarrier", Carrier.class); - Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); - vehicleTypeBuilder.setCapacity(10); - vehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - vehicleTypeBuilder.setCostPerTimeUnit(0.38); - vehicleTypeBuilder.setFixCost(49); - vehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = vehicleTypeBuilder.build(); + Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(vehicleTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id vollectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(carrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index 6994d171..5b9d5790 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -47,6 +48,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsCompleteLSPSchedulingTest { @@ -72,18 +74,17 @@ public void initialize() { Network network = scenario.getNetwork(); Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -120,20 +121,19 @@ public void initialize() { firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); toLinkId = Id.createLinkId("(14 2) (14 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); @@ -172,18 +172,17 @@ public void initialize() { secondHubElement = secondHubElementBuilder.build(); Id distributionCarrierId = Id.create("DistributionCarrier", Carrier.class); - Id distributionVehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder distributionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(distributionVehicleTypeId); - distributionVehicleTypeBuilder.setCapacity(10); - distributionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - distributionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - distributionVehicleTypeBuilder.setFixCost(49); - distributionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType distributionType = distributionVehicleTypeBuilder.build(); + Id distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car); + distributionVehType.getCapacity().setOther(10); + distributionVehType.getCostInformation().setCostsPerMeter(0.0004); + distributionVehType.getCostInformation().setCostsPerSecond(0.38); + distributionVehType.getCostInformation().setFixedCost(49.); + distributionVehType.setMaximumVelocity(50/3.6); Id distributionLinkId = Id.createLinkId("(4 2) (4 3)"); Id distributionVehicleId = Id.createVehicleId("DistributionVehicle"); - CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); + CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index 2b6a2e60..dc5fc7b7 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -46,6 +47,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsFirstReloadLSPSchedulingTest { private LSP lsp; @@ -64,18 +66,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index 6c8bd2fe..6378e53c 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -46,6 +47,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsMainRunLSPSchedulingTest { private LSP lsp; @@ -66,18 +68,17 @@ public void initialize() { Network network = scenario.getNetwork(); Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -112,20 +113,19 @@ public void initialize() { firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); toLinkId = Id.createLinkId("(14 2) (14 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 236e1dd2..d08ec364 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -47,6 +48,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsSecondReloadLSPSchedulingTest { private LSP lsp; @@ -70,18 +72,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -118,20 +119,19 @@ public void initialize() { firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); toLinkId = Id.createLinkId("(14 2) (14 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index e158884b..e9f5d639 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -47,6 +48,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class SecondReloadLSPSchedulingTest { private LSP lsp; @@ -70,18 +72,17 @@ public void initialize() { Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); - Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); - collectionVehicleTypeBuilder.setCapacity(10); - collectionVehicleTypeBuilder.setCostPerDistanceUnit(0.0004); - collectionVehicleTypeBuilder.setCostPerTimeUnit(0.38); - collectionVehicleTypeBuilder.setFixCost(49); - collectionVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType collectionType = collectionVehicleTypeBuilder.build(); + Id collectionVehTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType collectionVehType = VehicleUtils.createVehicleType(collectionVehTypeId, TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50/3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); Id collectionVehicleId = Id.createVehicleId("CollectionVehicle"); - CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); + CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionVehType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); @@ -118,20 +119,19 @@ public void initialize() { firstHubElement = firstHubElementBuilder.build(); Id mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class); - Id mainRunVehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); - CarrierVehicleType.Builder mainRunVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(mainRunVehicleTypeId); - mainRunVehicleTypeBuilder.setCapacity(30); - mainRunVehicleTypeBuilder.setCostPerDistanceUnit(0.0002); - mainRunVehicleTypeBuilder.setCostPerTimeUnit(0.38); - mainRunVehicleTypeBuilder.setFixCost(120); - mainRunVehicleTypeBuilder.setMaxVelocity(50/3.6); - org.matsim.vehicles.VehicleType mainRunType = mainRunVehicleTypeBuilder.build(); + Id mainRunVehTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); + org.matsim.vehicles.VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunVehTypeId, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50/3.6); Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); toLinkId = Id.createLinkId("(14 2) (14 3)"); Id mainRunVehicleId = Id.createVehicleId("MainRunVehicle"); - CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); + CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); From e0dda3ac431e4b94a2cbafc615d1364fe604ca43 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 15:44:18 +0100 Subject: [PATCH 4/9] add networkMode to vehicleType. --- .../ExampleTwoLspsGroceryDeliveryMultipleChains.java | 5 +++++ .../ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java index fb877baf..1c52b2be 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java @@ -50,6 +50,7 @@ import org.jetbrains.annotations.NotNull; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -111,6 +112,10 @@ public static void main(String[] args) { CarrierVehicleTypes vehicleTypes = new CarrierVehicleTypes(); CarrierVehicleTypeReader vehicleTypeReader = new CarrierVehicleTypeReader(vehicleTypes); vehicleTypeReader.readFile(VEHICLE_TYPE_FILE); + //The following is needed, because sinde fall 2024 the vehicle types are not assigned to a network mode by default. + for (VehicleType vehicleType : vehicleTypes.getVehicleTypes().values()) { + vehicleType.setNetworkMode(TransportMode.car); + } Carriers carriers = new Carriers(); CarrierPlanXmlReader carrierReader = new CarrierPlanXmlReader(carriers, vehicleTypes); 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 78bedf94..b3734fd5 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 @@ -30,6 +30,7 @@ import org.matsim.analysis.personMoney.PersonMoneyEventsAnalysisModule; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.contrib.roadpricing.*; import org.matsim.core.config.Config; @@ -95,6 +96,10 @@ public static void main(String[] args) { CarrierVehicleTypes vehicleTypes = new CarrierVehicleTypes(); CarrierVehicleTypeReader vehicleTypeReader = new CarrierVehicleTypeReader(vehicleTypes); vehicleTypeReader.readFile(VEHICLE_TYPE_FILE); + //The following is needed, because sinde fall 2024 the vehicle types are not assigned to a network mode by default. + for (VehicleType vehicleType : vehicleTypes.getVehicleTypes().values()) { + vehicleType.setNetworkMode(TransportMode.car); + } Carriers carriers = new Carriers(); CarrierPlanXmlReader carrierReader = new CarrierPlanXmlReader(carriers, vehicleTypes); From 5a860785b7886958b59dabb9da71e724a602aae6 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 15:52:30 +0100 Subject: [PATCH 5/9] add networkMode to vehicleType. Do not use CarrierVehicleType.Builder any more. --- ...chedulingOfTransportChainHubsVsDirect.java | 35 +++++++------- .../initialPlans/ExampleTwoEchelonGrid.java | 46 ++++++++++++------- .../lspScoring/CollectionLSPScoringTest.java | 13 +++++- .../MultipleChainsReplanningTest.java | 23 +++++++--- .../multipleChains/WorstPlanSelectorTest.java | 30 ++++++------ 5 files changed, 92 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java index 392845d6..d76277d6 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java +++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirect.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.CommandLine; @@ -52,6 +53,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /** * The LSP have to possibilities to send the goods from the first depot to the recipients: A) via @@ -240,15 +242,14 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType Carrier mainRunCarrier = CarriersUtils.createCarrier(Id.create("MainRunCarrier", Carrier.class)); - VehicleType mainRunVehType = - CarrierVehicleType.Builder.newInstance( - Id.create("MainRunCarrierVehicleType", VehicleType.class)) - .setCapacity(30) - .setCostPerDistanceUnit(0.0002) - .setCostPerTimeUnit(0.38) - .setFixCost(120) - .setMaxVelocity(50 / 3.6) - .build(); + Id mainRunCarrierVehicleType = Id.create("MainRunCarrierVehicleType", VehicleType.class); + VehicleType mainRunVehType = VehicleUtils.createVehicleType(mainRunCarrierVehicleType, TransportMode.car); + mainRunVehType.getCapacity().setOther(30); + mainRunVehType.getCostInformation().setCostsPerMeter(0.0002); + mainRunVehType.getCostInformation().setCostsPerSecond(0.38); + mainRunVehType.getCostInformation().setFixedCost(120.); + mainRunVehType.setMaximumVelocity(50 / 3.6); + mainRunVehType.setNetworkMode(TransportMode.car); CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.Builder.newInstance( @@ -533,13 +534,15 @@ private static LSPPlan createLSPPlan_reloading( } private static VehicleType createCarrierVehicleType(String vehicleTypeId) { - return CarrierVehicleType.Builder.newInstance(Id.create(vehicleTypeId, VehicleType.class)) - .setCapacity(10) - .setCostPerDistanceUnit(0.0004) - .setCostPerTimeUnit(0.38) - .setFixCost(49) - .setMaxVelocity(50 / 3.6) - .build(); + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create(vehicleTypeId, VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(10); + vehicleType.getCostInformation().setCostsPerMeter(0.0004); + vehicleType.getCostInformation().setCostsPerSecond(0.38); + vehicleType.getCostInformation().setFixedCost(49.); + vehicleType.setMaximumVelocity(50 / 3.6); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; } private static Collection createInitialLSPShipments(Network network) { diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java index 37714938..a776131e 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java +++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.CommandLine; @@ -50,6 +51,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /** * This is an academic example for the 2-echelon problem. It uses the 9x9-grid network from the @@ -81,22 +83,9 @@ final class ExampleTwoEchelonGrid { private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)"); private static final Id HUB_LINK_ID = Id.createLinkId("j(5,3)"); - private static final VehicleType VEH_TYPE_LARGE_50 = - CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); - private static final VehicleType VEH_TYPE_SMALL_05 = - CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class)) - .setCapacity(5) - .setMaxVelocity(10) - .setFixCost(25) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.005) - .build(); + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05(); + private ExampleTwoEchelonGrid() {} // so it cannot be instantiated @@ -490,6 +479,31 @@ enum CarrierCostSetting { lowerCost4LastMile } + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + + private static VehicleType createVehTypeSmall05() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(5); + vehicleType.getCostInformation().setCostsPerMeter(0.001); + vehicleType.getCostInformation().setCostsPerSecond(0.005); + vehicleType.getCostInformation().setFixedCost(25.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + // @Override public ScoringFunction createScoringFunction(Carrier carrier ){ // // return new ScoringFunction(){ diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java index 50431487..2e06a80c 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -49,6 +50,7 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class CollectionLSPScoringTest { @@ -69,8 +71,15 @@ public void initialize() { Scenario scenario = ScenarioUtils.loadScenario(config); Network network = scenario.getNetwork(); - VehicleType collectionVehType = CarrierVehicleType.Builder.newInstance(Id.create("CollectionCarrierVehicleType", VehicleType.class)) - .setCapacity(10).setCostPerDistanceUnit(0.0004).setCostPerTimeUnit(0.38).setFixCost(49).setMaxVelocity(50 / 3.6).build(); + + VehicleType collectionVehType = VehicleUtils.createVehicleType(Id.create("CollectionCarrierVehicleType", VehicleType.class), TransportMode.car); + collectionVehType.getCapacity().setOther(10); + collectionVehType.getCostInformation().setCostsPerMeter(0.0004); + collectionVehType.getCostInformation().setCostsPerSecond(0.38); + collectionVehType.getCostInformation().setFixedCost(49.); + collectionVehType.setMaximumVelocity(50 / 3.6); + collectionVehType.setNetworkMode(TransportMode.car); + Link collectionLink = network.getLinks().get(Id.createLinkId("(4 2) (4 3)")); // (make sure that the link exists) diff --git a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java index 9dd5cc58..501e710b 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -55,17 +56,25 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class MultipleChainsReplanningTest { private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)"); - private static final VehicleType VEH_TYPE_LARGE_50 = CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); int initialPlanCount; diff --git a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java index 47ad17c8..fccfa68e 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -56,25 +57,26 @@ import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; public class WorstPlanSelectorTest { private static final Id DEPOT_SOUTH_LINK_ID = Id.createLinkId("i(1,0)"); private static final Id DEPOT_NORTH_LINK_ID = Id.createLinkId("i(1,8)"); - private static final VehicleType VEH_TYPE_CHEAP = CarrierVehicleType.Builder.newInstance(Id.create("cheap", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(1) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.001) - .build(); - private static final VehicleType VEH_TYPE_EXPENSIVE = CarrierVehicleType.Builder.newInstance(Id.create("expensive", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(100) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); + private static final VehicleType VEH_TYPE_CHEAP = createVehType("cheap", 1., 0.001, 0.001); + private static final VehicleType VEH_TYPE_EXPENSIVE = createVehType("expensive", 100., 0.01, 0.01); + + private static VehicleType createVehType(String vehicleTypeId, double fix, double perDistanceUnit, double perTimeUnit) { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create(vehicleTypeId, VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(perDistanceUnit); + vehicleType.getCostInformation().setCostsPerSecond(perTimeUnit); + vehicleType.getCostInformation().setFixedCost(fix); + vehicleType.setMaximumVelocity(10); + + return vehicleType; + } + @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); private LSP lsp; From c6e9c6c92724ce157a5282f0c0174faf2fb9b134 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 16:10:54 +0100 Subject: [PATCH 6/9] add networkMode to vehicleType. Do not use CarrierVehicleType.Builder any more. --- .../ExampleTwoEchelonGrid_NR.java | 45 ++++++++++++------- .../lspScoring/ExampleLSPScoring.java | 22 ++++----- .../ExampleMultipleMixedEchelonChains.java | 44 +++++++++++------- .../ExampleMultipleOneEchelonChains.java | 45 ++++++++++++------- ...pleMultipleOneEchelonChainsReplanning.java | 45 ++++++++++++------- ...pleMultipleTwoEchelonChainsReplanning.java | 45 ++++++++++++------- .../CompleteLogisticChainTest.java | 15 ++++--- 7 files changed, 159 insertions(+), 102 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java index 695e7fe3..18525885 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java +++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.CommandLine; @@ -52,6 +53,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /** * This is an academic example for the 2-echelon problem. It uses the 9x9-grid network from the @@ -83,22 +85,33 @@ final class ExampleTwoEchelonGrid_NR { private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)"); private static final Id HUB_LINK_ID = Id.createLinkId("j(5,3)"); - private static final VehicleType VEH_TYPE_LARGE_50 = - CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); - private static final VehicleType VEH_TYPE_SMALL_05 = - CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class)) - .setCapacity(5) - .setMaxVelocity(10) - .setFixCost(25) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.005) - .build(); + + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05(); + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + + private static VehicleType createVehTypeSmall05() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(5); + vehicleType.getCostInformation().setCostsPerMeter(0.001); + vehicleType.getCostInformation().setCostsPerSecond(0.005); + vehicleType.getCostInformation().setFixedCost(25.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } private ExampleTwoEchelonGrid_NR() {} // so it cannot be instantiated diff --git a/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java b/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java index 769902b8..d857da87 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java +++ b/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -44,6 +45,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; /* Example for customized scoring. Each customer that is visited will give a random tip between zero and five * @@ -57,24 +59,18 @@ private ExampleLSPScoring() {} private static LSP createLSPWithScorer(Scenario scenario) { // The Carrier for the resource of the sole LogisticsSolutionElement of the LSP is created - var carrierVehicleType = - CarrierVehicleType.Builder.newInstance( - Id.create("CollectionCarrierVehicleType", VehicleType.class)) - .setCapacity(10) - .setCostPerDistanceUnit(0.0004) - .setCostPerTimeUnit(0.38) - .setFixCost(49) - .setMaxVelocity(50 / 3.6) - .build(); + final VehicleType carrierVehType = VehicleUtils.createVehicleType( Id.create("CollectionCarrierVehicleType", VehicleType.class), TransportMode.car); + carrierVehType.getCapacity().setOther(10); + carrierVehType.getCostInformation().setCostsPerMeter(0.0004); + carrierVehType.getCostInformation().setCostsPerSecond(0.38); + carrierVehType.getCostInformation().setFixedCost(49.); + carrierVehType.setMaximumVelocity(50 / 3.6); Id collectionLinkId = Id.createLinkId("(4 2) (4 3)"); CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance() - // .addType(carrierVehicleType ) - .addVehicle( - CarrierVehicle.newInstance( - Id.createVehicleId("CollectionVehicle"), collectionLinkId, carrierVehicleType)) + .addVehicle(CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, carrierVehType)) .setFleetSize(FleetSize.INFINITE) .build(); diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java index ac9d642c..5a1a0090 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -50,6 +51,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; final class ExampleMultipleMixedEchelonChains { @@ -58,22 +60,32 @@ final class ExampleMultipleMixedEchelonChains { private static final double TOLL_VALUE = 1000; private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)"); private static final Id HUB_LINK_ID = Id.createLinkId("j(5,3)"); - private static final VehicleType VEH_TYPE_SMALL_05 = - CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class)) - .setCapacity(5) - .setMaxVelocity(10) - .setFixCost(5) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.01) - .build(); - private static final VehicleType VEH_TYPE_LARGE_50 = - CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05(); + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + + private static VehicleType createVehTypeSmall05() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(5); + vehicleType.getCostInformation().setCostsPerMeter(0.001); + vehicleType.getCostInformation().setCostsPerSecond(0.005); + vehicleType.getCostInformation().setFixedCost(25.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } private ExampleMultipleMixedEchelonChains() {} diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java index 4f095552..2e107c96 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java @@ -29,6 +29,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -51,6 +52,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; final class ExampleMultipleOneEchelonChains { @@ -58,22 +60,33 @@ final class ExampleMultipleOneEchelonChains { private static final DemandSetting demandSetting = DemandSetting.fiveUnits; private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)"); - private static final VehicleType VEH_TYPE_SMALL_05 = - CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class)) - .setCapacity(5) - .setMaxVelocity(10) - .setFixCost(5) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.01) - .build(); - private static final VehicleType VEH_TYPE_LARGE_50 = - CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05(); + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + + private static VehicleType createVehTypeSmall05() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(5); + vehicleType.getCostInformation().setCostsPerMeter(0.001); + vehicleType.getCostInformation().setCostsPerSecond(0.005); + vehicleType.getCostInformation().setFixedCost(25.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + private ExampleMultipleOneEchelonChains() {} diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java index c3056d98..58aa47a7 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java @@ -29,6 +29,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; final class ExampleMultipleOneEchelonChainsReplanning { @@ -62,23 +64,32 @@ final class ExampleMultipleOneEchelonChainsReplanning { private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)"); - private static final VehicleType VEH_TYPE_SMALL_05 = - CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class)) - .setCapacity(5) - .setMaxVelocity(10) - .setFixCost(5) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.01) - .build(); - - private static final VehicleType VEH_TYPE_LARGE_50 = - CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05(); + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + + private static VehicleType createVehTypeSmall05() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(5); + vehicleType.getCostInformation().setCostsPerMeter(0.001); + vehicleType.getCostInformation().setCostsPerSecond(0.005); + vehicleType.getCostInformation().setFixedCost(25.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } private ExampleMultipleOneEchelonChainsReplanning() {} diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java index 7b0521f1..0b363437 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java @@ -29,6 +29,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; @@ -54,6 +55,7 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; +import org.matsim.vehicles.VehicleUtils; final class ExampleMultipleTwoEchelonChainsReplanning { @@ -64,23 +66,32 @@ final class ExampleMultipleTwoEchelonChainsReplanning { private static final Id HUB_LEFT_LINK_ID = Id.createLinkId("i(1,5)R"); private static final Id HUB_RIGHT_LINK_ID = Id.createLinkId("j(9,5)"); - private static final VehicleType VEH_TYPE_SMALL_05 = - CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class)) - .setCapacity(5) - .setMaxVelocity(10) - .setFixCost(5) - .setCostPerDistanceUnit(0.001) - .setCostPerTimeUnit(0.01) - .build(); - - private static final VehicleType VEH_TYPE_LARGE_50 = - CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class)) - .setCapacity(50) - .setMaxVelocity(10) - .setFixCost(150) - .setCostPerDistanceUnit(0.01) - .setCostPerTimeUnit(0.01) - .build(); + private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50(); + private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05(); + + private static VehicleType createVehTypeLarge50() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(50); + vehicleType.getCostInformation().setCostsPerMeter(0.01); + vehicleType.getCostInformation().setCostsPerSecond(0.01); + vehicleType.getCostInformation().setFixedCost(150.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } + + private static VehicleType createVehTypeSmall05() { + VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + vehicleType.getCapacity().setOther(5); + vehicleType.getCostInformation().setCostsPerMeter(0.001); + vehicleType.getCostInformation().setCostsPerSecond(0.005); + vehicleType.getCostInformation().setFixedCost(25.); + vehicleType.setMaximumVelocity(10); + vehicleType.setNetworkMode(TransportMode.car); + + return vehicleType; + } private ExampleMultipleTwoEchelonChainsReplanning() {} diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java index 6ae4fd07..a3f61d2f 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java @@ -113,13 +113,14 @@ public void initialize() { .setResource(firstTransshipmentHubBuilder.build()) .build(); - VehicleType mainRunType = CarrierVehicleType.Builder - .newInstance(collectionVehTypeId) - .setCapacity(30) - .setCostPerDistanceUnit(0.0002) - .setCostPerTimeUnit(0.38) - .setFixCost(120).setMaxVelocity(50 / 3.6) - .build(); + + final VehicleType mainRunType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car); + mainRunType.getCapacity().setOther(30); + mainRunType.getCostInformation().setCostsPerMeter(0.0002); + mainRunType.getCostInformation().setCostsPerSecond(0.38); + mainRunType.getCostInformation().setFixedCost(120.); + mainRunType.setMaximumVelocity(50 / 3.6); + mainRunType.setNetworkMode(TransportMode.car); final Id fromLinkId = Id.createLinkId("(4 2) (4 3)"); CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("MainRunVehicle"), fromLinkId, mainRunType); From a31d53c841f5720f9215f65bfe20f01491e61a95 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 19:19:09 +0100 Subject: [PATCH 7/9] fix typo --- .../ExampleTwoLspsGroceryDeliveryMultipleChains.java | 2 +- .../ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java index 1c52b2be..80462bde 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java @@ -112,7 +112,7 @@ public static void main(String[] args) { CarrierVehicleTypes vehicleTypes = new CarrierVehicleTypes(); CarrierVehicleTypeReader vehicleTypeReader = new CarrierVehicleTypeReader(vehicleTypes); vehicleTypeReader.readFile(VEHICLE_TYPE_FILE); - //The following is needed, because sinde fall 2024 the vehicle types are not assigned to a network mode by default. + //The following is needed, because since fall 2024 the vehicle types are not assigned to a network mode by default. for (VehicleType vehicleType : vehicleTypes.getVehicleTypes().values()) { vehicleType.setNetworkMode(TransportMode.car); } 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 b3734fd5..c1d277be 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 @@ -96,7 +96,7 @@ public static void main(String[] args) { CarrierVehicleTypes vehicleTypes = new CarrierVehicleTypes(); CarrierVehicleTypeReader vehicleTypeReader = new CarrierVehicleTypeReader(vehicleTypes); vehicleTypeReader.readFile(VEHICLE_TYPE_FILE); - //The following is needed, because sinde fall 2024 the vehicle types are not assigned to a network mode by default. + //The following is needed, because since fall 2024 the vehicle types are not assigned to a network mode by default. for (VehicleType vehicleType : vehicleTypes.getVehicleTypes().values()) { vehicleType.setNetworkMode(TransportMode.car); } From 2d3e6610c0f1005311540d30304c191093e7a4bb Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 23:39:34 +0100 Subject: [PATCH 8/9] update pom to use fix in #3560 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 49b88cf9..2e9cf82e 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.matsim matsim-all - 2025.0-2024w46 + 2025.0-PR3560 From af4fe0512f0a06cd0d980bfacb7552dc453c781f Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 23:41:53 +0100 Subject: [PATCH 9/9] comment out runCarrieranalysis, because it is broken somewhere --- .../ExampleTwoLspsGroceryDeliveryMultipleChains.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java index 80462bde..110724f0 100644 --- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java +++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java @@ -145,7 +145,8 @@ public static void main(String[] args) { .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); controler.run(); - runCarrierAnalysis(controler.getControlerIO().getOutputPath(), config); + //Todo: reactivate Analysis, as soon there is a fix. Currently it has a new issue, I need to investigate.... kmt' nov'24 + //runCarrierAnalysis(controler.getControlerIO().getOutputPath(), config); log.info("Done."); }