From 8837a7c51849ea1e7024f1606b7610cd809b14ee Mon Sep 17 00:00:00 2001 From: Ricardo Ewert Date: Thu, 8 Feb 2024 09:33:30 +0100 Subject: [PATCH 1/4] typo and style changes --- .../FreightDemandGeneration.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index caec3bbf367..999d7467ccd 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -258,12 +258,12 @@ private Config prepareConfig(int lastMATSimIteration, String coordinateSystem) { private static void setNetworkAndNetworkChangeEvents(Config config, String networkPathOfOtherNetwork, String networkChangeEventsFileLocation) throws RuntimeException { - if (networkPathOfOtherNetwork.equals("")) + if (networkPathOfOtherNetwork.isEmpty()) throw new RuntimeException("no correct network path network"); else { config.network().setInputFile(networkPathOfOtherNetwork); log.info("The following input network is selected: imported network from " + networkPathOfOtherNetwork); - if (networkChangeEventsFileLocation.equals("")) + if (networkChangeEventsFileLocation.isEmpty()) log.info("No networkChangeEvents selected"); else { log.info("Setting networkChangeEventsInput file: " + networkChangeEventsFileLocation); @@ -341,7 +341,7 @@ private void createCarrier(Scenario scenario, CarrierInputOptions selectedCarrie } /** - * Differs between the different options of creating the demand.. + * Differs between the different options of creating the demand. * * @param selectedDemandGenerationOption * @param scenario @@ -379,7 +379,7 @@ private void createDemand(DemandGenerationOptions selectedDemandGenerationOption case createMoreLocations -> /* * If the demand sample is higher than the population sample, more demand - * location are created related to the given share of persons of the population + * locations are created related to the given share of persons in the population * with this demand. */ FreightDemandGenerationUtils.preparePopulation(population, sampleSizeInputPopulation, @@ -460,7 +460,7 @@ private static void solveSelectedSolution(OptionsOfVRPSolutions selectedSolution Controler controler) throws ExecutionException, InterruptedException { switch (selectedSolution) { case runJspritAndMATSim -> { - // solves the VRP with jsprit and runs MATSim afterwards + // solves the VRP with jsprit and runs MATSim afterward new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); runJsprit(controler, false); @@ -469,8 +469,7 @@ private static void solveSelectedSolution(OptionsOfVRPSolutions selectedSolution .write(config.controller().getOutputDirectory() + "/output_carriersWithPlans.xml"); } case runJspritAndMATSimWithDistanceConstraint -> { - // solves the VRP with jsprit by using the distance constraint and runs MATSim - // afterwards + // solves the VRP with jsprit by using the distance constraint and runs MATSim afterward new CarrierPlanWriter((Carriers) controler.getScenario().getScenarioElement("carriers")) .write(config.controller().getOutputDirectory() + "/output_carriersNoPlans.xml"); runJsprit(controler, true); From 1d4449c2456b33e8a9864576dc88350317bc7d3a Mon Sep 17 00:00:00 2001 From: Ricardo Ewert Date: Thu, 8 Feb 2024 10:20:44 +0100 Subject: [PATCH 2/4] optimize imports --- .../FreightDemandGeneration.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index 999d7467ccd..80d931d13ed 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -26,14 +26,6 @@ import org.matsim.api.core.v01.population.Population; import org.matsim.application.MATSimAppCommand; import org.matsim.application.options.ShpOptions; -import org.matsim.freight.carriers.FreightCarriersConfigGroup; -import org.matsim.freight.carriers.Carrier; -import org.matsim.freight.carriers.CarrierPlanWriter; -import org.matsim.freight.carriers.CarriersUtils; -import org.matsim.freight.carriers.Carriers; -import org.matsim.freight.carriers.controler.CarrierModule; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.usecases.chessboard.CarrierScoringFunctionFactoryImpl; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ControllerConfigGroup; @@ -44,12 +36,15 @@ import org.matsim.core.population.PopulationUtils; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; +import org.matsim.freight.carriers.*; +import org.matsim.freight.carriers.controler.CarrierModule; +import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.usecases.chessboard.CarrierScoringFunctionFactoryImpl; import org.opengis.feature.simple.SimpleFeature; import picocli.CommandLine; import javax.management.InvalidAttributeValueException; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; import java.util.Objects; From f435432a7e2cfb16402e1f3ac92861b7022595f8 Mon Sep 17 00:00:00 2001 From: Ricardo Ewert Date: Thu, 8 Feb 2024 10:21:34 +0100 Subject: [PATCH 3/4] change population input from path to string --- .../freightDemandGeneration/FreightDemandGeneration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index 80d931d13ed..30e50e83cea 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -124,7 +124,7 @@ private enum OptionsOfVRPSolutions { private ShpOptions shp = new ShpOptions(shapeFilePath, shapeCRS, null); @CommandLine.Option(names = "--populationFileLocation", description = "Path to the population file.", defaultValue = "") - private Path populationFilePath; + private String populationFilePath; @CommandLine.Option(names = "--populationCRS", description = "CRS of the input network (e.g.\"EPSG:31468\")") private String populationCRS; @@ -165,7 +165,7 @@ public Integer call() throws IOException, InvalidAttributeValueException, Execut String vehicleTypesFileLocation = carrierVehicleFilePath.toString(); String carriersFileLocation = carrierFilePath.toString(); - String populationFile = populationFilePath.toString(); + String populationFile = populationFilePath; CoordinateTransformation crsTransformationFromNetworkToShape = null; // create and prepare MATSim config From b13d4a291aec950cf89ac11a9b758870b8cbc4b5 Mon Sep 17 00:00:00 2001 From: Ricardo Ewert Date: Thu, 8 Feb 2024 10:22:01 +0100 Subject: [PATCH 4/4] typo --- .../matsim/freightDemandGeneration/FreightDemandGeneration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index 30e50e83cea..eaad22775a1 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -367,7 +367,7 @@ private void createDemand(DemandGenerationOptions selectedDemandGenerationOption Population population = PopulationUtils.readPopulation(populationFile); switch (selectedSamplingOption) { /* - * this option is important if the sample of the population and the sample of + * This option is important if the sample of the population and the sample of * the resulting demand is different. For example, you can create with a 10pct * sample a 100pct demand modal for the waste collection. */