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

Minor: comments and Update MATSim version #286

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.matsim</groupId>
<artifactId>matsim-all</artifactId>
<version>2025.0-PR3386</version>
<version>2025.0-PR3390</version>
<!-- <version>2025.0-2024w31</version>-->
<!-- <version>2025.0-SNAPSHOT</version>-->
<relativePath/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
CarriersUtils.createCarrier(Id.create(lspName +"_distributionCarrier", Carrier.class));
distributionCarrier
.getCarrierCapabilities()
//.setNumberOfJspritIterations // TODO Das mal hier einbauen. --> Ist aktuell in CarrierUtils.
.setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarriersUtils.addCarrierVehicle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.roadpricing.RoadPricingScheme;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierPlan;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.jsprit.MatsimJspritFactory;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.freight.carriers.jsprit.NetworkRouter;
import org.matsim.freight.carriers.jsprit.VehicleTypeDependentRoadPricingCalculator;

/**
* This class contains some code fragments, that are used in the different *CarrierScheduler
Expand All @@ -31,16 +31,16 @@ public class CarrierSchedulerUtils {
* This looks for me (KMT) similar to what is done in {@link org.matsim.freight.carriers.CarriersUtils#runJsprit(Scenario)}.
* So, maybe this can be more simplify.
* <p>
* @Todo: include toll in the NetbasedCosts (if set), so it is also pat of the VRP
* @Todo: Find a way to reuse the netbasedCosts over the iterations(?) to avoid re-setting this up???
* <li> Pro: saves computation times,
* <li> Con: There is now update of the costs if the network (load) changes.
* <li> --> do it at least per Carrier or generally or stay as it is? --> Discuss with KN
* @Todo: Make the number of jsprit-Iterations configurable
*
* @param carrier Carrier for which the problem should be solved
* @param network the underlying network to create the network based transport costs
* @param carrier Carrier for which the problem should be solved
* @param network the underlying network to create the network based transport costs
* @return Carrier with the solution of the VehicleRoutingProblem and the routed plan.
* @Todo: include toll in the NetbasedCosts (if set), so it is also pat of the VRP
* @Todo: Find a way to reuse the netbasedCosts over the iterations(?) to avoid re-setting this up???
* <li> Pro: saves computation times,
* <li> Con: There is now update of the costs if the network (load) changes.
* <li> --> do it at least per Carrier or generally or stay as it is? --> Discuss with KN
* @Todo: Make the number of jsprit-Iterations configurable
*/
public static Carrier solveVrpWithJsprit(Carrier carrier, Network network) {
NetworkBasedTransportCosts netbasedTransportCosts =
Expand Down Expand Up @@ -70,17 +70,18 @@ public static Carrier solveVrpWithJsprit(Carrier carrier, Network network) {
/**
* First try with tolls.
* Rest is the same as {@link #solveVrpWithJsprit(Carrier, Network)}.
* @param carrier Carrier for which the problem should be solved
* @param network the underlying network to create the network based transport costs
* @param roadPricingCalculator the road pricing calculator to calculate the tolls
* //TODO: Combine this method with the untolled version {@link #solveVrpWithJsprit(Carrier, Network)}.
* @param carrier Carrier for which the problem should be solved
* @param network the underlying network to create the network based transport costs
* @param roadPricingScheme (MATSim's) road pricing scheme from the roadpricing contrib
* @return Carrier with the solution of the VehicleRoutingProblem and the routed plan.
*/
public static Carrier solveVrpWithJspritWithToll(Carrier carrier, Network network, VehicleTypeDependentRoadPricingCalculator roadPricingCalculator) {
if (roadPricingCalculator != null) {
public static Carrier solveVrpWithJspritWithToll(Carrier carrier, Network network, RoadPricingScheme roadPricingScheme) {
if (roadPricingScheme != null) {
NetworkBasedTransportCosts netbasedTransportCosts =
NetworkBasedTransportCosts.Builder.newInstance(
network, ResourceImplementationUtils.getVehicleTypeCollection(carrier))
.setRoadPricingCalculator(roadPricingCalculator)
.setRoadPricingScheme(roadPricingScheme)
.build();

VehicleRoutingProblem vrp =
Expand All @@ -89,6 +90,7 @@ public static Carrier solveVrpWithJspritWithToll(Carrier carrier, Network networ
.build();

//Setting jspritIterations to use central infrastructure -> should go more up in the code
//TODO: If not set, setze es auf 1.
CarriersUtils.setJspritIterations(carrier, 1);

VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void scheduleResource() {
CarrierService carrierService = convertToCarrierService(tupleToBeAssigned);
carrier.getServices().put(carrierService.getId(), carrierService);
}
carrier = CarrierSchedulerUtils.solveVrpWithJsprit(carrier, resource.getNetwork());
carrier = CarrierSchedulerUtils.solveVrpWithJspritWithToll(carrier, resource.getNetwork(), null);
}

private CarrierService convertToCarrierService(LspShipmentWithTime tuple) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ protected void scheduleResource() {
> vehicleType.getCapacity().getOther().intValue()) {
load = 0;
Carrier auxiliaryCarrier =
CarrierSchedulerUtils.solveVrpWithJsprit(
CarrierSchedulerUtils.solveVrpWithJspritWithToll(
createAuxiliaryCarrier(
shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime),
resource.getNetwork());
resource.getNetwork(), null);
scheduledPlans.add(auxiliaryCarrier.getSelectedPlan());
carrier.getServices().putAll(auxiliaryCarrier.getServices());
cumulatedLoadingTime = 0;
Expand All @@ -105,10 +105,10 @@ protected void scheduleResource() {

if (!shipmentsInCurrentTour.isEmpty()) {
Carrier auxiliaryCarrier =
CarrierSchedulerUtils.solveVrpWithJsprit(
CarrierSchedulerUtils.solveVrpWithJspritWithToll(
createAuxiliaryCarrier(
shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime),
resource.getNetwork());
resource.getNetwork(), null);
scheduledPlans.add(auxiliaryCarrier.getSelectedPlan());
carrier.getServices().putAll(auxiliaryCarrier.getServices());
shipmentsInCurrentTour.clear();
Expand Down