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

Commit

Permalink
rename services(s) to CarrierServices for clarification reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Aug 12, 2024
1 parent 15c7839 commit f721f1b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public void setEmbeddingContainer(LSP pointer) {}
public void handleEvent(CarrierTourEndEvent event) {
score++;
// use event handlers to compute score. In this case, score is incremented by one every time
// a service and a tour ends.
// a CarrierService and a tour ends.
}

@Override
Expand All @@ -615,7 +615,7 @@ public void reset(int iteration) {
public void handleEvent(CarrierServiceEndEvent event) {
score++;
// use event handlers to compute score. In this case, score is incremented by one every time
// a service and a tour ends.
// a CarrierService and a tour ends.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ private CarrierService convertToCarrierService(LspShipmentWithTime tuple) {
builder.setServiceStartTimeWindow(tuple.getLspShipment().getPickupTimeWindow());
builder.setCapacityDemand(tuple.getLspShipment().getSize());
builder.setServiceDuration(tuple.getLspShipment().getDeliveryServiceTime());
CarrierService service = builder.build();
pairs.add(new LSPCarrierPair(tuple, service));
return service;
CarrierService carrierService = builder.build();
pairs.add(new LSPCarrierPair(tuple, carrierService));
return carrierService;
}

@Override
Expand All @@ -109,12 +109,12 @@ protected void updateShipments() {
LSPCarrierPair carrierPair = new LSPCarrierPair(tuple, serviceActivity.getService());
for (LSPCarrierPair pair : pairs) {
if (pair.tuple == carrierPair.tuple
&& pair.service.getId() == carrierPair.service.getId()) {
&& pair.carrierService.getId() == carrierPair.carrierService.getId()) {
addShipmentLoadElement(tuple, tour, serviceActivity);
addShipmentTransportElement(tuple, tour, serviceActivity);
addShipmentUnloadElement(tuple, tour, serviceActivity);
addCollectionTourEndEventHandler(pair.service, tuple, resource, tour);
addCollectionServiceEventHandler(pair.service, tuple, resource);
addCollectionTourEndEventHandler(pair.carrierService, tuple, resource, tour);
addCollectionServiceEventHandler(pair.carrierService, tuple, resource);
}
}
}
Expand Down Expand Up @@ -246,5 +246,5 @@ private double getUnloadEndTime(Tour tour) {
return unloadEndTime;
}

private record LSPCarrierPair(LspShipmentWithTime tuple, CarrierService service) {}
private record LSPCarrierPair(LspShipmentWithTime tuple, CarrierService carrierService) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ private CarrierService convertToCarrierService(LspShipmentWithTime tuple) {
CarrierService.Builder.newInstance(serviceId, tuple.getLspShipment().getTo());
builder.setCapacityDemand(tuple.getLspShipment().getSize());
builder.setServiceDuration(tuple.getLspShipment().getDeliveryServiceTime());
CarrierService service = builder.build();
pairs.add(new LSPCarrierPair(tuple, service));
return service;
CarrierService carrierService = builder.build();
pairs.add(new LSPCarrierPair(tuple, carrierService));
return carrierService;
}

@Override
Expand All @@ -196,12 +196,12 @@ protected void updateShipments() {
LSPCarrierPair carrierPair = new LSPCarrierPair(tuple, serviceActivity.getService());
for (LSPCarrierPair pair : pairs) {
if (pair.tuple == carrierPair.tuple
&& pair.service.getId() == carrierPair.service.getId()) {
&& pair.carrierService.getId() == carrierPair.carrierService.getId()) {
addShipmentLoadElement(tuple, tour, serviceActivity);
addShipmentTransportElement(tuple, tour, serviceActivity);
addShipmentUnloadElement(tuple, tour, serviceActivity);
addDistributionTourStartEventHandler(pair.service, tuple, resource, tour);
addDistributionServiceEventHandler(pair.service, tuple, resource);
addDistributionTourStartEventHandler(pair.carrierService, tuple, resource, tour);
addDistributionServiceEventHandler(pair.carrierService, tuple, resource);
}
}
}
Expand Down Expand Up @@ -294,10 +294,10 @@ private void addShipmentUnloadElement(
}
}
int serviceIndex = tour.getTourElements().indexOf(serviceActivity);
ServiceActivity service = (ServiceActivity) tour.getTourElements().get(serviceIndex);
ServiceActivity serviceAct = (ServiceActivity) tour.getTourElements().get(serviceIndex);

final double startTime = service.getExpectedArrival();
final double endTime = startTime + service.getDuration();
final double startTime = serviceAct.getExpectedArrival();
final double endTime = startTime + serviceAct.getDuration();
Assert.isTrue(
endTime >= startTime,
"latest End must be later than earliest start. start: " + startTime + " ; end: " + endTime);
Expand Down Expand Up @@ -369,13 +369,5 @@ private void addDistributionTourStartEventHandler(
}
}

static class LSPCarrierPair {
private final LspShipmentWithTime tuple;
private final CarrierService service;

public LSPCarrierPair(LspShipmentWithTime tuple, CarrierService service) {
this.tuple = tuple;
this.service = service;
}
}
private record LSPCarrierPair(LspShipmentWithTime tuple, CarrierService carrierService) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ protected void updateShipments() {
lspShipmentWithTime, serviceActivity.getService());
for (LSPShipmentCarrierServicePair pair : pairs) {
if (pair.tuple == carrierPair.tuple
&& pair.service.getId() == carrierPair.service.getId()) {
&& pair.carrierService.getId() == carrierPair.carrierService.getId()) {
addShipmentLoadElement(lspShipmentWithTime, tour);
addShipmentTransportElement(lspShipmentWithTime, tour, serviceActivity);
addShipmentUnloadElement(lspShipmentWithTime, tour, serviceActivity);
addMainTourRunStartEventHandler(pair.service, lspShipmentWithTime, resource, tour);
addMainRunTourEndEventHandler(pair.service, lspShipmentWithTime, resource, tour);
addMainTourRunStartEventHandler(pair.carrierService, lspShipmentWithTime, resource, tour);
addMainRunTourEndEventHandler(pair.carrierService, lspShipmentWithTime, resource, tour);
}
}
}
Expand Down Expand Up @@ -386,5 +386,5 @@ private void addMainRunTourEndEventHandler(
}
}

private record LSPShipmentCarrierServicePair(LspShipmentWithTime tuple, CarrierService service) {}
private record LSPShipmentCarrierServicePair(LspShipmentWithTime tuple, CarrierService carrierService) {}
}

0 comments on commit f721f1b

Please sign in to comment.