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

Commit

Permalink
remove the temporarily added get/setTime(..) methods. They where only…
Browse files Browse the repository at this point in the history
… there for make refactoring a bit easier.
  • Loading branch information
kt86 committed Aug 14, 2024
1 parent 28217d0 commit d583037
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ private void presortIncomingShipments() {
for (LogisticChainElement element : resource.getClientElements()) {
lspShipmentsToSchedule.addAll(element.getIncomingShipments().getLspShipmentsWTime());
}
lspShipmentsToSchedule.sort(Comparator.comparingDouble(LspShipment::getTime));
lspShipmentsToSchedule.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment));
}

private void switchHandledShipments(int bufferTime) {
for (LspShipment lspShipmentWithTime : lspShipmentsToSchedule) {
var shipmentPlan = LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getId());
double endOfTransportTime = shipmentPlan.getMostRecentEntry().getEndTime() + bufferTime;
lspShipmentWithTime.setTime(endOfTransportTime);
LspShipmentUtils.setTimeOfLspShipment(lspShipmentWithTime, endOfTransportTime);
for (LogisticChainElement element : resource.getClientElements()) {
if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipmentWithTime)) {
element.getIncomingShipments().getLspShipmentsWTime().remove(lspShipmentWithTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

@Override
public void addShipment(double time, LspShipment lspShipment) {
lspShipment.setTime(time);
LspShipmentUtils.setTimeOfLspShipment(lspShipment, time);
this.shipments.add(lspShipment);
shipments.sort(Comparator.comparingDouble(LspShipment::getTime));
shipments.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment));
}

@Override
public Collection<LspShipment> getSortedLspShipments() {
shipments.sort(Comparator.comparingDouble(LspShipment::getTime));
shipments.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment));
return shipments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected void scheduleResource() {
shipmentsInCurrentTour.add(lspShipment);
load = load + lspShipment.getSize();
cumulatedLoadingTime = cumulatedLoadingTime + lspShipment.getDeliveryServiceTime();
availabilityTimeOfLastShipment = lspShipment.getTime();
availabilityTimeOfLastShipment = LspShipmentUtils.getTimeOfLspShipment(lspShipment);
}

if (!shipmentsInCurrentTour.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected void initializeValues(LSPResource resource) {
protected void scheduleResource() {
int load = 0;
List<LspShipment> copyOfAssignedShipments = new ArrayList<>(lspShipmentsToSchedule);
copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipment::getTime));
copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment));
ArrayList<LspShipment> shipmentsInCurrentTour = new ArrayList<>();
// ArrayList<ScheduledTour> scheduledTours = new ArrayList<>();
List<CarrierPlan> scheduledPlans = new LinkedList<>();
Expand Down Expand Up @@ -131,12 +131,12 @@ private CarrierPlan createPlan(Carrier carrier, List<LspShipment> lspShipments)
tourBuilder.scheduleStart(Id.create(resource.getStartLinkId(), Link.class));

double totalLoadingTime = 0;
double latestTupleTime = 0;
double latestLspShipmentTime = 0;

for (LspShipment lspShipment : lspShipments) {
totalLoadingTime = totalLoadingTime + lspShipment.getDeliveryServiceTime();
if (lspShipment.getTime() > latestTupleTime) {
latestTupleTime = lspShipment.getTime();
if (LspShipmentUtils.getTimeOfLspShipment(lspShipment) > latestLspShipmentTime) {
latestLspShipmentTime = LspShipmentUtils.getTimeOfLspShipment(lspShipment);
}
tourBuilder.addLeg(new Leg());
CarrierService carrierService = convertToCarrierService(lspShipment);
Expand All @@ -158,7 +158,7 @@ private CarrierPlan createPlan(Carrier carrier, List<LspShipment> lspShipments)
Tour vehicleTour = tourBuilder.build();
CarrierVehicle vehicle =
carrier.getCarrierCapabilities().getCarrierVehicles().values().iterator().next();
double tourStartTime = latestTupleTime + totalLoadingTime;
double tourStartTime = latestLspShipmentTime + totalLoadingTime;
ScheduledTour sTour = ScheduledTour.newInstance(vehicleTour, vehicle, tourStartTime);

tours.add(sTour);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ private void updateSchedule(LspShipment lspShipment) {
private void addShipmentHandleElement(LspShipment lspShipment) {
LspShipmentUtils.ScheduledShipmentHandleBuilder builder =
LspShipmentUtils.ScheduledShipmentHandleBuilder.newInstance();
builder.setStartTime(lspShipment.getTime());
builder.setEndTime(
lspShipment.getTime() + capacityNeedFixed + capacityNeedLinear * lspShipment.getSize());
builder.setStartTime(LspShipmentUtils.getTimeOfLspShipment(lspShipment));
builder.setEndTime(LspShipmentUtils.getTimeOfLspShipment(lspShipment) + capacityNeedFixed + capacityNeedLinear * lspShipment.getSize());
builder.setResourceId(transshipmentHubResource.getId());
for (LogisticChainElement element : transshipmentHubResource.getClientElements()) {
if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) {
builder.setLogisticsChainElement(element);
}
}
LspShipmentPlanElement handle = builder.build();

String idString =
handle.getResourceId()
+ String.valueOf(handle.getLogisticChainElement().getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,4 @@ public interface LspShipment

Collection<LspShipmentRequirement> getRequirements();

///---
double getTime();
void setTime(double time);

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ public Collection<LspShipmentRequirement> getRequirements() {
return lspShipmentRequirements;
}

@Override
public double getTime() {
return LspShipmentUtils.getTimeOfLspShipment(this);
}

@Override
public void setTime(double time) {
LspShipmentUtils.setTimeOfLspShipment(this, time);
}

@Override
public double getPickupServiceTime() {
return pickupServiceTime;
Expand Down

0 comments on commit d583037

Please sign in to comment.