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

Commit

Permalink
move stuff from carriers.carrier package one level up
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Oct 12, 2023
1 parent b19e2c8 commit 733bf0f
Show file tree
Hide file tree
Showing 107 changed files with 369 additions and 409 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import org.matsim.core.config.Config;
import org.matsim.core.network.io.MatsimNetworkReader;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -68,7 +68,7 @@ private static LSP createInitialLSP(Network network) {
capabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities capabilities = capabilitiesBuilder.build();

Carrier carrier = CarrierUtils.createCarrier(carrierId);
Carrier carrier = CarriersUtils.createCarrier(carrierId);
carrier.setCarrierCapabilities(capabilities);

//The Resource i.e. the Resource is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import org.matsim.core.config.Config;
import org.matsim.core.network.io.MatsimNetworkReader;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -77,7 +77,7 @@ private static LSP createInitialLSP(Scenario scenario) {
capabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities capabilities = capabilitiesBuilder.build();

Carrier collectionCarrier = CarrierUtils.createCarrier(collectionCarrierId);
Carrier collectionCarrier = CarriersUtils.createCarrier(collectionCarrierId);
collectionCarrier.setCarrierCapabilities(capabilities);

//The collection adapter i.e. the Resource is created
Expand Down Expand Up @@ -134,7 +134,7 @@ private static LSP createInitialLSP(Scenario scenario) {
.addVehicle(mainRunCarrierVehicle)
.setFleetSize(FleetSize.INFINITE)
.build();
Carrier mainRunCarrier = CarrierUtils.createCarrier(mainRunCarrierId);
Carrier mainRunCarrier = CarriersUtils.createCarrier(mainRunCarrierId);
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);

//The adapter i.e. the main run resource is created
Expand Down Expand Up @@ -191,7 +191,7 @@ private static LSP createInitialLSP(Scenario scenario) {
distributionCapabilitiesBuilder.addVehicle(distributionCarrierVehicle);
distributionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities distributionCapabilities = distributionCapabilitiesBuilder.build();
Carrier distributionCarrier = CarrierUtils.createCarrier(distributionCarrierId);
Carrier distributionCarrier = CarriersUtils.createCarrier(distributionCarrierId);
distributionCarrier.setCarrierCapabilities(distributionCapabilities);

//The distribution adapter i.e. the Resource is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
import org.matsim.core.replanning.GenericPlanStrategyImpl;
import org.matsim.core.replanning.selectors.RandomPlanSelector;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.events.CarrierServiceEndEvent;
Expand Down Expand Up @@ -217,7 +216,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType

log.info("");
log.info("The Carrier for the main run is created");
Carrier mainRunCarrier = CarrierUtils.createCarrier(Id.create("MainRunCarrier", Carrier.class));
Carrier mainRunCarrier = CarriersUtils.createCarrier(Id.create("MainRunCarrier", Carrier.class));

VehicleType mainRunVehicleType = CarrierVehicleType.Builder.newInstance(Id.create("MainRunCarrierVehicleType", VehicleType.class))
.setCapacity(30)
Expand Down Expand Up @@ -280,7 +279,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType

CarrierVehicle distributionCarrierVehicle = CarrierVehicle.Builder.newInstance(Id.createVehicleId("DistributionVehicle"), hubLinkId, distributionVehicleType).build();

Carrier distributionCarrier = CarrierUtils.createCarrier(Id.create("DistributionCarrier", Carrier.class));
Carrier distributionCarrier = CarriersUtils.createCarrier(Id.create("DistributionCarrier", Carrier.class));
distributionCarrier.setCarrierCapabilities(
CarrierCapabilities.Builder.newInstance()
.addType(distributionVehicleType)
Expand Down Expand Up @@ -319,7 +318,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType
.addVehicle(directDistributionCarrierVehicle)
.setFleetSize(FleetSize.INFINITE)
.build();
Carrier directDistributionCarrier = CarrierUtils.createCarrier(Id.create("DirectDistributionCarrier", Carrier.class));
Carrier directDistributionCarrier = CarriersUtils.createCarrier(Id.create("DirectDistributionCarrier", Carrier.class));
directDistributionCarrier.setCarrierCapabilities(directDistributionCarrierCapabilities);

//The distribution adapter i.e. the Resource is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
Expand Down Expand Up @@ -212,10 +211,10 @@ private static LSP createLSP(Scenario scenario) {
{
log.info("Create lspPlan for direct delivery");

Carrier directCarrier = CarrierUtils.createCarrier(Id.create("directCarrier", Carrier.class));
Carrier directCarrier = CarriersUtils.createCarrier(Id.create("directCarrier", Carrier.class));
directCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarrierUtils.addCarrierVehicle(directCarrier, CarrierVehicle.newInstance(Id.createVehicleId("directTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
CarriersUtils.addCarrierVehicle(directCarrier, CarrierVehicle.newInstance(Id.createVehicleId("directTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource directCarrierRessource = DistributionCarrierUtils.DistributionCarrierResourceBuilder.newInstance(directCarrier, network)
.setDistributionScheduler(DistributionCarrierUtils.createDefaultDistributionCarrierScheduler())
.build();
Expand All @@ -239,10 +238,10 @@ private static LSP createLSP(Scenario scenario) {
{
log.info("Create lspPlan with Hub");

Carrier mainCarrier = CarrierUtils.createCarrier(Id.create("mainCarrier", Carrier.class));
Carrier mainCarrier = CarriersUtils.createCarrier(Id.create("mainCarrier", Carrier.class));
mainCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarrierUtils.addCarrierVehicle(mainCarrier, CarrierVehicle.newInstance(Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
CarriersUtils.addCarrierVehicle(mainCarrier, CarrierVehicle.newInstance(Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierRessource = MainRunCarrierUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier, network)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(MainRunCarrierUtils.createDefaultMainRunCarrierScheduler())
Expand Down Expand Up @@ -270,7 +269,7 @@ private static LSP createLSP(Scenario scenario) {
.setResource(hubResource)
.build(); //Nicht unbedingt nötig, aber nehme den alten Hub nun als Depot. Waren werden dann dort "Zusammengestellt".

Carrier distributionCarrier = CarrierUtils.createCarrier(Id.create("distributionCarrier", Carrier.class));
Carrier distributionCarrier = CarriersUtils.createCarrier(Id.create("distributionCarrier", Carrier.class));
distributionCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

final VehicleType vehType;
Expand All @@ -279,7 +278,7 @@ private static LSP createLSP(Scenario scenario) {
case lowerCost4LastMile -> vehType = VEH_TYPE_SMALL_05;
default -> throw new IllegalStateException("Unexpected value: " + costSetting);
}
CarrierUtils.addCarrierVehicle(distributionCarrier, CarrierVehicle.newInstance(Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
CarriersUtils.addCarrierVehicle(distributionCarrier, CarrierVehicle.newInstance(Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
LSPResource distributionCarrierRessource = DistributionCarrierUtils.DistributionCarrierResourceBuilder.newInstance(distributionCarrier, network)
.setDistributionScheduler(DistributionCarrierUtils.createDefaultDistributionCarrierScheduler())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
Expand Down Expand Up @@ -157,8 +156,8 @@ public void install() {

//Ggf. muss der Ordner noch erstellt werden (?)
new LSPPlanXmlWriter(LSPUtils.getLSPs(controler.getScenario())).write(controler.getConfig().controller().getOutputDirectory() + "/lsps.xml");
new LSPPlanXmlReader(LSPUtils.getLSPs(controler.getScenario()), CarrierUtils.getCarriers(controler.getScenario()));
new CarrierPlanWriter(CarrierUtils.getCarriers(controler.getScenario())).write(controler.getConfig().controller().getOutputDirectory() + "/carriers.xml");
new LSPPlanXmlReader(LSPUtils.getLSPs(controler.getScenario()), CarriersUtils.getCarriers(controler.getScenario()));
new CarrierPlanWriter(CarriersUtils.getCarriers(controler.getScenario())).write(controler.getConfig().controller().getOutputDirectory() + "/carriers.xml");

log.info("Some results ....");

Expand Down Expand Up @@ -218,10 +217,10 @@ private static LSP createLSP(Scenario scenario) {
{
log.info("Create lspPlan for direct delivery");

Carrier directCarrier = CarrierUtils.createCarrier(Id.create("directCarrier", Carrier.class));
Carrier directCarrier = CarriersUtils.createCarrier(Id.create("directCarrier", Carrier.class));
directCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarrierUtils.addCarrierVehicle(directCarrier, CarrierVehicle.newInstance(Id.createVehicleId("directTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
CarriersUtils.addCarrierVehicle(directCarrier, CarrierVehicle.newInstance(Id.createVehicleId("directTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource directCarrierRessource = DistributionCarrierUtils.DistributionCarrierResourceBuilder.newInstance(directCarrier, network)
.setDistributionScheduler(DistributionCarrierUtils.createDefaultDistributionCarrierScheduler())
.build();
Expand All @@ -245,10 +244,10 @@ private static LSP createLSP(Scenario scenario) {
{
log.info("Create lspPlan with Hub");

Carrier mainCarrier = CarrierUtils.createCarrier(Id.create("mainCarrier", Carrier.class));
Carrier mainCarrier = CarriersUtils.createCarrier(Id.create("mainCarrier", Carrier.class));
mainCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

CarrierUtils.addCarrierVehicle(mainCarrier, CarrierVehicle.newInstance(Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
CarriersUtils.addCarrierVehicle(mainCarrier, CarrierVehicle.newInstance(Id.createVehicleId("mainTruck"), DEPOT_LINK_ID, VEH_TYPE_LARGE_50));
LSPResource mainCarrierRessource = MainRunCarrierUtils.MainRunCarrierResourceBuilder.newInstance(mainCarrier, network)
.setFromLinkId(DEPOT_LINK_ID)
.setMainRunCarrierScheduler(MainRunCarrierUtils.createDefaultMainRunCarrierScheduler())
Expand Down Expand Up @@ -276,7 +275,7 @@ private static LSP createLSP(Scenario scenario) {
.setResource(hubResource)
.build(); //Nicht unbedingt nötig, aber nehme den alten Hub nun als Depot. Waren werden dann dort "Zusammengestellt".

Carrier distributionCarrier = CarrierUtils.createCarrier(Id.create("distributionCarrier", Carrier.class));
Carrier distributionCarrier = CarriersUtils.createCarrier(Id.create("distributionCarrier", Carrier.class));
distributionCarrier.getCarrierCapabilities().setFleetSize(CarrierCapabilities.FleetSize.INFINITE);

final VehicleType vehType;
Expand All @@ -285,7 +284,7 @@ private static LSP createLSP(Scenario scenario) {
case lowerCost4LastMile -> vehType = VEH_TYPE_SMALL_05;
default -> throw new IllegalStateException("Unexpected value: " + costSetting);
}
CarrierUtils.addCarrierVehicle(distributionCarrier, CarrierVehicle.newInstance(Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
CarriersUtils.addCarrierVehicle(distributionCarrier, CarrierVehicle.newInstance(Id.createVehicleId("distributionTruck"), HUB_LINK_ID, vehType));
LSPResource distributionCarrierRessource = DistributionCarrierUtils.DistributionCarrierResourceBuilder.newInstance(distributionCarrier, network)
.setDistributionScheduler(DistributionCarrierUtils.createDefaultDistributionCarrierScheduler())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.matsim.core.scoring.ScoringFunction;
import org.matsim.core.scoring.SumScoringFunction;
import org.matsim.freight.carriers.carrier.Carrier;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.scoring.ScoringFunction;
import org.matsim.core.scoring.SumScoringFunction;
import org.matsim.freight.carriers.carrier.Carrier;
import org.matsim.freight.carriers.carrier.Tour;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.Tour;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.events.CarrierTourEndEvent;
import org.matsim.freight.carriers.events.CarrierTourStartEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import org.matsim.core.replanning.GenericStrategyManager;
import org.matsim.core.replanning.GenericStrategyManagerImpl;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -70,7 +70,7 @@ private static LSP createLSPWithReplanner(Network network) {
capabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities capabilities = capabilitiesBuilder.build();

Carrier carrier = CarrierUtils.createCarrier(carrierId);
Carrier carrier = CarriersUtils.createCarrier(carrierId);
carrier.setCarrierCapabilities(capabilities);

//The Resource i.e. the Resource is created
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/example/lsp/lspScoring/ExampleLSPScoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.events.CarrierServiceEndEvent;
import org.matsim.freight.carriers.events.eventhandler.FreightServiceEndEventHandler;
import org.matsim.vehicles.VehicleType;
Expand Down Expand Up @@ -71,7 +70,7 @@ private static LSP createLSPWithScorer(Network network) {
.addVehicle(CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, carrierVehicleType))
.setFleetSize(FleetSize.INFINITE).build();

Carrier carrier = CarrierUtils.createCarrier(Id.create("CollectionCarrier", Carrier.class));
Carrier carrier = CarriersUtils.createCarrier(Id.create("CollectionCarrier", Carrier.class));
carrier.setCarrierCapabilities(capabilities);

//The Resource i.e. the Resource is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.network.io.MatsimNetworkReader;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -143,7 +142,7 @@ private static LSP createInitialLSP(Network network) {
capabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities capabilities = capabilitiesBuilder.build();

Carrier carrier = CarrierUtils.createCarrier(carrierId);
Carrier carrier = CarriersUtils.createCarrier(carrierId);
carrier.setCarrierCapabilities(capabilities);

//The Resource i.e. the Resource is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.network.io.MatsimNetworkReader;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -77,7 +77,7 @@ private static LSP createInitialLSP(Scenario scenario) {
capabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities capabilities = capabilitiesBuilder.build();

Carrier collectionCarrier = CarrierUtils.createCarrier(collectionCarrierId);
Carrier collectionCarrier = CarriersUtils.createCarrier(collectionCarrierId);
collectionCarrier.setCarrierCapabilities(capabilities);

//The collection adapter i.e. the Resource is created
Expand Down Expand Up @@ -132,7 +132,7 @@ private static LSP createInitialLSP(Scenario scenario) {
.addVehicle(mainRunCarrierVehicle)
.setFleetSize(FleetSize.INFINITE)
.build();
Carrier mainRunCarrier = CarrierUtils.createCarrier(mainRunCarrierId);
Carrier mainRunCarrier = CarriersUtils.createCarrier(mainRunCarrierId);
mainRunCarrier.setCarrierCapabilities(mainRunCapabilities);

//The adapter i.e. the main run resource is created
Expand Down Expand Up @@ -189,7 +189,7 @@ private static LSP createInitialLSP(Scenario scenario) {
distributionCapabilitiesBuilder.addVehicle(distributionCarrierVehicle);
distributionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE);
CarrierCapabilities distributionCapabilities = distributionCapabilitiesBuilder.build();
Carrier distributionCarrier = CarrierUtils.createCarrier(distributionCarrierId);
Carrier distributionCarrier = CarriersUtils.createCarrier(distributionCarrierId);
distributionCarrier.setCarrierCapabilities(distributionCapabilities);

//The distribution adapter i.e. the Resource is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.scoring.ScoringFunction;
import org.matsim.core.scoring.SumScoringFunction;
import org.matsim.freight.carriers.carrier.Carrier;
import org.matsim.freight.carriers.carrier.Tour;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.Tour;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.events.CarrierTourEndEvent;
import org.matsim.freight.carriers.events.CarrierTourStartEvent;
Expand Down
Loading

0 comments on commit 733bf0f

Please sign in to comment.