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

Commit

Permalink
WORKAROUND: pass rpScheme through to VRP solving.
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Aug 7, 2024
1 parent 21c23bd commit ddd8c28
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.ArrayList;
import org.matsim.api.core.v01.Id;
import org.matsim.contrib.roadpricing.RoadPricingScheme;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierService;
import org.matsim.freight.carriers.ScheduledTour;
Expand All @@ -46,11 +47,24 @@
private Carrier carrier;
private CollectionCarrierResource resource;
private ArrayList<LSPCarrierPair> pairs;
private RoadPricingScheme rpscheme = null;

CollectionCarrierScheduler() {
this.pairs = new ArrayList<>();
}

/**
* Constructor for the CollectionCarrierScheduler.
* TODO: In the future, the road pricing scheme should come from some the scenario: RoadPricingUtils.getRoadPricingScheme(scenario). This here is only a dirty workaround. KMT'Aug'24
* @deprecated This is only a dirty workaround. KMT'Aug'24
* @param rpscheme the road pricing scheme
*/
@Deprecated
CollectionCarrierScheduler(RoadPricingScheme rpscheme) {
this.pairs = new ArrayList<>();
this.rpscheme = rpscheme;
}

@Override
public void initializeValues(LSPResource resource) {
this.pairs = new ArrayList<>();
Expand All @@ -69,7 +83,7 @@ public void scheduleResource() {
CarrierService carrierService = convertToCarrierService(tupleToBeAssigned);
carrier.getServices().put(carrierService.getId(), carrierService);
}
carrier = CarrierSchedulerUtils.solveVrpWithJspritWithToll(carrier, resource.getNetwork(), null);
carrier = CarrierSchedulerUtils.solveVrpWithJspritWithToll(carrier, resource.getNetwork(), rpscheme);
}

private CarrierService convertToCarrierService(LspShipmentWithTime tuple) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import org.locationtech.jts.util.Assert;
import org.matsim.api.core.v01.Id;
import org.matsim.contrib.roadpricing.RoadPricingScheme;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.Tour.Leg;
Expand All @@ -52,11 +53,24 @@
private DistributionCarrierResource resource;
private ArrayList<LSPCarrierPair> pairs;
private int carrierCnt = 1;
private RoadPricingScheme rpscheme = null;

DistributionCarrierScheduler() {
this.pairs = new ArrayList<>();
}

/**
* Constructor for the DistributionCarrierScheduler.
* TODO: In the future, the road pricing scheme should come from some the scenario: RoadPricingUtils.getRoadPricingScheme(scenario). This here is only a dirty workaround. KMT'Aug'24
* @deprecated This is only a dirty workaround. KMT'Aug'24
* @param rpscheme the road pricing scheme
*/
@Deprecated
DistributionCarrierScheduler(RoadPricingScheme rpscheme) {
this.pairs = new ArrayList<>();
this.rpscheme = rpscheme;
}

@Override
protected void initializeValues(LSPResource resource) {
this.pairs = new ArrayList<>();
Expand Down Expand Up @@ -91,7 +105,7 @@ protected void scheduleResource() {
CarrierSchedulerUtils.solveVrpWithJspritWithToll(
createAuxiliaryCarrier(
shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime),
resource.getNetwork(), null);
resource.getNetwork(), rpscheme);
scheduledPlans.add(auxiliaryCarrier.getSelectedPlan());
carrier.getServices().putAll(auxiliaryCarrier.getServices());
cumulatedLoadingTime = 0;
Expand All @@ -108,7 +122,7 @@ protected void scheduleResource() {
CarrierSchedulerUtils.solveVrpWithJspritWithToll(
createAuxiliaryCarrier(
shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime),
resource.getNetwork(), null);
resource.getNetwork(), rpscheme);
scheduledPlans.add(auxiliaryCarrier.getSelectedPlan());
carrier.getServices().putAll(auxiliaryCarrier.getServices());
shipmentsInCurrentTour.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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.contrib.roadpricing.RoadPricingScheme;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierVehicle;
Expand Down Expand Up @@ -221,6 +222,26 @@ public static CollectionCarrierScheduler createDefaultCollectionCarrierScheduler
return new CollectionCarrierScheduler();
}

/**
* Utils method to create a DistributionCarrierScheduler with Roadpricing.
* TODO: In the future, the road pricing scheme should come from some the scenario: RoadPricingUtils.getRoadPricingScheme(scenario). This here is only a dirty workaround. KMT'Aug'24
* @deprecated This is only a dirty workaround. KMT'Aug'24
* @param roadPricingScheme the road pricing scheme
*/
public static DistributionCarrierScheduler createDefaultDistributionCarrierSchedulerWithRoadPricing(RoadPricingScheme roadPricingScheme) {
return new DistributionCarrierScheduler(roadPricingScheme);
}

/**
* Utils method to create a Collection CarrierScheduler with Roadpricing.
* TODO: In the future, the road pricing scheme should come from some the scenario: RoadPricingUtils.getRoadPricingScheme(scenario). This here is only a dirty workaround. KMT'Aug'24
* @deprecated This is only a dirty workaround. KMT'Aug'24
* @param roadPricingScheme the road pricing scheme
*/
public static CollectionCarrierScheduler createDefaultCollectionCarrierSchedulerWithRoadPricing(RoadPricingScheme roadPricingScheme) {
return new CollectionCarrierScheduler(roadPricingScheme);
}

public static MainRunCarrierScheduler createDefaultMainRunCarrierScheduler() {
return new MainRunCarrierScheduler();
}
Expand Down

0 comments on commit ddd8c28

Please sign in to comment.