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

Commit

Permalink
Merge pull request #291 from matsim-vsp/kmt_2echelon4Diss
Browse files Browse the repository at this point in the history
make the scenario available
  • Loading branch information
kt86 authored Aug 13, 2024
2 parents 2ee697c + dd61053 commit e9669f9
Show file tree
Hide file tree
Showing 74 changed files with 340 additions and 393 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

/*package-private*/ class ExampleSchedulingOfInitialPlan {

private static LSP createInitialLSP(Network network) {
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);
Expand Down Expand Up @@ -73,9 +73,10 @@ private static LSP createInitialLSP(Network network) {

// The Resource i.e. the Resource is created
LSPResource collectionResource =
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier, network)
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(
carrier)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down Expand Up @@ -161,7 +162,7 @@ public static void main(String[] args) {
Network network = scenario.getNetwork();

// Create LSP and lspShipments
LSP lsp = createInitialLSP(network);
LSP lsp = createInitialLSP(scenario);
Collection<LSPShipment> lspShipments = createInitialLSPShipments(network);

// assign the lspShipments to the LSP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ private static LSP createInitialLSP(Scenario scenario) {
// The collection adapter i.e. the Resource is created
LSPResource collectionResource =
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(
collectionCarrier, network)
collectionCarrier)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down Expand Up @@ -149,10 +149,10 @@ 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())
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.build();

// The LogisticsSolutionElement for the main run Resource is created
Expand Down Expand Up @@ -217,12 +217,12 @@ 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.
distributionResourceBuilder.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler());
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario));
LSPResource distributionResource = distributionResourceBuilder.build();

// The adapter is now inserted into the corresponding LogisticsSolutionElement of the only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ 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(
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler())
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.build();

mainRunElement =
Expand Down Expand Up @@ -328,10 +328,10 @@ 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())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
// (The scheduler is where jsprit comes into play.)

Expand Down Expand Up @@ -371,10 +371,10 @@ 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())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
// (The scheduler is where jsprit comes into play.)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ 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())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement directCarrierElement =
Expand Down Expand Up @@ -286,10 +286,10 @@ 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())
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setToLinkId(HUB_LINK_ID)
.setVehicleReturn(ResourceImplementationUtils.VehicleReturn.returnToFromLink)
.build();
Expand Down Expand Up @@ -342,9 +342,9 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
LSPResource distributionCarrierRessource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ 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())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement directCarrierElement =
Expand Down Expand Up @@ -296,10 +296,10 @@ 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())
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setToLinkId(HUB_LINK_ID)
.setVehicleReturn(ResourceImplementationUtils.VehicleReturn.returnToFromLink)
.build();
Expand Down Expand Up @@ -352,9 +352,9 @@ private static LSP createLSP(Scenario scenario) {
Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
LSPResource distributionCarrierRessource =
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
distributionCarrier)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

private ExampleLSPScoring() {}

private static LSP createLSPWithScorer(Network network) {
private static LSP createLSPWithScorer(Scenario scenario) {

// The Carrier for the resource of the sole LogisticsSolutionElement of the LSP is created
var carrierVehicleType =
Expand Down Expand Up @@ -84,9 +84,10 @@ private static LSP createLSPWithScorer(Network network) {
// The Resource i.e. the Resource is created
// The scheduler for the Resource is created and added. This is where jsprit comes into play.
LSPResource lspResource =
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier, network)
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(
carrier)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down Expand Up @@ -198,7 +199,7 @@ static Scenario prepareScenario(Config config) {
Scenario scenario = ScenarioUtils.loadScenario(config);

// Create LSP and lspShipments
LSP lsp = createLSPWithScorer(scenario.getNetwork());
LSP lsp = createLSPWithScorer(scenario);
Collection<LSPShipment> lspShipments = createInitialLSPShipments(scenario.getNetwork());

// assign the lspShipments to the LSP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ public static void main(String[] args) {
.readFile("scenarios/2regions/2regions-network.xml");

// Create LSP and lspShipments
Network network = scenario.getNetwork();
LSP lsp = createInitialLSP(network);
Collection<LSPShipment> lspShipments = createInitialLSPShipments(network);
LSP lsp = createInitialLSP(scenario);
Collection<LSPShipment> lspShipments = createInitialLSPShipments(scenario.getNetwork());

// assign the lspShipments to the LSP
for (LSPShipment lspShipment : lspShipments) {
Expand Down Expand Up @@ -153,7 +152,7 @@ public void install() {
}
}

private static LSP createInitialLSP(Network network) {
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);
Expand Down Expand Up @@ -182,9 +181,9 @@ private static LSP createInitialLSP(Network network) {

// The Resource i.e. the Resource is created
LSPResource collectionResource =
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier, network)
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ private static LSP createInitialLSP(Scenario scenario) {
// The collection adapter i.e. the Resource is created
LSPResource collectionResource =
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(
collectionCarrier, network)
collectionCarrier)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down Expand Up @@ -150,10 +150,10 @@ 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())
.setMainRunCarrierScheduler(ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.build();

// The LogisticsSolutionElement for the main run Resource is created
Expand Down Expand Up @@ -219,12 +219,12 @@ 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.
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

// The adapter is now inserted into the corresponding LogisticsSolutionElement of the only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ 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())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down Expand Up @@ -228,10 +228,10 @@ 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())
ResourceImplementationUtils.createDefaultMainRunCarrierScheduler(scenario))
.setToLinkId(HUB_LINK_ID)
.setVehicleReturn(ResourceImplementationUtils.VehicleReturn.returnToFromLink)
.build();
Expand Down Expand Up @@ -278,9 +278,9 @@ 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())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Loading

0 comments on commit e9669f9

Please sign in to comment.