Skip to content

Commit

Permalink
Merge pull request #104 from matsim-vsp/dependabot/maven/org.matsim-m…
Browse files Browse the repository at this point in the history
…atsim-all-2025.0-2025w04

Bump org.matsim:matsim-all from 2025.0-2025w02 to 2025.0-2025w04
  • Loading branch information
rewertvsp authored Jan 20, 2025
2 parents 58710b9 + 2917eb7 commit c3ef3ce
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 66 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.matsim</groupId>
<artifactId>matsim-all</artifactId>
<version>2025.0-2025w02</version>
<version>2025.0-2025w04</version>
<!-- <version>2025.0-PR3245</version>-->
<!-- <version>2025.0-SNAPSHOT</version>-->
<relativePath/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.analysis.CarriersAnalysis;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;

Expand All @@ -17,20 +16,17 @@ public class RunFreightAnalysisForMultipleRuns {
public static void main(String[] args) throws IOException {

Path folderWithDifferentRuns = Path.of("output/WasteCollectionVulkaneifel/250it_newConstraint/");
String globalCrs = "EPSG:25832";

boolean reRunAllAnalysis = false;
File runFolder = new File(folderWithDifferentRuns.toUri());

for (File singleRunFolder : Objects.requireNonNull(runFolder.listFiles())) {
if (singleRunFolder.getName().equals("Analysis")) continue;

File analysisFolder = new File(singleRunFolder, "Analysis_new");
File analysisFolder = new File(singleRunFolder, "CarriersAnalysis");
if (!analysisFolder.exists() || reRunAllAnalysis) {
RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(singleRunFolder.getPath() + "/",
singleRunFolder.getPath() + "/Analysis_new/",
globalCrs);
freightAnalysis.runCompleteAnalysis();
CarriersAnalysis freightAnalysis = new CarriersAnalysis(singleRunFolder.getPath());
freightAnalysis.runCarrierAnalysis(CarriersAnalysis.CarrierAnalysisType.carriersAndEvents);
}
}

Expand Down
14 changes: 1 addition & 13 deletions src/main/java/org/matsim/vsp/freight/food/RunFood.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.matsim.api.core.v01.population.Leg;
import org.matsim.application.MATSimAppCommand;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.controller.CarrierModule;
Expand All @@ -42,12 +41,6 @@
import org.matsim.core.controler.OutputDirectoryHierarchy;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.scoring.ScoringFunction;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.vehicles.EngineInformation;
import org.matsim.vehicles.VehicleUtils;
import picocli.CommandLine;
Expand Down Expand Up @@ -120,11 +113,6 @@ public Integer call() throws Exception {
controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn);
controler.run();

final String outputPath = controler.getControlerIO().getOutputPath();
RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(outputPath + "/", outputPath + "/Analysis/",
config.global().getCoordinateSystem());
freightAnalysis.runCompleteAnalysis();

return 0;
}

Expand All @@ -147,7 +135,7 @@ private void calculateVariableConsumptionCosts(Scenario scenario, double fuelCos
energieCostsPerMeter = energyConsumptionKWhPerMeter * energyCostsEurPerKWh;

} else if (engineType.equals("diesel")) {
double fuelConsumptionLitersPerMeter = VehicleUtils.getFuelConsumption(vehicleType);
double fuelConsumptionLitersPerMeter = VehicleUtils.getFuelConsumptionLitersPerMeter(vehicleType.getEngineInformation());
energieCostsPerMeter = fuelConsumptionLitersPerMeter * fuelCostsEurPerL;

} else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.analysis.CarriersAnalysis;

import java.io.File;
import java.io.IOException;
Expand All @@ -29,8 +29,8 @@ public static void main(String[] args) throws IOException {
if (!simOutputPath.endsWith(File.separator)) {
simOutputPath = simOutputPath + File.separator;
}
log.info("Running analysis for: " + simOutputPath);
RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(simOutputPath, simOutputPath +"Analysis"+File.separator, null);
freightAnalysis.runCompleteAnalysis();
log.info("Running analysis for: {}", simOutputPath);
CarriersAnalysis freightAnalysis = new CarriersAnalysis(simOutputPath);
freightAnalysis.runCarrierAnalysis(CarriersAnalysis.CarrierAnalysisType.carriersAndEvents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.ScheduledTour;
import org.matsim.freight.carriers.Tour;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.controller.CarrierModule;

/**
Expand Down Expand Up @@ -113,16 +112,8 @@ public static void run( String[] args, String runDir )
final Controler controler = new Controler( scenario ) ;
controler.addOverridingModule(new CarrierModule() );


// ## Start of the MATSim-Run: ##
controler.run();

var analysis = new RunFreightAnalysisEventBased(config.controller().getOutputDirectory() , config.controller().getOutputDirectory()+"Analysis", "EPSG:31468");
try {
analysis.runCompleteAnalysis();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

}
7 changes: 3 additions & 4 deletions src/main/java/org/matsim/vsp/freightAnalysis/RunAnalyse.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.matsim.vsp.freightAnalysis;

import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.analysis.CarriersAnalysis;

import java.io.IOException;

Expand All @@ -25,9 +25,8 @@ enum FreightAnalysisVersion {
FreightAnalysisVersion slectedFreightAnalysisVersion = FreightAnalysisVersion.eventBased;
switch (slectedFreightAnalysisVersion) {
case eventBased -> {
RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(runDir + "/" + runId,
runDir + "/EventBasedAnalysis/", "EPSG:25832");
freightAnalysis.runCompleteAnalysis();
CarriersAnalysis freightAnalysis = new CarriersAnalysis(runDir);
freightAnalysis.runCarrierAnalysis(CarriersAnalysis.CarrierAnalysisType.carriersAndEvents);
}
case oldVersion -> {
if (runId != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,10 @@
* *********************************************************************** */
package org.matsim.vsp.freightDemandGeneration;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freightDemandGeneration.FreightDemandGeneration;
import org.matsim.vsp.freightAnalysis.FreightAnalyse;

public class FreightDemandGenerationExample {

Expand Down Expand Up @@ -67,18 +60,6 @@ public static void main(String[] args) throws IOException {
"--populationCRS", "DHDN_GK4",
"--defaultJspritIterations", "3"
);

List<File> fileData = new ArrayList<>();
for (File file : Objects.requireNonNull(output.toFile().listFiles())) {
fileData.add(file);
}
Collections.sort(fileData);
File lastFile = fileData.get(fileData.size() - 1);
String[] argsAnalysis = {lastFile.toString(), "true"};
FreightAnalyse.main(argsAnalysis);
RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(lastFile + "/",
lastFile + "/Analysis_new/", "EPSG:31468");
freightAnalysis.runCarriersAnalysis();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.matsim.core.scoring.ScoringFunction;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import picocli.CommandLine;
Expand Down Expand Up @@ -162,12 +161,6 @@ public Integer call() throws Exception {

controller.run();

// Analysis
log.info("Starting Analysis");
RunFreightAnalysisEventBased freightAnalysis = new RunFreightAnalysisEventBased(output +"/", output +"/Analysis_new/", config.global().getCoordinateSystem());
freightAnalysis.runCompleteAnalysis();
log.info("Finished Analysis");

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/matsim/vsp/freight/TestRunFreight.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testMain() {
try {
RunFreight.main(null);
} catch ( Exception ee ) {
LogManager.getLogger(this.getClass()).fatal("there was an exception: \n" + ee ) ;
LogManager.getLogger(this.getClass()).fatal("there was an exception: \n{}", String.valueOf(ee));
// if one catches an exception, then one needs to explicitly fail the test:
Assertions.fail();
}
Expand Down

0 comments on commit c3ef3ce

Please sign in to comment.