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

Commit

Permalink
rename/move packages: ....contrib.freight.* -> ....freight.carriers.*…
Browse files Browse the repository at this point in the history
… AND adapt to other changes in MATSim libs, e.g. renaming of config groups and parameters
  • Loading branch information
kt86 committed Oct 12, 2023
1 parent 10b313f commit 7758c68
Show file tree
Hide file tree
Showing 116 changed files with 557 additions and 555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
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.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
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.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.FreightConfigGroup;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
import org.matsim.contrib.freight.controler.CarrierStrategyManager;
import org.matsim.contrib.freight.controler.FreightUtils;
import org.matsim.contrib.freight.events.CarrierServiceEndEvent;
import org.matsim.contrib.freight.events.CarrierTourEndEvent;
import org.matsim.contrib.freight.events.eventhandler.FreightServiceEndEventHandler;
import org.matsim.contrib.freight.events.eventhandler.FreightTourEndEventHandler;
import org.matsim.core.config.CommandLine;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
Expand All @@ -53,6 +44,15 @@
import org.matsim.core.replanning.GenericPlanStrategyImpl;
import org.matsim.core.replanning.selectors.RandomPlanSelector;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.FreightConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controler.FreightUtils;
import org.matsim.freight.carriers.events.CarrierServiceEndEvent;
import org.matsim.freight.carriers.events.CarrierTourEndEvent;
import org.matsim.freight.carriers.events.eventhandler.FreightServiceEndEventHandler;
import org.matsim.freight.carriers.events.eventhandler.FreightTourEndEventHandler;
import org.matsim.vehicles.VehicleType;

import java.util.*;
Expand Down Expand Up @@ -99,11 +99,11 @@ public static void main(String[] args) {
} else {
solutionType = SolutionType.onePlan_direct;
log.warn("SolutionType was set in code to: " + solutionType);
config.controler().setOutputDirectory("output/ChainVsDirect/" + solutionType);
config.controler().setLastIteration(2);
config.controller().setOutputDirectory("output/ChainVsDirect/" + solutionType);
config.controller().setLastIteration(2);

}
config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);

var freightConfig = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class);
freightConfig.setTimeWindowHandling(FreightConfigGroup.TimeWindowHandling.ignore);
Expand Down Expand Up @@ -165,7 +165,7 @@ public static void main(String[] args) {

//print the schedules for the assigned LSPShipments
log.info("print the schedules for the assigned LSPShipments");
ResourceImplementationUtils.printResults_shipmentPlan(config.controler().getOutputDirectory(), lsp);
ResourceImplementationUtils.printResults_shipmentPlan(config.controller().getOutputDirectory(), lsp);

log.info("Done.");

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/example/lsp/initialPlans/ExampleTestOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public static void main( String[] args ){

Config config = ConfigUtils.loadConfig( IOUtils.extendUrl( ExamplesUtils.getTestScenarioURL( "equil" ), "config.xml" ) );

config.controler().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists );
config.controler().setLastIteration( 1 );
config.controller().setOverwriteFileSetting( OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists );
config.controller().setLastIteration( 1 );

Scenario scenario = ScenarioUtils.loadScenario( config );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.FreightConfigGroup;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.controler.CarrierScoringFunctionFactory;
import org.matsim.contrib.freight.controler.CarrierStrategyManager;
import org.matsim.contrib.freight.controler.FreightUtils;
import org.matsim.core.config.CommandLine;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
Expand All @@ -51,6 +46,11 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.freight.carriers.FreightConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controler.FreightUtils;
import org.matsim.vehicles.VehicleType;

import java.util.*;
Expand Down Expand Up @@ -175,13 +175,13 @@ private static Config prepareConfig(String[] args) {

CommandLine cmd = ConfigUtils.getCommandLine(args);
} else {
config.controler().setOutputDirectory("output/2echelon_"+demandSetting + "_" + costSetting + "_" + HUBCOSTS_FIX+ "_" + TOLL_VALUE);
config.controler().setLastIteration(2);
config.controller().setOutputDirectory("output/2echelon_"+demandSetting + "_" + costSetting + "_" + HUBCOSTS_FIX+ "_" + TOLL_VALUE);
config.controller().setLastIteration(2);
}

config.network().setInputFile(String.valueOf(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("freight-chessboard-9x9"), "grid9x9.xml")));
config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setWriteEventsInterval(1);
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setWriteEventsInterval(1);

FreightConfigGroup freightConfig = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class);
freightConfig.setTimeWindowHandling(FreightConfigGroup.TimeWindowHandling.ignore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.FreightConfigGroup;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.controler.CarrierScoringFunctionFactory;
import org.matsim.contrib.freight.controler.CarrierStrategyManager;
import org.matsim.contrib.freight.controler.FreightUtils;
import org.matsim.core.config.CommandLine;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
Expand All @@ -53,6 +48,11 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.freight.carriers.FreightConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controler.FreightUtils;
import org.matsim.vehicles.VehicleType;

import java.util.*;
Expand Down Expand Up @@ -156,9 +156,9 @@ public void install() {
controler.run();

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

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

Expand All @@ -181,13 +181,13 @@ private static Config prepareConfig(String[] args) {

CommandLine cmd = ConfigUtils.getCommandLine(args);
} else {
config.controler().setOutputDirectory("output/2echelon_"+demandSetting + "_" + costSetting + "_" + HUBCOSTS_FIX+ "_" + TOLL_VALUE);
config.controler().setLastIteration(2);
config.controller().setOutputDirectory("output/2echelon_"+demandSetting + "_" + costSetting + "_" + HUBCOSTS_FIX+ "_" + TOLL_VALUE);
config.controller().setLastIteration(2);
}

config.network().setInputFile(String.valueOf(IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("freight-chessboard-9x9"), "grid9x9.xml")));
config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles);
config.controler().setWriteEventsInterval(1);
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles);
config.controller().setWriteEventsInterval(1);

FreightConfigGroup freightConfig = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class);
freightConfig.setTimeWindowHandling(FreightConfigGroup.TimeWindowHandling.ignore);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/example/lsp/initialPlans/MyCarrierScorer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package example.lsp.initialPlans;

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

/**
* @author Kai Martins-Turner (kturner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import org.matsim.api.core.v01.events.Event;
import org.matsim.api.core.v01.events.LinkEnterEvent;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.carrier.Carrier;
import org.matsim.contrib.freight.carrier.Tour;
import org.matsim.contrib.freight.controler.CarrierScoringFunctionFactory;
import org.matsim.contrib.freight.events.CarrierTourEndEvent;
import org.matsim.contrib.freight.events.CarrierTourStartEvent;
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.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.events.CarrierTourEndEvent;
import org.matsim.freight.carriers.events.CarrierTourStartEvent;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
import org.matsim.core.config.Config;
import org.matsim.core.config.groups.VspExperimentalConfigGroup;
import org.matsim.core.controler.AbstractModule;
Expand All @@ -41,6 +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.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -212,9 +212,9 @@ public static void main(String[] args) {

strategyManager.addStrategy( new TomorrowShipmentAssignerStrategyFactory(maybeTodayAssigner).createStrategy(), null, 1);

config.controler().setFirstIteration(0);
config.controler().setLastIteration(4);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles);
config.controller().setFirstIteration(0);
config.controller().setLastIteration(4);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles);
config.network().setInputFile("scenarios/2regions/2regions-network.xml");
//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);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/example/lsp/lspScoring/ExampleLSPScoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.FreightConfigGroup;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
import org.matsim.contrib.freight.events.CarrierServiceEndEvent;
import org.matsim.contrib.freight.events.eventhandler.FreightServiceEndEventHandler;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.VspExperimentalConfigGroup;
import org.matsim.core.controler.AbstractModule;
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.freight.carriers.FreightConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.events.CarrierServiceEndEvent;
import org.matsim.freight.carriers.events.eventhandler.FreightServiceEndEventHandler;
import org.matsim.vehicles.VehicleType;

import java.util.*;
Expand Down Expand Up @@ -200,8 +200,8 @@ static Config prepareConfig() {

config.network().setInputFile("scenarios/2regions/2regions-network.xml");

config.controler().setLastIteration(0);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setLastIteration(0);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);

var freightConfig = ConfigUtils.addOrGetModule(config, FreightConfigGroup.class);
freightConfig.setTimeWindowHandling(FreightConfigGroup.TimeWindowHandling.ignore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.FreightConfigGroup;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.VspExperimentalConfigGroup;
Expand All @@ -41,6 +38,9 @@
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.FreightConfigGroup;
import org.matsim.freight.carriers.carrier.*;
import org.matsim.freight.carriers.carrier.CarrierCapabilities.FleetSize;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -85,9 +85,9 @@ public static void main(String[] args) {
LSPs lsps = new LSPs(lspList);
LSPUtils.addLSPs(scenario, lsps);

config.controler().setFirstIteration(0);
config.controler().setLastIteration(0);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles);
config.controller().setFirstIteration(0);
config.controller().setLastIteration(0);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles);

Controler controler = new Controler(scenario);
controler.addOverridingModule(new AbstractModule() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.contrib.freight.carrier.CarrierCapabilities.FleetSize;
import org.matsim.core.config.Config;
import org.matsim.core.config.groups.VspExperimentalConfigGroup;
import org.matsim.core.controler.AbstractModule;
import org.matsim.core.controler.Controler;
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.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;

Expand Down Expand Up @@ -327,9 +327,9 @@ public void install() {
install(new LSPModule()); // this is the better syntax, having everything in one module. kai, may'22
}
});
config.controler().setFirstIteration(0);
config.controler().setLastIteration(0);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles);
config.controller().setFirstIteration(0);
config.controller().setLastIteration(0);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles);
config.network().setInputFile("scenarios/2regions/2regions-network.xml");
//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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import org.matsim.api.core.v01.events.Event;
import org.matsim.api.core.v01.events.LinkEnterEvent;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.freight.carrier.Carrier;
import org.matsim.contrib.freight.carrier.Tour;
import org.matsim.contrib.freight.controler.CarrierScoringFunctionFactory;
import org.matsim.contrib.freight.events.CarrierTourEndEvent;
import org.matsim.contrib.freight.events.CarrierTourStartEvent;
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.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.events.CarrierTourEndEvent;
import org.matsim.freight.carriers.events.CarrierTourStartEvent;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
Expand Down
Loading

0 comments on commit 7758c68

Please sign in to comment.