Skip to content

Commit

Permalink
use new method names
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Dec 20, 2024
1 parent b8c6da6 commit 80cc5df
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) {
createJobId(scenario, newDemandInformationElement, link.getId(), null),
CarrierService.class);
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
.setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime)
.setDemand(demandForThisLink).setServiceDuration(serviceTime)
.setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow())
.build();
CarriersUtils.getCarriers(scenario).getCarriers()
Expand Down Expand Up @@ -696,7 +696,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) {
CarrierService.class);
if (demandToDistribute > 0 && singleDemandForThisLink > 0) {
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
.setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime)
.setDemand(singleDemandForThisLink).setServiceDuration(serviceTime)
.setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow())
.build();
thisCarrier.getServices().put(thisService.getId(), thisService);
Expand Down Expand Up @@ -747,7 +747,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) {
createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class);
if ((demandToDistribute > 0 && singleDemandForThisLink > 0) || demandToDistribute == 0) {
CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId())
.setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime)
.setDemand(singleDemandForThisLink).setServiceDuration(serviceTime)
.setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow())
.build();
CarriersUtils.getCarriers(scenario).getCarriers()
Expand Down Expand Up @@ -1051,8 +1051,8 @@ private static void createSingleShipment(Scenario scenario, DemandInformationEle

CarrierShipment thisShipment = CarrierShipment.Builder
.newInstance(idNewShipment, linkPickup.getId(), linkDelivery.getId(), singleDemandForThisLink)
.setPickupServiceTime(serviceTimePickup).setPickupTimeWindow(timeWindowPickup)
.setDeliveryServiceTime(serviceTimeDelivery).setDeliveryTimeWindow(timeWindowDelivery)
.setPickupDuration(serviceTimePickup).setPickupStartsTimeWindow(timeWindowPickup)
.setDeliveryDuration(serviceTimeDelivery).setDeliveryStartsTimeWindow(timeWindowDelivery)
.build();
thisCarrier.getShipments().put(thisShipment.getId(), thisShipment);
if (demandForThisLink == 0)
Expand Down Expand Up @@ -1207,10 +1207,10 @@ private static void combineSimilarJobs(Scenario scenario) {
}
CarrierShipment newShipment = CarrierShipment.Builder
.newInstance(idNewShipment, baseShipment.getFrom(), baseShipment.getTo(), demandForThisLink)
.setPickupServiceTime(serviceTimePickup)
.setPickupTimeWindow(baseShipment.getPickupTimeWindow())
.setDeliveryServiceTime(serviceTimeDelivery)
.setDeliveryTimeWindow(baseShipment.getDeliveryTimeWindow()).build();
.setPickupDuration(serviceTimePickup)
.setPickupStartsTimeWindow(baseShipment.getPickupTimeWindow())
.setDeliveryDuration(serviceTimeDelivery)
.setDeliveryStartsTimeWindow(baseShipment.getDeliveryTimeWindow()).build();
shipmentsToAdd.add(newShipment);
}
}
Expand Down Expand Up @@ -1253,7 +1253,7 @@ private static void combineSimilarJobs(Scenario scenario) {
.newInstance(idNewService, baseService.getLocationLinkId())
.setServiceDuration(serviceTimeService)
.setServiceStartTimeWindow(baseService.getServiceStartTimeWindow())
.setCapacityDemand(demandForThisLink).build();
.setDemand(demandForThisLink).build();
servicesToAdd.add(newService);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void generateIterationServices(Carriers carriers, Population population)
double latestStart = Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_END_IDX));

CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(serviceId, PopulationUtils.decideOnLinkIdForActivity(activity,scenario));
serviceBuilder.setCapacityDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX)));
serviceBuilder.setDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX)));
serviceBuilder.setServiceDuration(Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_DURATION_IDX)));
serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(earliestStart,latestStart));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ public void startTag(String name, Attributes attributes, Stack<String> context)
CarrierShipment.Builder shipmentBuilder = CarrierShipment.Builder.newInstance( Id.create( id, CarrierShipment.class ),
Id.create( from, Link.class ), Id.create( to, Link.class ), size );
if( startPickup == null ){
shipmentBuilder.setPickupTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ).setDeliveryTimeWindow(
shipmentBuilder.setPickupStartsTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ).setDeliveryStartsTimeWindow(
TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) );
} else{
shipmentBuilder.setPickupTimeWindow( TimeWindow.newInstance( getDouble( startPickup ), getDouble( endPickup ) ) ).
setDeliveryTimeWindow(
shipmentBuilder.setPickupStartsTimeWindow( TimeWindow.newInstance( getDouble( startPickup ), getDouble( endPickup ) ) ).
setDeliveryStartsTimeWindow(
TimeWindow.newInstance(
getDouble(
startDelivery ),
getDouble(
endDelivery ) ) );
}
if( pickupServiceTime != null ) shipmentBuilder.setPickupServiceTime( getDouble( pickupServiceTime ) );
if( deliveryServiceTime != null ) shipmentBuilder.setDeliveryServiceTime( getDouble( deliveryServiceTime ) );
if( pickupServiceTime != null ) shipmentBuilder.setPickupDuration( getDouble( pickupServiceTime ) );
if( deliveryServiceTime != null ) shipmentBuilder.setDeliveryDuration( getDouble( deliveryServiceTime ) );
CarrierShipment shipment = shipmentBuilder.build();
currentShipments.put( attributes.getValue( ID ), shipment );
CarriersUtils.addShipment(currentCarrier, shipment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void startTag(String name, Attributes atts, Stack<String> context) {
Id<Link> to = Id.create(toLocation, Link.class);
CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(id, to);
String capDemandString = atts.getValue("capacityDemand");
if (capDemandString != null) serviceBuilder.setCapacityDemand(getInt(capDemandString));
if (capDemandString != null) serviceBuilder.setDemand(getInt(capDemandString));
String startString = atts.getValue("earliestStart");
double start = parseTimeToDouble(startString);
double end;
Expand Down Expand Up @@ -157,13 +157,13 @@ public void startTag(String name, Attributes atts, Stack<String> context) {
String deliveryServiceTime = atts.getValue("deliveryServiceTime");

if (startPickup != null && endPickup != null)
shipmentBuilder.setPickupTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup)));
shipmentBuilder.setPickupStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup)));
if (startDelivery != null && endDelivery != null)
shipmentBuilder.setDeliveryTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery)));
shipmentBuilder.setDeliveryStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery)));
if (pickupServiceTime != null)
shipmentBuilder.setPickupServiceTime(parseTimeToDouble(pickupServiceTime));
shipmentBuilder.setPickupDuration(parseTimeToDouble(pickupServiceTime));
if (deliveryServiceTime != null)
shipmentBuilder.setDeliveryServiceTime(parseTimeToDouble(deliveryServiceTime));
shipmentBuilder.setDeliveryDuration(parseTimeToDouble(deliveryServiceTime));

currentShipment = shipmentBuilder.build();
currentShipments.put(atts.getValue(ID), currentShipment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void startTag(String name, Attributes atts, Stack<String> context) {
Id<Link> to = Id.create(toLocation, Link.class);
CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(id, to);
String capDemandString = atts.getValue("capacityDemand");
if (capDemandString != null) serviceBuilder.setCapacityDemand(getInt(capDemandString));
if (capDemandString != null) serviceBuilder.setDemand(getInt(capDemandString));
String startString = atts.getValue("earliestStart");
double start = parseTimeToDouble(startString);
double end;
Expand Down Expand Up @@ -155,13 +155,13 @@ public void startTag(String name, Attributes atts, Stack<String> context) {
String deliveryServiceTime = atts.getValue("deliveryServiceTime");

if (startPickup != null && endPickup != null)
shipmentBuilder.setPickupTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup)));
shipmentBuilder.setPickupStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup)));
if (startDelivery != null && endDelivery != null)
shipmentBuilder.setDeliveryTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery)));
shipmentBuilder.setDeliveryStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery)));
if (pickupServiceTime != null)
shipmentBuilder.setPickupServiceTime(parseTimeToDouble(pickupServiceTime));
shipmentBuilder.setPickupDuration(parseTimeToDouble(pickupServiceTime));
if (deliveryServiceTime != null)
shipmentBuilder.setDeliveryServiceTime(parseTimeToDouble(deliveryServiceTime));
shipmentBuilder.setDeliveryDuration(parseTimeToDouble(deliveryServiceTime));

currentShipment = shipmentBuilder.build();
currentShipments.put(atts.getValue(ID), currentShipment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,12 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri
.newInstance(Id.create(carrierService.getId().toString(), CarrierShipment.class),
depotServiceIsDeliveredFrom.get(carrierService.getId()), carrierService.getLocationLinkId(),
carrierService.getDemand())
.setDeliveryServiceTime(carrierService.getServiceDuration())
.setDeliveryDuration(carrierService.getServiceDuration())
// .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we
// have now time for that. Maybe change it later, kmt sep18
.setDeliveryTimeWindow(carrierService.getServiceStartTimeWindow())
.setDeliveryStartsTimeWindow(carrierService.getServiceStartTimeWindow())
// Limited to end of delivery timeWindow (pickup later than the latest delivery is not useful).
.setPickupTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStartTimeWindow().getEnd()))
.setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStartTimeWindow().getEnd()))
.build();
addShipment(carrierWS, carrierShipment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static CarrierServiceStartEvent convert(GenericEvent event) {
Id<Link> locationLinkId = Id.createLinkId(attributes.get(ATTRIBUTE_LINK));
CarrierService service = CarrierService.Builder.newInstance(carrierServiceId, locationLinkId)
.setServiceDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_SERVICE_DURATION)))
.setCapacityDemand(Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND)))
.setDemand(Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND)))
.build();
Id<Vehicle> vehicleId = Id.create(attributes.get(ATTRIBUTE_VEHICLE), Vehicle.class);
return new CarrierServiceStartEvent(time, carrierId, service, vehicleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static CarrierShipmentDeliveryEndEvent convert(GenericEvent event) {
Id<Link> shipmentTo = Id.createLinkId(attributes.get(ATTRIBUTE_LINK));
int size = Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND));
CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, null, shipmentTo, size)
.setDeliveryServiceTime(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_DROPOFF_DURATION)))
.setDeliveryDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_DROPOFF_DURATION)))
.build();
Id<Vehicle> vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE));
return new CarrierShipmentDeliveryEndEvent(time, carrierId, shipment, vehicleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static CarrierShipmentDeliveryStartEvent convert(GenericEvent event) {
Id<Link> shipmentTo = Id.createLinkId(attributes.get(ATTRIBUTE_LINK));
int size = Integer.parseInt(attributes.get(ATTRIBUTE_CAPACITYDEMAND));
CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, null, shipmentTo, size)
.setDeliveryServiceTime(Double.parseDouble(attributes.get(ATTRIBUTE_DROPOFF_DURATION)))
.setDeliveryDuration(Double.parseDouble(attributes.get(ATTRIBUTE_DROPOFF_DURATION)))
.build();
Id<Vehicle> vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE));
return new CarrierShipmentDeliveryStartEvent(time, carrierId, shipment, vehicleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static CarrierShipmentPickupEndEvent convert(GenericEvent event) {
Id<Link> shipmentFrom = Id.createLinkId(attributes.get(ATTRIBUTE_LINK));
int shipmentSize = Integer.parseInt(attributes.get(ATTRIBUTE_CAPACITYDEMAND));
CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, shipmentFrom, null, shipmentSize)
.setPickupServiceTime(Double.parseDouble(attributes.get(ATTRIBUTE_PICKUP_DURATION)))
.setPickupDuration(Double.parseDouble(attributes.get(ATTRIBUTE_PICKUP_DURATION)))
.build();
Id<Vehicle> vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE));
return new CarrierShipmentPickupEndEvent(time, carrierId, shipment, vehicleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static CarrierShipmentPickupStartEvent convert(GenericEvent event) {
Id<Link> shipmentFrom = Id.createLinkId(attributes.get(ATTRIBUTE_LINK));
int shipmentSize = Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND));
CarrierShipment shipment = CarrierShipment.Builder.newInstance(shipmentId, shipmentFrom, null, shipmentSize)
.setPickupServiceTime(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_PICKUP_DURATION)))
.setPickupDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_PICKUP_DURATION)))
.build();
Id<Vehicle> vehicleId = Id.createVehicleId(attributes.get(ATTRIBUTE_VEHICLE));
return new CarrierShipmentPickupStartEvent(time, carrierId, shipment, vehicleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ static CarrierShipment createCarrierShipment(Shipment jspritShipment) {
.newInstance(Id.create(jspritShipment.getId(), CarrierShipment.class),
Id.createLinkId(jspritShipment.getPickupLocation().getId()),
Id.createLinkId(jspritShipment.getDeliveryLocation().getId()), jspritShipment.getSize().get(0))
.setDeliveryServiceTime(jspritShipment.getDeliveryServiceTime())
.setDeliveryTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getDeliveryTimeWindow().getStart(),
.setDeliveryDuration(jspritShipment.getDeliveryServiceTime())
.setDeliveryStartsTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getDeliveryTimeWindow().getStart(),
jspritShipment.getDeliveryTimeWindow().getEnd()))
.setPickupServiceTime(jspritShipment.getPickupServiceTime())
.setPickupTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getPickupTimeWindow().getStart(),
.setPickupDuration(jspritShipment.getPickupServiceTime())
.setPickupStartsTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getPickupTimeWindow().getStart(),
jspritShipment.getPickupTimeWindow().getEnd()))
.build();
CarriersUtils.setSkills(carrierShipment, jspritShipment.getRequiredSkills().values());
Expand Down Expand Up @@ -184,7 +184,7 @@ static Service createJspritService(CarrierService carrierService, Coord location
static CarrierService createCarrierService(Service jspritService) {
CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(
Id.create(jspritService.getId(), CarrierService.class), Id.create(jspritService.getLocation().getId(), Link.class));
serviceBuilder.setCapacityDemand(jspritService.getSize().get(0));
serviceBuilder.setDemand(jspritService.getSize().get(0));
serviceBuilder.setServiceDuration(jspritService.getServiceDuration());
serviceBuilder.setServiceStartTimeWindow(
org.matsim.freight.carriers.TimeWindow.newInstance(jspritService.getTimeWindow().getStart(), jspritService.getTimeWindow().getEnd()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static void createCustomers(Carrier carrier, Network network) {

for(int i=0;i<20;i++){
CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(Id.create((i + 1),CarrierService.class), drawLocationLinkId(innerCityLinks, outerCityLinks));
serviceBuilder.setCapacityDemand(1);
serviceBuilder.setDemand(1);
serviceBuilder.setServiceDuration(5*60);
serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(6*60*60, 15*60*60));
CarrierService carrierService = serviceBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) {
Id<CarrierService> serviceId = Id.create(lspShipment.getId().toString(), CarrierService.class);
CarrierService carrierService = CarrierService.Builder.newInstance(serviceId, lspShipment.getFrom())
.setServiceStartTimeWindow(TimeWindow.newInstance(lspShipment.getPickupTimeWindow().getStart(), lspShipment.getPickupTimeWindow().getEnd()))
.setCapacityDemand(lspShipment.getSize())
.setDemand(lspShipment.getSize())
.setServiceDuration(lspShipment.getDeliveryServiceTime())
.build();
//ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan
Expand Down
Loading

0 comments on commit 80cc5df

Please sign in to comment.