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

Commit

Permalink
rename classes and interfaces to indicate that it deals with LspShipm…
Browse files Browse the repository at this point in the history
…ents and avoid confusions with CarrierShipments
  • Loading branch information
kt86 committed Aug 13, 2024
1 parent 7734b36 commit 4a9c897
Show file tree
Hide file tree
Showing 125 changed files with 1,202 additions and 1,201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.util.ArrayList;
import org.matsim.api.core.v01.Id;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

/**
* .... Macht 3 Schritte: 1.) the LSPShipments are handed over to the first {@link
Expand Down Expand Up @@ -131,7 +131,7 @@ private void insertShipmentsAtBeginning() {
for (LogisticChain solution : lsp.getSelectedPlan().getLogisticChains()) {
LogisticChainElement firstElement = getFirstElement(solution);
assert firstElement != null;
for (Id<LSPShipment> lspShipmentId : solution.getLspShipmentIds()) {
for (Id<LspShipment> lspShipmentId : solution.getLspShipmentIds()) {
var shipment = LSPUtils.findLspShipment(lsp, lspShipmentId);
assert shipment != null;
firstElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.matsim.freight.logistics;

import org.matsim.api.core.v01.Id;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

/**
* @author Kai Martins-Turner (kturner)
Expand All @@ -28,5 +28,5 @@ public interface HasLspShipmentId {

String ATTRIBUTE_LSP_SHIPMENT_ID = "lspShipmentId";

Id<LSPShipment> getLspShipmentId();
Id<LspShipment> getLspShipmentId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@

package org.matsim.freight.logistics;

import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

/**
* Takes an {@link LSPShipment} and normally assigns it to something that belongs to an {@link LSP}.
* Takes an {@link LspShipment} and normally assigns it to something that belongs to an {@link LSP}.
* <br>
* After changes in fall 2023 (see master thesis of nrichter), the assingment is
* there to be done one time initially.
* <br>
* If there are several {@link LogisticChain}s in a {@link LSPPlan}, the {@link LSP} has to assign each {@link
* LSPShipment} to the suitable {@link LogisticChain}. For this purpose, each {@link LSPPlan}
* LspShipment} to the suitable {@link LogisticChain}. For this purpose, each {@link LSPPlan}
* (or only the LSP? - kmt'jan'24), contains a pluggable strategy
* that is contained in classes implementing the interface {@link InitialShipmentAssigner}. <br>
* <br>
* During iterations, it can happen that the {@link LSPShipment} should be moved to another
* During iterations, it can happen that the {@link LspShipment} should be moved to another
* {@link LogisticChain} of the same {@link LSPPlan}. This is now (since fall 2023; see master
* thesis of nrichter) part of the (innovative) **Replanning** strategies.
*/
public interface InitialShipmentAssigner {

void assignToPlan(LSPPlan lspPlan, LSPShipment lspShipment);
void assignToPlan(LSPPlan lspPlan, LspShipment lspShipment);
}
8 changes: 4 additions & 4 deletions src/main/java/org/matsim/freight/logistics/LSP.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@

import java.util.Collection;
import org.matsim.api.core.v01.population.HasPlansAndId;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

/**
* In the class library, the interface LSP has the following tasks: 1. Maintain one or several
* transport chains through which {@link LSPShipment}s are routed. 2. Assign {@link LSPShipment}s to
* transport chains through which {@link LspShipment}s are routed. 2. Assign {@link LspShipment}s to
* the suitable transport chain. --> {@link InitialShipmentAssigner}. 3. Interact with the agents that
* embody the demand side of the freight transport market, if they are specified in the setting. 4.
* Coordinate carriers that are in charge of the physical transport.
*/
public interface LSP extends HasPlansAndId<LSPPlan, LSP>, HasSimulationTrackers<LSP> {

/** yyyy does this have to be exposed? */
Collection<LSPShipment> getLspShipments();
Collection<LspShipment> getLspShipments();

/** ok (behavioral method) */
void scheduleLogisticChains();
Expand All @@ -48,6 +48,6 @@ public interface LSP extends HasPlansAndId<LSPPlan, LSP>, HasSimulationTrackers<
/**
* @param lspShipment ok (LSP needs to be told that it is responsible for lspShipment)
*/
void assignShipmentToLSP(LSPShipment lspShipment);
void assignShipmentToLSP(LspShipment lspShipment);

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.controler.CarrierAgentTracker;
import org.matsim.freight.logistics.io.LSPPlanXmlWriter;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

class LSPControlerListener
implements StartupListener,
Expand Down Expand Up @@ -134,7 +134,7 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) {
}

// simulation trackers of shipments:
for (LSPShipment lspShipment : lsp.getLspShipments()) {
for (LspShipment lspShipment : lsp.getLspShipments()) {
registerSimulationTrackers(lspShipment);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/matsim/freight/logistics/LSPImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

/* package-private */ class LSPImpl extends LSPDataObject<LSP> implements LSP {
private static final Logger log = LogManager.getLogger(LSPImpl.class);

private final Collection<LSPShipment> lspShipments;
private final Collection<LspShipment> lspShipments;
private final ArrayList<LSPPlan> lspPlans;
private final LogisticChainScheduler logisticChainScheduler;
private final Collection<LSPResource> resources;
Expand Down Expand Up @@ -147,7 +147,7 @@ public void scoreSelectedPlan() {
}

@Override
public void assignShipmentToLSP(LSPShipment lspShipment) {
public void assignShipmentToLSP(LspShipment lspShipment) {
// shipment.setLspId(this.getId()); // und rückweg dann auch darüber und dann
// lsp.getselectedPlan.getShipment...
lspShipments.add(lspShipment);
Expand All @@ -157,7 +157,7 @@ public void assignShipmentToLSP(LSPShipment lspShipment) {
}

@Override
public Collection<LSPShipment> getLspShipments() {
public Collection<LspShipment> getLspShipments() {
return this.lspShipments;
}
}
10 changes: 5 additions & 5 deletions src/main/java/org/matsim/freight/logistics/LSPPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

import java.util.Collection;
import org.matsim.api.core.v01.population.BasicPlan;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.ShipmentPlan;
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentPlan;

/**
* This interface has the following properties:
*
* <ul>
* <li>As a {@link BasicPlan} it has a score, so it can be used for evolutionary learning. kai,
* may'22
* <li>An {@link LSPShipment} is added via lspPlan#getAssigner().assignToSolution(shipment). The
* <li>An {@link LspShipment} is added via lspPlan#getAssigner().assignToSolution(shipment). The
* {@link InitialShipmentAssigner} assigns it deterministically to a {@link LogisticChain}.
* </ul>
*/
Expand All @@ -49,9 +49,9 @@ public interface LSPPlan extends BasicPlan, KnowsLSP {

LSPPlan setInitialShipmentAssigner(InitialShipmentAssigner assigner);

Collection<ShipmentPlan> getShipmentPlans();
Collection<LspShipmentPlan> getShipmentPlans();

LSPPlan addShipmentPlan(ShipmentPlan shipmentPlan);
LSPPlan addShipmentPlan(LspShipmentPlan lspShipmentPlan);

String getType();

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/matsim/freight/logistics/LSPPlanImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@

import java.util.ArrayList;
import java.util.Collection;
import org.matsim.freight.logistics.shipment.ShipmentPlan;
import org.matsim.freight.logistics.shipment.LspShipmentPlan;

public class LSPPlanImpl implements LSPPlan {

private final Collection<LogisticChain> logisticChains;
private final Collection<ShipmentPlan> shipmentPlans;
private final Collection<LspShipmentPlan> lspShipmentPlans;
private LSP lsp;
private Double score = null;
private InitialShipmentAssigner assigner;
private String type = null;

public LSPPlanImpl() {
this.logisticChains = new ArrayList<>();
this.shipmentPlans = new ArrayList<>();
this.lspShipmentPlans = new ArrayList<>();
}

@Override
Expand All @@ -62,13 +62,13 @@ public LSPPlan setInitialShipmentAssigner(InitialShipmentAssigner assigner) {
}

@Override
public Collection<ShipmentPlan> getShipmentPlans() {
return this.shipmentPlans;
public Collection<LspShipmentPlan> getShipmentPlans() {
return this.lspShipmentPlans;
}

@Override
public LSPPlan addShipmentPlan(ShipmentPlan shipmentPlan) {
this.shipmentPlans.add(shipmentPlan);
public LSPPlan addShipmentPlan(LspShipmentPlan lspShipmentPlan) {
this.lspShipmentPlans.add(lspShipmentPlan);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

import java.util.ArrayList;
import java.util.Comparator;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.ShipmentUtils;
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentUtils;

/**
* Resources are scheduled separately by calling their individual scheduling algorithm.
Expand Down Expand Up @@ -71,9 +71,9 @@ public final void scheduleShipments(LSPPlan lspPlan, LSPResource resource, int b
protected abstract void scheduleResource();

/**
* Endows the involved {@link LSPShipment}s with information that resulted from the scheduling in
* Endows the involved {@link LspShipment}s with information that resulted from the scheduling in
* a narrow sense in scheduleResource(). The information can be divided into two main components.
* 1.) the schedule of the {@link LSPShipment}s is updated if necessary 2.) the information for a
* 1.) the schedule of the {@link LspShipment}s is updated if necessary 2.) the information for a
* later logging of the is added.
*/
protected abstract void updateShipments();
Expand All @@ -89,7 +89,7 @@ private void presortIncomingShipments() {
private void switchHandledShipments(int bufferTime) {
for (LspShipmentWithTime lspShipmentWithTime : lspShipmentsWithTime) {
var shipmentPlan =
ShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getLspShipment().getId());
LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getLspShipment().getId());
double endOfTransportTime = shipmentPlan.getMostRecentEntry().getEndTime() + bufferTime;
LspShipmentWithTime outgoingTuple =
new LspShipmentWithTime(endOfTransportTime, lspShipmentWithTime.getLspShipment());
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/matsim/freight/logistics/LSPUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.freight.carriers.Carriers;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.ShipmentPlan;
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.freight.logistics.shipment.LspShipmentPlan;
import org.matsim.utils.objectattributes.attributable.Attributable;

public final class LSPUtils {
Expand Down Expand Up @@ -113,14 +113,14 @@ public static void setFixedCost(Attributable attributable, Double fixedCost) {
}

/**
* Gives back the {@link LSPShipment} object of the {@link LSP}, which matches to the shipmentId
* Gives back the {@link LspShipment} object of the {@link LSP}, which matches to the shipmentId
*
* @param lsp In this LSP this method tries to find the shipment.
* @param shipmentId Id of the shipment that should be found.
* @return the lspShipment object or null, if it is not found.
*/
public static LSPShipment findLspShipment(LSP lsp, Id<LSPShipment> shipmentId) {
for (LSPShipment lspShipment : lsp.getLspShipments()) {
public static LspShipment findLspShipment(LSP lsp, Id<LspShipment> shipmentId) {
for (LspShipment lspShipment : lsp.getLspShipments()) {
if (lspShipment.getId().equals(shipmentId)) {
return lspShipment;
}
Expand All @@ -129,16 +129,16 @@ public static LSPShipment findLspShipment(LSP lsp, Id<LSPShipment> shipmentId) {
}

/**
* Returns the {@link ShipmentPlan} of an {@link LSPShipment}.
* Returns the {@link LspShipmentPlan} of an {@link LspShipment}.
*
* @param lspPlan the lspPlan: It contains the information of its shipmentPlans
* @param shipmentId Id of the shipment that should be found.
* @return the shipmentPlan object or null, if it is not found.
*/
public static ShipmentPlan findLspShipmentPlan(LSPPlan lspPlan, Id<LSPShipment> shipmentId) {
for (ShipmentPlan shipmentPlan : lspPlan.getShipmentPlans()) {
if (shipmentPlan.getLspShipmentId().equals(shipmentId)) {
return shipmentPlan;
public static LspShipmentPlan findLspShipmentPlan(LSPPlan lspPlan, Id<LspShipment> shipmentId) {
for (LspShipmentPlan lspShipmentPlan : lspPlan.getShipmentPlans()) {
if (lspShipmentPlan.getLspShipmentId().equals(shipmentId)) {
return lspShipmentPlan;
}
}
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/matsim/freight/logistics/LogisticChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Collection;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Identifiable;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.utils.objectattributes.attributable.Attributable;

/**
Expand All @@ -42,7 +42,7 @@ public interface LogisticChain

Collection<LogisticChainElement> getLogisticChainElements();

Collection<Id<LSPShipment>> getLspShipmentIds();
Collection<Id<LspShipment>> getLspShipmentIds();

void addShipmentToChain(LSPShipment lspShipment);
void addShipmentToChain(LspShipment lspShipment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.freight.logistics.shipment.LSPShipment;
import org.matsim.freight.logistics.shipment.LspShipment;

/* package-private */ class LogisticChainImpl extends LSPDataObject<LogisticChain>
implements LogisticChain {
private static final Logger log = LogManager.getLogger(LogisticChainImpl.class);

private final Collection<LogisticChainElement> logisticChainElements;
private final Collection<Id<LSPShipment>> lspShipmentIds;
private final Collection<Id<LspShipment>> lspShipmentIds;
private LSP lsp;

LogisticChainImpl(LSPUtils.LogisticChainBuilder builder) {
Expand Down Expand Up @@ -60,12 +60,12 @@ public Collection<LogisticChainElement> getLogisticChainElements() {
}

@Override
public Collection<Id<LSPShipment>> getLspShipmentIds() {
public Collection<Id<LspShipment>> getLspShipmentIds() {
return lspShipmentIds;
}

@Override
public void addShipmentToChain(LSPShipment lspShipment) {
public void addShipmentToChain(LspShipment lspShipment) {
lspShipmentIds.add(lspShipment.getId());
}

Expand All @@ -86,7 +86,7 @@ public String toString() {
strb.append("[No of Shipments=").append(lspShipmentIds.size()).append("] \n");
if (!lspShipmentIds.isEmpty()) {
strb.append("{ShipmentIds=");
for (Id<LSPShipment> lspShipmentId : lspShipmentIds) {
for (Id<LspShipment> lspShipmentId : lspShipmentIds) {
strb.append("[").append(lspShipmentId.toString()).append("]");
}
strb.append("}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

package org.matsim.freight.logistics;

import org.matsim.freight.logistics.shipment.LspShipment;

/**
* Serve the purpose of routing a set of {@link org.matsim.freight.logistics.shipment.LSPShipment}s
* Serve the purpose of routing a set of {@link LspShipment}s
* through a set of {@link LogisticChain}s, which, in turn, consist of several {@link
* LogisticChainElement}s and the corresponding {@link LSPResource}s.
*/
Expand Down
Loading

0 comments on commit 4a9c897

Please sign in to comment.