diff --git a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java
index 695e7fe3..18525885 100644
--- a/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java
+++ b/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java
@@ -26,6 +26,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
+import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.CommandLine;
@@ -52,6 +53,7 @@
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;
import org.matsim.vehicles.VehicleType;
+import org.matsim.vehicles.VehicleUtils;
/**
* This is an academic example for the 2-echelon problem. It uses the 9x9-grid network from the
@@ -83,22 +85,33 @@ final class ExampleTwoEchelonGrid_NR {
private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)");
private static final Id HUB_LINK_ID = Id.createLinkId("j(5,3)");
- private static final VehicleType VEH_TYPE_LARGE_50 =
- CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class))
- .setCapacity(50)
- .setMaxVelocity(10)
- .setFixCost(150)
- .setCostPerDistanceUnit(0.01)
- .setCostPerTimeUnit(0.01)
- .build();
- private static final VehicleType VEH_TYPE_SMALL_05 =
- CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class))
- .setCapacity(5)
- .setMaxVelocity(10)
- .setFixCost(25)
- .setCostPerDistanceUnit(0.001)
- .setCostPerTimeUnit(0.005)
- .build();
+
+ private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50();
+ private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05();
+
+ private static VehicleType createVehTypeLarge50() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(50);
+ vehicleType.getCostInformation().setCostsPerMeter(0.01);
+ vehicleType.getCostInformation().setCostsPerSecond(0.01);
+ vehicleType.getCostInformation().setFixedCost(150.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
+
+ private static VehicleType createVehTypeSmall05() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(5);
+ vehicleType.getCostInformation().setCostsPerMeter(0.001);
+ vehicleType.getCostInformation().setCostsPerSecond(0.005);
+ vehicleType.getCostInformation().setFixedCost(25.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
private ExampleTwoEchelonGrid_NR() {} // so it cannot be instantiated
diff --git a/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java b/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java
index 769902b8..d857da87 100644
--- a/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java
+++ b/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java
@@ -26,6 +26,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
+import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
@@ -44,6 +45,7 @@
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;
import org.matsim.vehicles.VehicleType;
+import org.matsim.vehicles.VehicleUtils;
/* Example for customized scoring. Each customer that is visited will give a random tip between zero and five
*
@@ -57,24 +59,18 @@ private ExampleLSPScoring() {}
private static LSP createLSPWithScorer(Scenario scenario) {
// The Carrier for the resource of the sole LogisticsSolutionElement of the LSP is created
- var carrierVehicleType =
- CarrierVehicleType.Builder.newInstance(
- Id.create("CollectionCarrierVehicleType", VehicleType.class))
- .setCapacity(10)
- .setCostPerDistanceUnit(0.0004)
- .setCostPerTimeUnit(0.38)
- .setFixCost(49)
- .setMaxVelocity(50 / 3.6)
- .build();
+ final VehicleType carrierVehType = VehicleUtils.createVehicleType( Id.create("CollectionCarrierVehicleType", VehicleType.class), TransportMode.car);
+ carrierVehType.getCapacity().setOther(10);
+ carrierVehType.getCostInformation().setCostsPerMeter(0.0004);
+ carrierVehType.getCostInformation().setCostsPerSecond(0.38);
+ carrierVehType.getCostInformation().setFixedCost(49.);
+ carrierVehType.setMaximumVelocity(50 / 3.6);
Id collectionLinkId = Id.createLinkId("(4 2) (4 3)");
CarrierCapabilities capabilities =
CarrierCapabilities.Builder.newInstance()
- // .addType(carrierVehicleType )
- .addVehicle(
- CarrierVehicle.newInstance(
- Id.createVehicleId("CollectionVehicle"), collectionLinkId, carrierVehicleType))
+ .addVehicle(CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, carrierVehType))
.setFleetSize(FleetSize.INFINITE)
.build();
diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java
index ac9d642c..5a1a0090 100644
--- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java
+++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java
@@ -26,6 +26,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
+import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
@@ -50,6 +51,7 @@
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;
import org.matsim.vehicles.VehicleType;
+import org.matsim.vehicles.VehicleUtils;
final class ExampleMultipleMixedEchelonChains {
@@ -58,22 +60,32 @@ final class ExampleMultipleMixedEchelonChains {
private static final double TOLL_VALUE = 1000;
private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)");
private static final Id HUB_LINK_ID = Id.createLinkId("j(5,3)");
- private static final VehicleType VEH_TYPE_SMALL_05 =
- CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class))
- .setCapacity(5)
- .setMaxVelocity(10)
- .setFixCost(5)
- .setCostPerDistanceUnit(0.001)
- .setCostPerTimeUnit(0.01)
- .build();
- private static final VehicleType VEH_TYPE_LARGE_50 =
- CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class))
- .setCapacity(50)
- .setMaxVelocity(10)
- .setFixCost(150)
- .setCostPerDistanceUnit(0.01)
- .setCostPerTimeUnit(0.01)
- .build();
+ private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50();
+ private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05();
+
+ private static VehicleType createVehTypeLarge50() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(50);
+ vehicleType.getCostInformation().setCostsPerMeter(0.01);
+ vehicleType.getCostInformation().setCostsPerSecond(0.01);
+ vehicleType.getCostInformation().setFixedCost(150.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
+
+ private static VehicleType createVehTypeSmall05() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(5);
+ vehicleType.getCostInformation().setCostsPerMeter(0.001);
+ vehicleType.getCostInformation().setCostsPerSecond(0.005);
+ vehicleType.getCostInformation().setFixedCost(25.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
private ExampleMultipleMixedEchelonChains() {}
diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java
index 4f095552..2e107c96 100644
--- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java
+++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java
@@ -29,6 +29,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
+import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
@@ -51,6 +52,7 @@
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;
import org.matsim.vehicles.VehicleType;
+import org.matsim.vehicles.VehicleUtils;
final class ExampleMultipleOneEchelonChains {
@@ -58,22 +60,33 @@ final class ExampleMultipleOneEchelonChains {
private static final DemandSetting demandSetting = DemandSetting.fiveUnits;
private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)");
- private static final VehicleType VEH_TYPE_SMALL_05 =
- CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class))
- .setCapacity(5)
- .setMaxVelocity(10)
- .setFixCost(5)
- .setCostPerDistanceUnit(0.001)
- .setCostPerTimeUnit(0.01)
- .build();
- private static final VehicleType VEH_TYPE_LARGE_50 =
- CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class))
- .setCapacity(50)
- .setMaxVelocity(10)
- .setFixCost(150)
- .setCostPerDistanceUnit(0.01)
- .setCostPerTimeUnit(0.01)
- .build();
+ private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50();
+ private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05();
+
+ private static VehicleType createVehTypeLarge50() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(50);
+ vehicleType.getCostInformation().setCostsPerMeter(0.01);
+ vehicleType.getCostInformation().setCostsPerSecond(0.01);
+ vehicleType.getCostInformation().setFixedCost(150.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
+
+ private static VehicleType createVehTypeSmall05() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(5);
+ vehicleType.getCostInformation().setCostsPerMeter(0.001);
+ vehicleType.getCostInformation().setCostsPerSecond(0.005);
+ vehicleType.getCostInformation().setFixedCost(25.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
+
private ExampleMultipleOneEchelonChains() {}
diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java
index c3056d98..58aa47a7 100644
--- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java
+++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java
@@ -29,6 +29,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
+import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
@@ -54,6 +55,7 @@
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;
import org.matsim.vehicles.VehicleType;
+import org.matsim.vehicles.VehicleUtils;
final class ExampleMultipleOneEchelonChainsReplanning {
@@ -62,23 +64,32 @@ final class ExampleMultipleOneEchelonChainsReplanning {
private static final Id DEPOT_LINK_ID = Id.createLinkId("i(5,0)");
- private static final VehicleType VEH_TYPE_SMALL_05 =
- CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class))
- .setCapacity(5)
- .setMaxVelocity(10)
- .setFixCost(5)
- .setCostPerDistanceUnit(0.001)
- .setCostPerTimeUnit(0.01)
- .build();
-
- private static final VehicleType VEH_TYPE_LARGE_50 =
- CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class))
- .setCapacity(50)
- .setMaxVelocity(10)
- .setFixCost(150)
- .setCostPerDistanceUnit(0.01)
- .setCostPerTimeUnit(0.01)
- .build();
+ private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50();
+ private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05();
+
+ private static VehicleType createVehTypeLarge50() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(50);
+ vehicleType.getCostInformation().setCostsPerMeter(0.01);
+ vehicleType.getCostInformation().setCostsPerSecond(0.01);
+ vehicleType.getCostInformation().setFixedCost(150.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
+
+ private static VehicleType createVehTypeSmall05() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(5);
+ vehicleType.getCostInformation().setCostsPerMeter(0.001);
+ vehicleType.getCostInformation().setCostsPerSecond(0.005);
+ vehicleType.getCostInformation().setFixedCost(25.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
private ExampleMultipleOneEchelonChainsReplanning() {}
diff --git a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java
index 7b0521f1..0b363437 100644
--- a/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java
+++ b/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java
@@ -29,6 +29,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
+import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
@@ -54,6 +55,7 @@
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;
import org.matsim.vehicles.VehicleType;
+import org.matsim.vehicles.VehicleUtils;
final class ExampleMultipleTwoEchelonChainsReplanning {
@@ -64,23 +66,32 @@ final class ExampleMultipleTwoEchelonChainsReplanning {
private static final Id HUB_LEFT_LINK_ID = Id.createLinkId("i(1,5)R");
private static final Id HUB_RIGHT_LINK_ID = Id.createLinkId("j(9,5)");
- private static final VehicleType VEH_TYPE_SMALL_05 =
- CarrierVehicleType.Builder.newInstance(Id.create("small05", VehicleType.class))
- .setCapacity(5)
- .setMaxVelocity(10)
- .setFixCost(5)
- .setCostPerDistanceUnit(0.001)
- .setCostPerTimeUnit(0.01)
- .build();
-
- private static final VehicleType VEH_TYPE_LARGE_50 =
- CarrierVehicleType.Builder.newInstance(Id.create("large50", VehicleType.class))
- .setCapacity(50)
- .setMaxVelocity(10)
- .setFixCost(150)
- .setCostPerDistanceUnit(0.01)
- .setCostPerTimeUnit(0.01)
- .build();
+ private static final VehicleType VEH_TYPE_LARGE_50 = createVehTypeLarge50();
+ private static final VehicleType VEH_TYPE_SMALL_05 = createVehTypeSmall05();
+
+ private static VehicleType createVehTypeLarge50() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("large50", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(50);
+ vehicleType.getCostInformation().setCostsPerMeter(0.01);
+ vehicleType.getCostInformation().setCostsPerSecond(0.01);
+ vehicleType.getCostInformation().setFixedCost(150.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
+
+ private static VehicleType createVehTypeSmall05() {
+ VehicleType vehicleType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car);
+ vehicleType.getCapacity().setOther(5);
+ vehicleType.getCostInformation().setCostsPerMeter(0.001);
+ vehicleType.getCostInformation().setCostsPerSecond(0.005);
+ vehicleType.getCostInformation().setFixedCost(25.);
+ vehicleType.setMaximumVelocity(10);
+ vehicleType.setNetworkMode(TransportMode.car);
+
+ return vehicleType;
+ }
private ExampleMultipleTwoEchelonChainsReplanning() {}
diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java
index 6ae4fd07..a3f61d2f 100644
--- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java
+++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java
@@ -113,13 +113,14 @@ public void initialize() {
.setResource(firstTransshipmentHubBuilder.build())
.build();
- VehicleType mainRunType = CarrierVehicleType.Builder
- .newInstance(collectionVehTypeId)
- .setCapacity(30)
- .setCostPerDistanceUnit(0.0002)
- .setCostPerTimeUnit(0.38)
- .setFixCost(120).setMaxVelocity(50 / 3.6)
- .build();
+
+ final VehicleType mainRunType = VehicleUtils.createVehicleType(Id.create("small05", VehicleType.class), TransportMode.car);
+ mainRunType.getCapacity().setOther(30);
+ mainRunType.getCostInformation().setCostsPerMeter(0.0002);
+ mainRunType.getCostInformation().setCostsPerSecond(0.38);
+ mainRunType.getCostInformation().setFixedCost(120.);
+ mainRunType.setMaximumVelocity(50 / 3.6);
+ mainRunType.setNetworkMode(TransportMode.car);
final Id fromLinkId = Id.createLinkId("(4 2) (4 3)");
CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("MainRunVehicle"), fromLinkId, mainRunType);