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

Commit

Permalink
remove network from DistributionCarrierResource and its Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Aug 13, 2024
1 parent e5a4bcc commit 1c42fb6
Show file tree
Hide file tree
Showing 29 changed files with 46 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private static LSP createInitialLSP(Scenario scenario) {
// The distribution adapter i.e. the Resource is created
DistributionCarrierResourceBuilder distributionResourceBuilder =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network);
distributionCarrier);
distributionResourceBuilder.setLocationLinkId(distributionLinkId);

// The scheduler for the Resource is created and added. This is where jsprit comes into play.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType
// The distribution adapter i.e. the Resource is created
LSPResource distributionResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setLocationLinkId(hubLinkId)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
Expand Down Expand Up @@ -371,7 +371,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType
// The distribution adapter i.e. the Resource is created
LSPResource directDistributionResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directDistributionCarrier, network)
directDistributionCarrier)
.setLocationLinkId(depotLinkId)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("directTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource directCarrierRessource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, network)
directCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -342,7 +342,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
LSPResource distributionCarrierRessource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("directTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource directCarrierRessource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, network)
directCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -352,7 +352,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
LSPResource distributionCarrierRessource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private static LSP createInitialLSP(Scenario scenario) {
// The distribution adapter i.e. the Resource is created
LSPResource distributionResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setLocationLinkId(distributionLinkId)
// The scheduler for the Resource is created and added. This is where jsprit comes into
// play.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static LSP createLSP(Scenario scenario) {
vehicleTypes.getVehicleTypes().get(Id.create("heavy40t", VehicleType.class))));
LSPResource singleCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, scenario.getNetwork())
singleCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -278,7 +278,7 @@ private static LSP createLSP(Scenario scenario) {
.get(Id.create("heavy40t_electro", VehicleType.class))));
LSPResource distributionCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, scenario.getNetwork())
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource distributionCarrierResource1 =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier1, network)
distributionCarrier1)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -288,7 +288,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("singleCarrier"), DEPOT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource singleCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, network)
singleCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -361,7 +361,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource distributionCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("veh_large"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource singleCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, network)
singleCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -235,7 +235,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("veh_small"), DEPOT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource carrierLeftResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierLeft, network)
carrierLeft)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand All @@ -259,7 +259,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("veh_small"), DEPOT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource carrierRightResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierRight, network)
carrierRight)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("veh_large"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource singleCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, network)
singleCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -256,7 +256,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("veh_small"), DEPOT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource carrierLeftResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierLeft, network)
carrierLeft)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand All @@ -280,7 +280,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("veh_small"), DEPOT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource carrierRightResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierRight, network)
carrierRight)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LEFT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource distributionCarrierResourceLeft =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrierLeft, network)
distributionCarrierLeft)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -326,7 +326,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_RIGHT_LINK_ID, VEH_TYPE_SMALL_05));
LSPResource distributionCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
.get(Id.create("heavy40t_electro", VehicleType.class))));
LSPResource distributionCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, scenario.getNetwork())
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down Expand Up @@ -408,7 +408,7 @@ private static LogisticChain createDirectChain(Scenario scenario, String lspName
vehicleTypes.getVehicleTypes().get(Id.create("heavy40t", VehicleType.class))));
LSPResource singleCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, scenario.getNetwork())
directCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
.get(Id.create("heavy40t_electro", VehicleType.class))));
LSPResource distributionCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, scenario.getNetwork())
distributionCarrier)
.setDistributionScheduler(ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

Expand Down Expand Up @@ -434,7 +434,7 @@ private static LogisticChain createDirectChain(Scenario scenario, String lspName
vehicleTypes.getVehicleTypes().get(Id.create("heavy40t", VehicleType.class))));
LSPResource singleCarrierResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, scenario.getNetwork())
directCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void endTag(String name, String content, Stack<String> context) {
.build();
case distributionCarrier -> lspResource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
currentCarrier, null)
currentCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(null))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Collection;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierVehicle;
import org.matsim.freight.logistics.*;
Expand All @@ -36,14 +35,12 @@
private final Carrier carrier;
private final Collection<LogisticChainElement> clientElements;
private final DistributionCarrierScheduler distributionHandler;
private final Network network;

DistributionCarrierResource(DistributionCarrierResourceBuilder builder) {
super(builder.id);
this.distributionHandler = builder.distributionHandler;
this.clientElements = builder.clientElements;
this.carrier = builder.carrier;
this.network = builder.network;
}

@Override
Expand Down Expand Up @@ -80,10 +77,6 @@ public void schedule(int bufferTime, LSPPlan lspPlan) {
distributionHandler.scheduleShipments(lspPlan, this, bufferTime);
}

public Network getNetwork() {
return network;
}

public Carrier getCarrier() {
return carrier;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,19 @@ public static class DistributionCarrierResourceBuilder {

final Id<LSPResource> id;
final ArrayList<LogisticChainElement> clientElements;
final Network network;
final Carrier carrier;
Id<Link> locationLinkId;
DistributionCarrierScheduler distributionHandler;

private DistributionCarrierResourceBuilder(Carrier carrier, Network network) {
private DistributionCarrierResourceBuilder(Carrier carrier) {
this.id = Id.create(carrier.getId().toString(), LSPResource.class);
setCarrierType(carrier, CARRIER_TYPE.distributionCarrier);
this.carrier = carrier;
this.clientElements = new ArrayList<>();
this.network = network;
}

public static DistributionCarrierResourceBuilder newInstance(Carrier carrier, Network network) {
return new DistributionCarrierResourceBuilder(carrier, network);
public static DistributionCarrierResourceBuilder newInstance(Carrier carrier) {
return new DistributionCarrierResourceBuilder(carrier);
}

public DistributionCarrierResourceBuilder setLocationLinkId(Id<Link> locationLinkId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void initialize() {
distributionCarrier.setCarrierCapabilities(capabilities);


DistributionCarrierResourceBuilder builder = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(distributionCarrier, network);
DistributionCarrierResourceBuilder builder = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(distributionCarrier);
builder.setDistributionScheduler(ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario));
builder.setLocationLinkId(distributionLinkId);
distributionResource = builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static LSP createLSP(Scenario scenario) {
carrierLeft.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarriersUtils.addCarrierVehicle(carrierLeft, CarrierVehicle.newInstance(Id.createVehicleId("veh_small"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource carrierLeftResource = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrierLeft, network)
LSPResource carrierLeftResource = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrierLeft)
.setDistributionScheduler(ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

Expand All @@ -117,7 +117,7 @@ private static LSP createLSP(Scenario scenario) {
carrierRight.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarriersUtils.addCarrierVehicle(carrierRight, CarrierVehicle.newInstance(Id.createVehicleId("veh_small"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource carrierRightResource = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrierRight, network)
LSPResource carrierRightResource = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrierRight)
.setDistributionScheduler(ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

Expand Down
Loading

0 comments on commit 1c42fb6

Please sign in to comment.