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 #264 from matsim-vsp/kmt_2echelon4Diss
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
kt86 authored Jul 16, 2024
2 parents 6309574 + 3f2821c commit 5d425cd
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ private void addShipmentLoadElement(
legBeforeService.getExpectedDepartureTime() + legBeforeService.getExpectedTransportTime();
builder.setStartTime(startTimeOfLoading);
builder.setEndTime(startTimeOfLoading + tuple.getShipment().getDeliveryServiceTime());
builder.setCarrierId(carrier.getId());
builder.setLinkId(serviceActivity.getLocation());
builder.setCarrierService(serviceActivity.getService());

ShipmentPlanElement load = builder.build();
String idString =
load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType();
Expand Down Expand Up @@ -232,9 +230,7 @@ private void addShipmentUnloadElement(
double startTime = lastLeg.getExpectedDepartureTime() + lastLeg.getExpectedTransportTime();
builder.setStartTime(startTime);
builder.setEndTime(startTime + getUnloadEndTime(tour));
builder.setCarrierId(carrier.getId());
builder.setLinkId(tour.getEndLinkId());
builder.setCarrierService(serviceActivity.getService());

ShipmentPlanElement unload = builder.build();
String idString =
unload.getResourceId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ private void addShipmentLoadElement(
}
builder.setStartTime(startTimeOfTransport - cumulatedLoadingTime);
builder.setEndTime(startTimeOfTransport);
builder.setCarrierId(carrier.getId());
builder.setLinkId(tour.getStartLinkId());
builder.setCarrierService(serviceActivity.getService());

ShipmentPlanElement load = builder.build();
String idString =
Expand Down Expand Up @@ -312,9 +309,7 @@ private void addShipmentUnloadElement(

builder.setStartTime(startTime);
builder.setEndTime(endTime);
builder.setCarrierId(carrier.getId());
builder.setLinkId(serviceActivity.getLocation());
builder.setCarrierService(serviceActivity.getService());

ShipmentPlanElement unload = builder.build();
String idString =
unload.getResourceId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected void updateShipments() {
for (LSPShipmentCarrierServicePair pair : pairs) {
if (pair.tuple == carrierPair.tuple
&& pair.service.getId() == carrierPair.service.getId()) {
addShipmentLoadElement(lspShipmentWithTime, tour, serviceActivity);
addShipmentLoadElement(lspShipmentWithTime, tour);
addShipmentTransportElement(lspShipmentWithTime, tour, serviceActivity);
addShipmentUnloadElement(lspShipmentWithTime, tour, serviceActivity);
addMainTourRunStartEventHandler(pair.service, lspShipmentWithTime, resource, tour);
Expand All @@ -276,7 +276,7 @@ protected void updateShipments() {
}

private void addShipmentLoadElement(
LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) {
LspShipmentWithTime tuple, Tour tour) {
ShipmentUtils.ScheduledShipmentLoadBuilder builder =
ShipmentUtils.ScheduledShipmentLoadBuilder.newInstance();
builder.setResourceId(resource.getId());
Expand All @@ -297,9 +297,7 @@ private void addShipmentLoadElement(
}
builder.setStartTime(startTimeOfTransport - cumulatedLoadingTime);
builder.setEndTime(startTimeOfTransport);
builder.setCarrierId(carrier.getId());
builder.setLinkId(tour.getStartLinkId());
builder.setCarrierService(serviceActivity.getService());

ShipmentPlanElement load = builder.build();
String idString =
load.getResourceId()
Expand Down Expand Up @@ -365,9 +363,7 @@ private void addShipmentUnloadElement(
legAfterStart.getExpectedDepartureTime()
+ legAfterStart.getExpectedTransportTime()
+ cumulatedLoadingTime);
builder.setCarrierId(carrier.getId());
builder.setLinkId(tour.getEndLinkId());
builder.setCarrierService(serviceActivity.getService());

ShipmentPlanElement unload = builder.build();
String idString =
unload.getResourceId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ && allServicesAreInOnePoint(tour)
final double startTime = event.getTime();
final double endTime = startTime + expHandlingDuration;

logHandlingInHub(serviceActivity.getService(), event, startTime, endTime);
logHandlingInHub(serviceActivity.getService(), startTime, endTime);
throwHandlingEvent(event, lspShipment, expHandlingDuration);
}
}
Expand All @@ -192,7 +192,7 @@ && allServicesAreInOnePoint(tour)
final double startTime = event.getTime() + expUnloadingTime;
final double endTime = startTime + expHandlingDuration;

logHandlingInHub(carrierService, event, startTime, endTime);
logHandlingInHub(carrierService, startTime, endTime);
throwHandlingEvent(event, lspShipment, expHandlingDuration);
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ private double getTotalUnloadingTime(Tour tour) {
}

private void logHandlingInHub(
CarrierService carrierService, CarrierTourEndEvent event, double startTime, double endTime) {
CarrierService carrierService, double startTime, double endTime) {

LSPShipment lspShipment = servicesWaitedFor.get(carrierService).shipment;

Expand Down Expand Up @@ -261,16 +261,6 @@ private void throwHandlingEvent(
event.getTime(), linkId, lspShipment.getId(), resourceId, expHandlingDuration));
}

private double getUnloadEndTime(Tour tour) {
double unloadEndTime = 0;
for (TourElement element : tour.getTourElements()) {
if (element instanceof ServiceActivity serviceActivity) {
unloadEndTime = unloadEndTime + serviceActivity.getDuration();
}
}
return unloadEndTime;
}

private boolean allServicesAreInOnePoint(Tour tour) {
for (TourElement element : tour.getTourElements()) {
if (element instanceof ServiceActivity activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
package org.matsim.freight.logistics.shipment;

import org.matsim.api.core.v01.Id;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierService;
import org.matsim.freight.logistics.LSPResource;
import org.matsim.freight.logistics.LogisticChainElement;

Expand All @@ -32,17 +30,13 @@ class ScheduledShipmentLoad implements ShipmentPlanElement {
private final double endTime;
private final LogisticChainElement element;
private final Id<LSPResource> resourceId;
private final Id<Carrier> carrierId;
private final CarrierService carrierService;

ScheduledShipmentLoad(ShipmentUtils.ScheduledShipmentLoadBuilder builder) {
ScheduledShipmentLoad(ShipmentUtils.ScheduledShipmentLoadBuilder builder) {
this.startTime = builder.startTime;
this.endTime = builder.endTime;
this.element = builder.element;
this.resourceId = builder.resourceId;
this.carrierId = builder.carrierId;
this.carrierService = builder.carrierService;
}
}

@Override
public String getElementType() {
Expand All @@ -69,11 +63,4 @@ public Id<LSPResource> getResourceId() {
return resourceId;
}

public Id<Carrier> getCarrierId() {
return carrierId;
}

public CarrierService getCarrierService() {
return carrierService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ class ScheduledShipmentUnload implements ShipmentPlanElement {
private final double endTime;
private final LogisticChainElement element;
private final Id<LSPResource> resourceId;
private final Id<Carrier> carrierId;
private final CarrierService carrierService;

ScheduledShipmentUnload(ShipmentUtils.ScheduledShipmentUnloadBuilder builder) {
ScheduledShipmentUnload(ShipmentUtils.ScheduledShipmentUnloadBuilder builder) {
this.startTime = builder.startTime;
this.endTime = builder.endTime;
this.element = builder.element;
this.resourceId = builder.resourceId;
this.carrierId = builder.carrierId;
this.carrierService = builder.carrierService;
}
}

@Override
public String getElementType() {
Expand All @@ -69,11 +65,4 @@ public Id<LSPResource> getResourceId() {
return resourceId;
}

public Id<Carrier> getCarrierId() {
return carrierId;
}

public CarrierService getCarrierService() {
return carrierService;
}
}
Loading

0 comments on commit 5d425cd

Please sign in to comment.