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

Remove dependeny to vsp contrib #328

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bcfb579
comment
kt86 Aug 21, 2024
17eee39
towards using shipments for the delivery carrier.
kt86 Aug 23, 2024
c95d985
not working now.. needs infrastructure for EventHandling..
kt86 Aug 23, 2024
bd80bfa
WIP commiting just to change the workspace..
kt86 Aug 30, 2024
6ddf8ea
renaming
kt86 Sep 2, 2024
6569879
pom to shnapshot
kt86 Sep 2, 2024
a13d2ec
Merge remote-tracking branch 'origin/main' into kmt_2echelon4Diss
kt86 Sep 3, 2024
b8a7fad
Merge branch 'kmt_2echelon4Diss' of github.com:matsim-vsp/logistics i…
kt86 Sep 5, 2024
e4b1748
Merge remote-tracking branch 'origin/main' into kmt_2echelon4Diss
kt86 Sep 17, 2024
5c7d593
Merge branch 'kmt_2echelon4Diss' of github.com:matsim-vsp/logistics i…
kt86 Sep 17, 2024
041eeb5
Merge remote-tracking branch 'origin/main' into kmt_2echelon4Diss
kt86 Sep 23, 2024
e042693
Merge remote-tracking branch 'origin/main' into kmt_2echelon4Diss
kt86 Oct 10, 2024
89283a3
some minor adaptions towards Shipment-based solving. some comments
kt86 Oct 10, 2024
c79b3f4
towards using instanceof
kainagel Oct 10, 2024
1ea559b
some more work, check that serviceBased still works
kt86 Oct 11, 2024
a087058
more forward
kt86 Oct 11, 2024
92b13f1
replace if by switch
kt86 Oct 11, 2024
f358399
implement ShipmentBased
kt86 Oct 11, 2024
04f95ee
extract method, comment
kt86 Oct 11, 2024
7082b91
move setting to config setup
kt86 Oct 11, 2024
23bd646
comments after Kai/Kai mtg
kt86 Nov 15, 2024
3f62ec4
Merge remote-tracking branch 'refs/remotes/origin/main' into kmt_2ech…
kt86 Nov 15, 2024
5bcdeaf
remove dependency to vsp contrib, as it is no longer needed
kt86 Nov 15, 2024
198861c
update import for annotation
kt86 Nov 15, 2024
aed7ada
remove NotNull annotation
kt86 Nov 15, 2024
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
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>vsp</artifactId>
<version>${project.parent.version}</version>
</dependency>

<!--MATSim examples. Not transitive -->
<dependency>
<groupId>org.matsim</groupId>
Expand Down
Empty file modified src/main/java/doxyfilter.sh
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions src/main/java/org/matsim/freight/logistics/LSPUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ public LogisticChainBuilder addTracker(LSPSimulationTracker<LogisticChain> track
}

public LogisticChain build() {
//TODO: Prüfe of das alle Elemente Verbunden sind (in irgendeiner Art). Plus Hinweis auf die Änderung.

return new LogisticChainImpl(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public static void main(String[] args) {
.controller()
.setOverwriteFileSetting(
OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
// The VSP default settings are designed for person transport simulation. After talking to Kai,
// they will be set to WARN here. Kai MT may'23
config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn);

var freightConfig = ConfigUtils.addOrGetModule(config, FreightCarriersConfigGroup.class);
freightConfig.setTimeWindowHandling(FreightCarriersConfigGroup.TimeWindowHandling.ignore);
Expand Down Expand Up @@ -170,12 +173,7 @@ public void install() {
});

log.info("Run MATSim");
// The VSP default settings are designed for person transport simulation. After talking to Kai,
// they will be set to WARN here. Kai MT may'23
controler
.getConfig()
.vspExperimental()
.setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn);

controler.run();

// print the schedules for the assigned LSPShipments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
Expand All @@ -71,6 +70,7 @@
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.logistics.*;
import org.matsim.freight.logistics.examples.ExampleConstants;
import org.matsim.freight.logistics.resourceImplementations.CarrierSchedulerUtils;
import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils;
import org.matsim.freight.logistics.shipment.LspShipment;
import org.matsim.vehicles.VehicleType;
Expand Down Expand Up @@ -132,17 +132,10 @@ public static void main(String[] args) {
lsps.add(createLspWithDirectChain(scenario, "Kaufland_DIRECT", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierKaufland), getDepotLinkFromVehicle(carrierKaufland), vehicleTypes));
LSPUtils.addLSPs(scenario, new LSPs(lsps));


Controler controler = prepareControler(scenario);

log.info("Run MATSim");

// The VSP default settings are designed for person transport simulation. After talking to Kai,
// they will be set to WARN here. Kai MT may'23
controler
.getConfig()
.vspExperimental()
.setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn);
controler.run();

runCarrierAnalysis(controler.getControlerIO().getOutputPath(), config);
Expand All @@ -167,13 +160,17 @@ private static Config prepareConfig(String[] args) {
config.global().setRandomSeed(4177);
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);

// The VSP default settings are designed for person transport simulation. After talking to Kai,
// they will be set to WARN here. Kai MT may'23
config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn);

FreightCarriersConfigGroup freightConfig = ConfigUtils.addOrGetModule(config, FreightCarriersConfigGroup.class);
freightConfig.setTimeWindowHandling(FreightCarriersConfigGroup.TimeWindowHandling.ignore);

return config;
}

private static @NotNull Controler prepareControler(Scenario scenario) {
private static Controler prepareControler(Scenario scenario) {
log.info("Prepare controler");
Controler controler = new Controler(scenario);
controler.addOverridingModule(
Expand Down Expand Up @@ -347,6 +344,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
.getCarrierCapabilities()
//.setNumberOfJspritIterations // TODO Das mal hier einbauen. --> Ist aktuell in CarrierUtils.
.setFleetSize(CarrierCapabilities.FleetSize.INFINITE);
CarrierSchedulerUtils.setVrpLogic(distributionCarrier, LSPUtils.LogicOfVrp.serviceBased);

CarriersUtils.addCarrierVehicle(
distributionCarrier,
Expand All @@ -371,6 +369,7 @@ private static LogisticChain createTwoEchelonChain(Scenario scenario, String lsp
mainCarrierElement.connectWithNextElement(hubElement);
hubElement.connectWithNextElement(distributionCarrierElement);

//TODO: Hier das Verbinden einfügen und in der Reihenfolge ist es. KMT Nov'24
hubChain =
LSPUtils.LogisticChainBuilder.newInstance(Id.create("hubChain", LogisticChain.class))
.addLogisticChainElement(mainCarrierElement)
Expand Down Expand Up @@ -421,6 +420,7 @@ private static LogisticChain createDirectChain(Scenario scenario, String lspName
LogisticChain directChain;
Carrier directCarrier = CarriersUtils.createCarrier(Id.create(lspName +"_directCarrier", Carrier.class));
directCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);
CarrierSchedulerUtils.setVrpLogic(directCarrier, LSPUtils.LogicOfVrp.serviceBased);

CarriersUtils.addCarrierVehicle(directCarrier,
CarrierVehicle.newInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.matsim.analysis.personMoney.PersonMoneyEventsAnalysisModule;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
Expand Down Expand Up @@ -159,7 +158,7 @@ private static Config prepareConfig(String[] args) {
return config;
}

private static @NotNull Controler prepareControler(Scenario scenario, RoadPricingScheme rpScheme) {
private static Controler prepareControler(Scenario scenario, RoadPricingScheme rpScheme) {
log.info("Prepare controler");
Controler controler = new Controler(scenario);
controler.addOverridingModule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class CarrierSchedulerUtils {
* @return Carrier with the solution of the VehicleRoutingProblem and the routed plan.
*/
public static Carrier solveVrpWithJsprit(Carrier carrier, Scenario scenario) {
// Maybe it make sense to store this object instead of rebuilding it for each carrier (in each iteration) ???
// pro: save computation time
// con: interdependencies, if something changes in the network (load), the object is not up-to-date & it is not clear, if the object is thread safe
// Decision for the time being: rebuild it for each carrier to have a clear state KMT/KN Aug'24
NetworkBasedTransportCosts netbasedTransportCosts;
Network network = scenario.getNetwork();
RoadPricingScheme roadPricingScheme = null;
Expand Down Expand Up @@ -127,10 +131,16 @@ public static void setVrpLogic(Carrier carrier, LSPUtils.LogicOfVrp logicOfVrp){
* This decides later, whether the VRP is build base on {@link org.matsim.freight.carriers.CarrierService}s or {@link org.matsim.freight.carriers.CarrierShipment}s.
*
* @param carrier The carrier for which the setting should be got.
* @return the logic of the VRP
* @return the logic of the VRP, returns {@link LSPUtils.LogicOfVrp#serviceBased} if not set.
*/
public static LSPUtils.LogicOfVrp getVrpLogic(Carrier carrier){
return (LSPUtils.LogicOfVrp) carrier.getAttributes().getAttribute(LOGIC_OF_VRP);
LSPUtils.LogicOfVrp result = (LSPUtils.LogicOfVrp) carrier.getAttributes().getAttribute(LOGIC_OF_VRP);
if (result == null){
log.error("VRPLogic not found for carrier {}. Will return {}", carrier.getId(), LSPUtils.LogicOfVrp.serviceBased);
return LSPUtils.LogicOfVrp.serviceBased;
} else {
return result ;
}
}

}
Loading