Skip to content

Commit

Permalink
todos, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Mar 10, 2025
1 parent 74b10a4 commit f4ca292
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.locationtech.jts.util.Assert;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.Tour.Leg;
Expand Down Expand Up @@ -219,19 +220,20 @@ private void scheduleCarrierBasedOnShipments(ArrayList<LspShipment> shipmentsToS
ccBuilder.setFleetSize(FleetSize.INFINITE);

//copy all vehicles from the original carrier to the auxiliary carrier.
var startTime = 0.0; //Todo set to something meaningful, e.g. arrivalTime of the first shipment.
var startTime = 0.0; //Todo: set to something meaningful, e.g. arrivalTime of the first shipment.
for (CarrierVehicle carrierVehicle : carrier.getCarrierCapabilities().getCarrierVehicles().values()) {
var cv = CarrierVehicle.Builder.newInstance(carrierVehicle.getId(), carrierVehicle.getLinkId(), carrierVehicle.getType())
.setEarliestStart(startTime)
.setLatestEnd(24 * 60 * 60)
.build();
ccBuilder.addVehicle(carrierVehicle);
ccBuilder.addVehicle(cv);
}

auxCarrier.setCarrierCapabilities(ccBuilder.build());

//add all shipments.
for (LspShipment lspShipment : shipmentsToSchedule) {
lspShipment.getShipmentLog().getMostRecentEntry(); // todo mal mit Debugger hier rein stellen
CarrierShipment carrierShipment = convertToCarrierShipment(lspShipment);
auxCarrier.getShipments().put(carrierShipment.getId(), carrierShipment);
}
Expand Down Expand Up @@ -273,7 +275,8 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) {
*/
private CarrierShipment convertToCarrierShipment(LspShipment lspShipment) {
Id<CarrierShipment> serviceId = Id.create(lspShipment.getId().toString(), CarrierShipment.class);
CarrierShipment carrierShipment = CarrierShipment.Builder.newInstance(serviceId, lspShipment.getFrom(), lspShipment.getTo(), lspShipment.getSize())
Id<Link> fromLinkId = lspShipment.getFrom(); //Todo: needs to be the hub, if there is one. KMT mar'25
CarrierShipment carrierShipment = CarrierShipment.Builder.newInstance(serviceId, fromLinkId, lspShipment.getTo(), lspShipment.getSize())
//TODO TimeWindows are not set. This seems to be a problem. KMT'Aug'24
//If added here, we also need to decide what happens, if the vehicles StartTime (plus TT) is > TimeWindowEnd ....
.setDeliveryDuration(lspShipment.getDeliveryServiceTime())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.logistics.*;
import org.matsim.freight.logistics.resourceImplementations.CarrierSchedulerUtils;
import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils;
import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TranshipmentHubSchedulerBuilder;
import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TransshipmentHubBuilder;
Expand Down Expand Up @@ -153,7 +154,6 @@ public void initialize() {
secondHubElementBuilder.setResource(secondTransshipmentHubBuilder.build());
LogisticChainElement secondHubElement = secondHubElementBuilder.build();

Id<Carrier> distributionCarrierId = Id.create("DistributionCarrier", Carrier.class);
Id<VehicleType> distributionVehTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class);
org.matsim.vehicles.VehicleType distributionVehType = VehicleUtils.createVehicleType(distributionVehTypeId, TransportMode.car);
distributionVehType.getCapacity().setOther(10);
Expand All @@ -170,8 +170,10 @@ public void initialize() {
capabilitiesBuilder.addVehicle(distributionCarrierVehicle);
capabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build();
Carrier carrier = CarriersUtils.createCarrier(distributionCarrierId);

Carrier carrier = CarriersUtils.createCarrier(Id.create("DistributionCarrier", Carrier.class));
carrier.setCarrierCapabilities(distributionCapabilities);
CarrierSchedulerUtils.setVrpLogic(carrier, LSPUtils.LogicOfVrp.serviceBased);


final LSPResource distributionCarrierResource = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrier)
Expand Down

0 comments on commit f4ca292

Please sign in to comment.