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 MainRunCarrierResource and its Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Aug 13, 2024
1 parent 2db8f74 commit dd61053
Show file tree
Hide file tree
Showing 35 changed files with 39 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static LSP createInitialLSP(Scenario scenario) {

// The adapter i.e. the main run resource is created
LSPResource mainRunResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType

// The scheduler for the main run Resource is created and added to the Resource
LSPResource mainRunResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setFromLinkId(depotLinkId)
.setToLinkId(hubLinkId)
.setMainRunCarrierScheduler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private static LSP createLSP(Scenario scenario) {
CarrierVehicle.newInstance(
Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierRessource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private static LSP createLSP(Scenario scenario) {
CarrierVehicle.newInstance(
Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierRessource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static LSP createInitialLSP(Scenario scenario) {

// The adapter i.e. the main run resource is created
LSPResource mainRunResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private static LSP createLSP(Scenario scenario) {
vehicleTypes.getVehicleTypes().get(Id.create("heavy40t", VehicleType.class))));
LSPResource mainCarrierResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(
mainCarrier, scenario.getNetwork())
mainCarrier)
.setFromLinkId(depotLinkFromVehicles)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierResource1 =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(
mainCarrier1, network)
mainCarrier1)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down Expand Up @@ -316,7 +316,7 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(
mainCarrier, network)
mainCarrier)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static LSP createLSP(Scenario scenario) {
CarrierVehicle.newInstance(
Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierResourceLeft =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrierLeft, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrierLeft)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down Expand Up @@ -281,7 +281,7 @@ private static LSP createLSP(Scenario scenario) {
CarrierVehicle.newInstance(
Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier, network)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
vehicleTypesMainRun.getVehicleTypes().get(Id.create("heavy40t", VehicleType.class))));
LSPResource mainCarrierResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(
mainCarrier, scenario.getNetwork())
mainCarrier)
.setFromLinkId(depotLinkFromVehicles)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
vehicleTypesMainRun.getVehicleTypes().get(Id.create("heavy40t", VehicleType.class))));
LSPResource mainCarrierResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(
mainCarrier, scenario.getNetwork())
mainCarrier)
.setFromLinkId(depotLinkFromVehicles)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void endTag(String name, String content, Stack<String> context) {
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(null))
.build();
case mainRunCarrier -> lspResource =
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(currentCarrier, null)
ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(currentCarrier)
.setMainRunCarrierScheduler(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(null))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierVehicle;
Expand Down Expand Up @@ -332,23 +331,21 @@ public static class MainRunCarrierResourceBuilder {

private final Id<LSPResource> id;
private final ArrayList<LogisticChainElement> clientElements;
private final Network network;
private Carrier carrier;
private Id<Link> fromLinkId;
private Id<Link> toLinkId;
private MainRunCarrierScheduler mainRunScheduler;
private VehicleReturn vehicleReturn;

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

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

public MainRunCarrierResourceBuilder setMainRunCarrierScheduler(
Expand Down Expand Up @@ -403,10 +400,6 @@ MainRunCarrierScheduler getMainRunScheduler() {
return mainRunScheduler;
}

Network getNetwork() {
return network;
}

VehicleReturn getVehicleReturn() {
return vehicleReturn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void initialize() {
carrier = CarriersUtils.createCarrier(carrierId);
carrier.setCarrierCapabilities(capabilities);

mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(carrier, network)
mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(carrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)")).setToLinkId(Id.createLinkId("(14 2) (14 3)"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void initialize() {
Carrier mainRunCarrierResourceBuilder = CarriersUtils.createCarrier(carrierId);
mainRunCarrierResourceBuilder.setCarrierCapabilities(capabilities);

mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrierResourceBuilder, network)
mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrierResourceBuilder)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void initialize() {
Carrier mainRunCarrier = CarriersUtils.createCarrier(collectionCarrierId);
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);

LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void initialize() {
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);


LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
LSPResource mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(Id.createLinkId("(4 2) (4 3)"))
.setToLinkId(Id.createLinkId("(14 2) (14 3)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void initialize() {
Carrier mainRunCarrier = CarriersUtils.createCarrier(mainRunCarrierId);
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);

mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier, network)
mainRunResource = ResourceImplementationUtils.MainRunCarrierResourceBuilder.newInstance(mainRunCarrier)
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setFromLinkId(fromLinkId)
.setToLinkId(toLinkId)
Expand Down
Loading

0 comments on commit dd61053

Please sign in to comment.