From 3c091b6d6ef1f70c5b05a52fb0c609a2e6daaf0a Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Tue, 12 Nov 2024 12:16:30 +0100 Subject: [PATCH] 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();