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

Commit

Permalink
add networkMode to vehicleType. Do not use CarrierVehicleType.Builder…
Browse files Browse the repository at this point in the history
… any more.
  • Loading branch information
kt86 committed Nov 12, 2024
1 parent 90831d3 commit 3c091b6
Show file tree
Hide file tree
Showing 53 changed files with 796 additions and 782 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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<Carrier> carrierId = Id.create("CollectionCarrier", Carrier.class);
Id<VehicleType> 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<Link> collectionLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> vollectionVehicleId = Id.createVehicleId("CollectionVehicle");
CarrierVehicle carrierVehicle =
CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType);
CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType);

CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance()
.addVehicle(carrierVehicle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*
Expand All @@ -57,19 +59,17 @@ private static LSP createInitialLSP(Scenario scenario) {
// The Carrier for collection is created
Id<Carrier> collectionCarrierId = Id.create("CollectionCarrier", Carrier.class);
Id<VehicleType> 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<Link> collectionLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> 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);
Expand Down Expand Up @@ -124,20 +124,20 @@ private static LSP createInitialLSP(Scenario scenario) {

// The Carrier for the main run Resource is created
Id<Carrier> 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<VehicleType> 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<Link> fromLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> mainRunVehicleId = Id.createVehicleId("MainRunVehicle");
CarrierVehicle mainRunCarrierVehicle =
CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType);
CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType);

CarrierCapabilities mainRunCapabilities =
CarrierCapabilities.Builder.newInstance()
Expand Down Expand Up @@ -190,21 +190,20 @@ private static LSP createInitialLSP(Scenario scenario) {

// The Carrier for distribution is created
Id<Carrier> distributionCarrierId = Id.create("DistributionCarrier", Carrier.class);
Id<VehicleType> 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<VehicleType> 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<Link> distributionLinkId = Id.createLinkId("(14 2) (14 3)");
Id<Vehicle> distributionVehicleId = Id.createVehicleId("DistributionVehicle");
CarrierVehicle distributionCarrierVehicle =
CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType);
CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType);

CarrierCapabilities.Builder distributionCapabilitiesBuilder =
CarrierCapabilities.Builder.newInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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<Carrier> carrierId = Id.create("CollectionCarrier", Carrier.class);
Id<VehicleType> 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<Link> collectionLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> vollectionVehicleId = Id.createVehicleId("CollectionVehicle");
CarrierVehicle carrierVehicle =
CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType);
CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType);

CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance()
.addVehicle(carrierVehicle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -57,19 +59,17 @@ private static LSP createInitialLSP(Scenario scenario) {
// The Carrier for collection is created
Id<Carrier> collectionCarrierId = Id.create("CollectionCarrier", Carrier.class);
Id<VehicleType> 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<Link> collectionLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> vollectionVehicleId = Id.createVehicleId("CollectionVehicle");
CarrierVehicle carrierVehicle =
CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType);
CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionVehType);

CarrierCapabilities capabilities = CarrierCapabilities.Builder.newInstance()
.addVehicle(carrierVehicle)
Expand Down Expand Up @@ -124,21 +124,18 @@ private static LSP createInitialLSP(Scenario scenario) {

// The Carrier for the main run Resource is created
final Id<Carrier> mainRunCarrierId = Id.create("MainRunCarrier", Carrier.class);
final Id<VehicleType> 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<VehicleType> 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<Link> fromLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> mainRunVehicleId = Id.createVehicleId("MainRunVehicle");
CarrierVehicle mainRunCarrierVehicle =
CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType);
CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunVehType);

CarrierCapabilities mainRunCapabilities =
CarrierCapabilities.Builder.newInstance()
Expand Down Expand Up @@ -192,21 +189,19 @@ private static LSP createInitialLSP(Scenario scenario) {

// The Carrier for distribution is created
Id<Carrier> distributionCarrierId = Id.create("DistributionCarrier", Carrier.class);
Id<VehicleType> distributionVehicleTypeId =
Id<VehicleType> 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<Link> distributionLinkId = Id.createLinkId("(4 2) (4 3)");
Id<Vehicle> distributionVehicleId = Id.createVehicleId("DistributionVehicle");
CarrierVehicle distributionCarrierVehicle =
CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType);
CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionVehType);

CarrierCapabilities distributionCapabilities = CarrierCapabilities.Builder.newInstance()
.addVehicle(distributionCarrierVehicle)
Expand Down
Loading

0 comments on commit 3c091b6

Please sign in to comment.