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

Renamings; small step forward for VrPLogic #292

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -35,22 +35,6 @@ public class FreightLogisticsConfigGroup extends ReflectiveConfigGroup {
static final String LSPS_FILE = "lspsFile";
private static final String LSPS_FILE_DESC = "Freight LogisticsServiceProviders (LSP)s File, according to MATSim logistics extension as part of MATSim's freight contrib.";


public enum LogicOfVrp {serviceBased, shipmentBased}

static final String VRP_LOGIC_OF_DISTRIBUTION_CARRIER = "vrpLogicOfDistributionCarrier";
private LogicOfVrp vrpLogicOfDistributionCarrier = LogicOfVrp.serviceBased;
private static final String VRP_LOGIC_OF_DISTRIBUTION_CARRIER_DESC = "Define, on which type of jobs the VRP of the **distribution** carrier will base on:" + Arrays.toString(LogicOfVrp.values());

static final String VRP_LOGIC_OF_MAINRUN_CARRIER = "vrpLogicOfMainRunCarrier";
private LogicOfVrp vrpLogicOfMainRunCarrier = LogicOfVrp.serviceBased;
private static final String VRP_LOGIC_OF_MAINRUN_CARRIER_DESC = "Define, on which type of jobs the VRP of the **MainRun** carrier will base on:" + Arrays.toString(LogicOfVrp.values());

static final String VRP_LOGIC_OF_COLLECTION_CARRIER = "vrpLogicOfCollectionCarrier";
private LogicOfVrp vrpLogicOfCollectionCarrier = LogicOfVrp.serviceBased;
private static final String VRP_LOGIC_OF_COLLECTION_CARRIER_DESC = "Define, on which type of jobs the VRP of the **Collection** carrier will base on:" + Arrays.toString(LogicOfVrp.values());


public FreightLogisticsConfigGroup() {
super(GROUPNAME);
}
Expand Down Expand Up @@ -79,66 +63,80 @@ public void setLspsFile(String lspsFile) {


//---
// Commenting this out, because in a frist step I think it is better/ more streight forward to have the VRP logic in the carriers as an attribute.
// please see {@link CarrierSchedulerUtils#setVrpLogic(carrier, VRPLogic)} and {@link CarrierSchedulerUtils#getVrpLogic(carrier)}
//---

/**
*
* @return The internal type of jobs, on which the VRPs of the distribution carrier bases on.
*/
@StringGetter(VRP_LOGIC_OF_DISTRIBUTION_CARRIER)
public LogicOfVrp getVrpLogicOfDistributionCarrier() {
return vrpLogicOfDistributionCarrier;
}

/**
* @param vrpLogicOfDistributionCarrier {@value #VRP_LOGIC_OF_DISTRIBUTION_CARRIER}
*/
@StringSetter(VRP_LOGIC_OF_DISTRIBUTION_CARRIER)
public void setVrpLogicOfDistributionCarrier(LogicOfVrp vrpLogicOfDistributionCarrier) {
this.vrpLogicOfDistributionCarrier = vrpLogicOfDistributionCarrier;
}

/**
* @return The internal type of jobs, on which the VRPs of the main run carrier bases on.
*/
@StringGetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_MAINRUN_CARRIER)
public LogicOfVrp getVrpLogicOfMainRunCarrier() {
return vrpLogicOfMainRunCarrier;
}

/**
* @param vrpLogicOfMainRunCarrier {@value #VRP_LOGIC_OF_MAINRUN_CARRIER}
*/
@StringSetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_MAINRUN_CARRIER)
public void setVrpLogicOfMainRunCarrier(LogicOfVrp vrpLogicOfMainRunCarrier) {
this.vrpLogicOfMainRunCarrier = vrpLogicOfMainRunCarrier;
}

/**
* @return The internal type of jobs, on which the VRPs of the collection carrier bases on.
*/
@StringGetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_COLLECTION_CARRIER)
public LogicOfVrp getVrpLogicOfCollectionCarrier() {
return vrpLogicOfCollectionCarrier;
}

/**
* @param vrpLogicOfCollectionCarrier {@value #VRP_LOGIC_OF_COLLECTION_CARRIER}
*/
@StringSetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_COLLECTION_CARRIER)
public void setVrpLogicOfCollectionCarrier(LogicOfVrp vrpLogicOfCollectionCarrier) {
this.vrpLogicOfCollectionCarrier = vrpLogicOfCollectionCarrier;
}
// static final String VRP_LOGIC_OF_DISTRIBUTION_CARRIER = "vrpLogicOfDistributionCarrier";
// private LSPUtils.LogicOfVrp vrpLogicOfDistributionCarrier = LSPUtils.LogicOfVrp.serviceBased;
// private static final String VRP_LOGIC_OF_DISTRIBUTION_CARRIER_DESC = "Define, on which type of jobs the VRP of the **distribution** carrier will base on:" + Arrays.toString(LSPUtils.LogicOfVrp.values());
//
// static final String VRP_LOGIC_OF_MAINRUN_CARRIER = "vrpLogicOfMainRunCarrier";
// private LSPUtils.LogicOfVrp vrpLogicOfMainRunCarrier = LSPUtils.LogicOfVrp.serviceBased;
// private static final String VRP_LOGIC_OF_MAINRUN_CARRIER_DESC = "Define, on which type of jobs the VRP of the **MainRun** carrier will base on:" + Arrays.toString(LSPUtils.LogicOfVrp.values());
//
// static final String VRP_LOGIC_OF_COLLECTION_CARRIER = "vrpLogicOfCollectionCarrier";
// private LSPUtils.LogicOfVrp vrpLogicOfCollectionCarrier = LSPUtils.LogicOfVrp.serviceBased;
// private static final String VRP_LOGIC_OF_COLLECTION_CARRIER_DESC = "Define, on which type of jobs the VRP of the **Collection** carrier will base on:" + Arrays.toString(LSPUtils.LogicOfVrp.values());
//
// /**
// *
// * @return The internal type of jobs, on which the VRPs of the distribution carrier bases on.
// */
// @StringGetter(VRP_LOGIC_OF_DISTRIBUTION_CARRIER)
// public LSPUtils.LogicOfVrp getVrpLogicOfDistributionCarrier() {
// return vrpLogicOfDistributionCarrier;
// }
//
// /**
// * @param vrpLogicOfDistributionCarrier {@value #VRP_LOGIC_OF_DISTRIBUTION_CARRIER}
// */
// @StringSetter(VRP_LOGIC_OF_DISTRIBUTION_CARRIER)
// public void setVrpLogicOfDistributionCarrier(LSPUtils.LogicOfVrp vrpLogicOfDistributionCarrier) {
// this.vrpLogicOfDistributionCarrier = vrpLogicOfDistributionCarrier;
// }
//
// /**
// * @return The internal type of jobs, on which the VRPs of the main run carrier bases on.
// */
// @StringGetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_MAINRUN_CARRIER)
// public LSPUtils.LogicOfVrp getVrpLogicOfMainRunCarrier() {
// return vrpLogicOfMainRunCarrier;
// }
//
// /**
// * @param vrpLogicOfMainRunCarrier {@value #VRP_LOGIC_OF_MAINRUN_CARRIER}
// */
// @StringSetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_MAINRUN_CARRIER)
// public void setVrpLogicOfMainRunCarrier(LSPUtils.LogicOfVrp vrpLogicOfMainRunCarrier) {
// this.vrpLogicOfMainRunCarrier = vrpLogicOfMainRunCarrier;
// }
//
// /**
// * @return The internal type of jobs, on which the VRPs of the collection carrier bases on.
// */
// @StringGetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_COLLECTION_CARRIER)
// public LSPUtils.LogicOfVrp getVrpLogicOfCollectionCarrier() {
// return vrpLogicOfCollectionCarrier;
// }
//
// /**
// * @param vrpLogicOfCollectionCarrier {@value #VRP_LOGIC_OF_COLLECTION_CARRIER}
// */
// @StringSetter(FreightLogisticsConfigGroup.VRP_LOGIC_OF_COLLECTION_CARRIER)
// public void setVrpLogicOfCollectionCarrier(LSPUtils.LogicOfVrp vrpLogicOfCollectionCarrier) {
// this.vrpLogicOfCollectionCarrier = vrpLogicOfCollectionCarrier;
// }

//---
//---
@Override
public Map<String, String> getComments() {
Map<String, String> map = super.getComments();
map.put(LSPS_FILE, LSPS_FILE_DESC);
map.put(VRP_LOGIC_OF_DISTRIBUTION_CARRIER, VRP_LOGIC_OF_DISTRIBUTION_CARRIER_DESC);
map.put(VRP_LOGIC_OF_MAINRUN_CARRIER, VRP_LOGIC_OF_MAINRUN_CARRIER_DESC);
map.put(VRP_LOGIC_OF_COLLECTION_CARRIER, VRP_LOGIC_OF_COLLECTION_CARRIER_DESC);
// map.put(VRP_LOGIC_OF_DISTRIBUTION_CARRIER, VRP_LOGIC_OF_DISTRIBUTION_CARRIER_DESC);
// map.put(VRP_LOGIC_OF_MAINRUN_CARRIER, VRP_LOGIC_OF_MAINRUN_CARRIER_DESC);
// map.put(VRP_LOGIC_OF_COLLECTION_CARRIER, VRP_LOGIC_OF_COLLECTION_CARRIER_DESC);
return map;
}

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
Loading
Loading