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

Commit

Permalink
pass the scenario through to the *CarrierScheduler, ctd.
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Aug 13, 2024
1 parent 5790244 commit aead2c1
Show file tree
Hide file tree
Showing 67 changed files with 131 additions and 155 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, scenario.getNetwork())
.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 @@ -84,7 +84,7 @@ private static LSP createInitialLSP(Scenario scenario) {
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(
collectionCarrier, network)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down Expand Up @@ -222,7 +222,7 @@ private static LSP createInitialLSP(Scenario scenario) {

// 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 @@ -331,7 +331,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType
distributionCarrier, network)
.setLocationLinkId(hubLinkId)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();
// (The scheduler is where jsprit comes into play.)

Expand Down Expand Up @@ -374,7 +374,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType
directDistributionCarrier, network)
.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 @@ -251,7 +251,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement directCarrierElement =
Expand Down Expand Up @@ -344,7 +344,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement directCarrierElement =
Expand Down Expand Up @@ -354,7 +354,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
.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, scenario.getNetwork())
.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, scenario.getNetwork())
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static LSP createInitialLSP(Scenario scenario) {
ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(
collectionCarrier, network)
.setCollectionScheduler(
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler())
ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario))
.setLocationLinkId(collectionLinkId)
.build();

Expand Down Expand Up @@ -224,7 +224,7 @@ private static LSP createInitialLSP(Scenario scenario) {
// 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 @@ -200,7 +200,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, scenario.getNetwork())
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down Expand Up @@ -280,7 +280,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, scenario.getNetwork())
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier1, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement1 =
Expand Down Expand Up @@ -290,7 +290,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down Expand Up @@ -363,7 +363,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down Expand Up @@ -237,7 +237,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierLeft, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

leftCarrierElement =
Expand All @@ -261,7 +261,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierRight, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

rightCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
singleCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down Expand Up @@ -258,7 +258,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierLeft, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

leftCarrierElement =
Expand All @@ -282,7 +282,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
carrierRight, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

rightCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrierLeft, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElementLeft =
Expand Down Expand Up @@ -328,7 +328,7 @@ private static LSP createLSP(Scenario scenario) {
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, network)
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
distributionCarrier, scenario.getNetwork())
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down Expand Up @@ -410,7 +410,7 @@ private static LogisticChain createDirectChain(Scenario scenario, String lspName
ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(
directCarrier, scenario.getNetwork())
.setDistributionScheduler(
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
distributionCarrier, scenario.getNetwork())
.setDistributionScheduler(
// ResourceImplementationUtils.createDefaultDistributionCarrierSchedulerWithRoadPricing(RoadPricingUtils.getRoadPricingScheme(scenario)))
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement distributionCarrierElement =
Expand Down Expand Up @@ -439,7 +439,7 @@ private static LogisticChain createDirectChain(Scenario scenario, String lspName
directCarrier, scenario.getNetwork())
.setDistributionScheduler(
// ResourceImplementationUtils.createDefaultDistributionCarrierSchedulerWithRoadPricing(RoadPricingUtils.getRoadPricingScheme(scenario)))
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler())
ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario))
.build();

LogisticChainElement singleCarrierElement =
Expand Down
Loading

0 comments on commit aead2c1

Please sign in to comment.