Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tschlenther committed Sep 23, 2024
1 parent a632f75 commit 82fc278
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/matsim/run/DrtFleetSizing.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.matsim.api.core.v01.Coord;
import org.matsim.api.core.v01.Id;
Expand Down Expand Up @@ -74,6 +76,7 @@ public class DrtFleetSizing implements MATSimAppCommand {
@CommandLine.Option(names = "--fleet-sizing", description = "a triplet: [from max interval]. ", arity = "1..*", defaultValue = "10 50 5")
private List<Integer> fleetSizing;

private Logger logger = LogManager.getLogger(DrtFleetSizing.class);

public static void main(String[] args) {
new DrtFleetSizing().execute(args);
Expand All @@ -83,6 +86,7 @@ public static void main(String[] args) {
public Integer call() throws Exception {
// write output root folder
if (!Files.exists(Path.of(outputFolderPath))) {
logger.info("creating outputFolderPath");
Files.createDirectories(Path.of(outputFolderPath));
}

Expand All @@ -101,8 +105,10 @@ public Integer call() throws Exception {

private @NotNull String extractAVDemandFromExistingOutput(String drtNetworkPath, String extractedAVPlansPath) {


Network drtNetwork = NetworkUtils.readNetwork(drtNetworkPath);
Path outputPopulationPath = globFile(Path.of(matsimRunFolderPath), "*output_plans.xml.gz*");
logger.info("retrieving single-leg av plans from " + outputPopulationPath);
MainModeIdentifier modeIdentifier = new DefaultAnalysisMainModeIdentifier();
Population outputPlans = PopulationUtils.readPopulation(outputPopulationPath.toString());
Population avPlans = PopulationUtils.createPopulation(ConfigUtils.createConfig());
Expand Down Expand Up @@ -155,12 +161,14 @@ private void runDRTSimulations(String drtNetworkPath, String extractedAVPlansPat
int fleetInterval = fleetSizing.get(2);

for (int fleetSize = fleetFrom; fleetSize <= fleetMax; fleetSize += fleetInterval) {
logger.info("set up run with fleet size = " + fleetSize);
// setup DRT run
Config config = ConfigUtils.loadConfig(drtConfigPath, new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new), new DvrpConfigGroup());
config.network().setInputFile(drtNetworkPath);
config.plans().setInputFile(extractedAVPlansPath);
config.controller().setLastIteration(1);
config.controller().setOutputDirectory(outputFolderPath + "/" + fleetSize + "-veh");
logger.info("output will be written to " + outputFolderPath + "/" + fleetSize + "-veh");
config.vehicles().setVehiclesFile(vehiclesFolderPath + "/" + fleetSize + "-veh.xml");
String singleDrtRunOutputDirectory = config.controller().getOutputDirectory();
MultiModeDrtConfigGroup multiModeDrtConfig = MultiModeDrtConfigGroup.get(config);
Expand Down Expand Up @@ -206,7 +214,10 @@ public void install() {
}
}

logger.info("the obtained waiting time is " + waitingTime);

if (waitingTime < meanWaitTime) {
logger.info("will stop to conduct simulations, as the target waiting time of " + waitingTime + " is higher than the yielded waiting time.");
break;
}
}
Expand Down

0 comments on commit 82fc278

Please sign in to comment.