diff --git a/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/CarrierPlanAnalysis.java b/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/CarrierPlanAnalysis.java index 5892430bf81..8de996a9bf0 100644 --- a/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/CarrierPlanAnalysis.java +++ b/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/CarrierPlanAnalysis.java @@ -40,7 +40,7 @@ public void runAnalysisAndWriteStats(String analysisOutputDirectory) throws IOEx BufferedWriter bw1 = new BufferedWriter(new FileWriter(fileName)); //Write headline: - bw1.write("carrierId \t scoreOfSelectedPlan \t nuOfTours \t nuOfShipments(input) \t nuOfServices(input) "); + bw1.write("carrierId \t MATSimScoreSelectedPlan \t jSpritScoreSelectedPlan \t nuOfTours \t nuOfShipments(input) \t nuOfServices(input) "); bw1.newLine(); final TreeMap, Carrier> sortedCarrierMap = new TreeMap<>(carriers.getCarriers()); @@ -48,6 +48,7 @@ public void runAnalysisAndWriteStats(String analysisOutputDirectory) throws IOEx for (Carrier carrier : sortedCarrierMap.values()) { bw1.write(carrier.getId().toString()); bw1.write("\t" + carrier.getSelectedPlan().getScore()); + bw1.write("\t" + carrier.getSelectedPlan().getJspritScore()); bw1.write("\t" + carrier.getSelectedPlan().getScheduledTours().size()); bw1.write("\t" + carrier.getShipments().size()); bw1.write("\t" + carrier.getServices().size()); diff --git a/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventbased.java b/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java similarity index 96% rename from contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventbased.java rename to contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java index bcc3753f621..3f5792e8ace 100644 --- a/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventbased.java +++ b/contribs/vsp/src/main/java/org/matsim/contrib/freight/analysis/RunFreightAnalysisEventBased.java @@ -48,9 +48,9 @@ * * @author kturner (Kai Martins-Turner) */ -public class RunFreightAnalysisEventbased { +public class RunFreightAnalysisEventBased { - private static final Logger log = LogManager.getLogger(RunFreightAnalysisEventbased.class); + private static final Logger log = LogManager.getLogger(RunFreightAnalysisEventBased.class); //Were is your simulation output, that should be analysed? private final String SIM_OUTPUT_PATH ; @@ -62,7 +62,7 @@ public class RunFreightAnalysisEventbased { * @param analysisOutputPath The directory where the result of the analysis should go to * @param globalCrs */ - public RunFreightAnalysisEventbased(String simOutputPath, String analysisOutputPath, String globalCrs) { + public RunFreightAnalysisEventBased(String simOutputPath, String analysisOutputPath, String globalCrs) { this.SIM_OUTPUT_PATH = simOutputPath; this.ANALYSIS_OUTPUT_PATH = analysisOutputPath; this.GLOBAL_CRS = globalCrs; @@ -81,7 +81,7 @@ public void runAnalysis() throws IOException { //freight settings FreightConfigGroup freightConfigGroup = ConfigUtils.addOrGetModule( config, FreightConfigGroup.class ) ; freightConfigGroup.setCarriersFile( SIM_OUTPUT_PATH + "output_carriers.xml.gz"); - freightConfigGroup.setCarriersVehicleTypesFile(SIM_OUTPUT_PATH + "output_carriersVehicleTypes.xml.gz"); + freightConfigGroup.setCarriersVehicleTypesFile(SIM_OUTPUT_PATH + "output_allVehicles.xml.gz"); //Were to store the analysis output? String analysisOutputDirectory = ANALYSIS_OUTPUT_PATH; diff --git a/contribs/vsp/src/test/java/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest.java b/contribs/vsp/src/test/java/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest.java new file mode 100644 index 00000000000..4974a90d130 --- /dev/null +++ b/contribs/vsp/src/test/java/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest.java @@ -0,0 +1,25 @@ +package org.matsim.contrib.freight.analysis; + +import org.junit.Rule; +import org.junit.Test; +import org.matsim.testcases.MatsimTestUtils; + +import java.io.IOException; + +public class FreightAnalysisEventBasedTest { + + @Rule + public MatsimTestUtils testUtils = new MatsimTestUtils(); + + @Test + public void runFreightAnalysisEventBasedTest() throws IOException { + + RunFreightAnalysisEventBased analysisEventBased = new RunFreightAnalysisEventBased(testUtils.getClassInputDirectory(), testUtils.getOutputDirectory(),null); + analysisEventBased.runAnalysis(); + + MatsimTestUtils.assertEqualFilesLineByLine(testUtils.getInputDirectory() + "Carrier_stats.tsv", testUtils.getOutputDirectory() + "Carrier_stats.tsv"); + MatsimTestUtils.assertEqualFilesLineByLine(testUtils.getInputDirectory() + "Load_perVehicle.tsv", testUtils.getOutputDirectory() + "Load_perVehicle.tsv"); + MatsimTestUtils.assertEqualFilesLineByLine(testUtils.getInputDirectory() + "TimeDistance_perVehicle.tsv", testUtils.getOutputDirectory() + "TimeDistance_perVehicle.tsv"); + MatsimTestUtils.assertEqualFilesLineByLine(testUtils.getInputDirectory() + "TimeDistance_perVehicleType.tsv", testUtils.getOutputDirectory() + "TimeDistance_perVehicleType.tsv"); + } +} diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_allVehicles.xml.gz b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_allVehicles.xml.gz new file mode 100644 index 00000000000..199380ef6a0 Binary files /dev/null and b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_allVehicles.xml.gz differ diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_carriers.xml.gz b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_carriers.xml.gz new file mode 100644 index 00000000000..f1423329b98 Binary files /dev/null and b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_carriers.xml.gz differ diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_events.xml.gz b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_events.xml.gz new file mode 100644 index 00000000000..23e96d838a7 Binary files /dev/null and b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_events.xml.gz differ diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_network.xml.gz b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_network.xml.gz new file mode 100644 index 00000000000..cb668e2933b Binary files /dev/null and b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/output_network.xml.gz differ diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/Carrier_stats.tsv b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/Carrier_stats.tsv new file mode 100644 index 00000000000..21421192918 --- /dev/null +++ b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/Carrier_stats.tsv @@ -0,0 +1,2 @@ +carrierId MATSimScoreSelectedPlan jSpritScoreSelectedPlan nuOfTours nuOfShipments(input) nuOfServices(input) +carrier1 -263.4 null 2 0 7 diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/Load_perVehicle.tsv b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/Load_perVehicle.tsv new file mode 100644 index 00000000000..8cff896d44c --- /dev/null +++ b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/Load_perVehicle.tsv @@ -0,0 +1 @@ +vehicleId capacity maxLoad load state during tour diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/TimeDistance_perVehicle.tsv b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/TimeDistance_perVehicle.tsv new file mode 100644 index 00000000000..a3716b50cdc --- /dev/null +++ b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/TimeDistance_perVehicle.tsv @@ -0,0 +1 @@ +vehicleId carrierId vehicleTypeId tourId tourDuration[s] travelDistance[m] costPerSecond[EUR/s] costPerMeter[EUR/m] fixedCosts[EUR] varCostsTime[EUR] varCostsDist[EUR] totalCosts[EUR] diff --git a/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/TimeDistance_perVehicleType.tsv b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/TimeDistance_perVehicleType.tsv new file mode 100644 index 00000000000..dacd1779828 --- /dev/null +++ b/contribs/vsp/test/input/org/matsim/contrib/freight/analysis/FreightAnalysisEventBasedTest/runFreightAnalysisEventBasedTest/TimeDistance_perVehicleType.tsv @@ -0,0 +1,2 @@ +vehicleTypeId nuOfVehicles SumOfTourDuration[s] SumOfTravelDistances[m] costPerSecond[EUR/s] costPerMeter[EUR/m] fixedCosts[EUR/veh] varCostsTime[EUR] varCostsDist[EUR] fixedCosts[EUR] totalCosts[EUR] +light 0 0.0 60000.0 0.008 4.7E-4 84.0 0.0 28.2 0.0 28.2