Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oustide activity #174

Closed
wants to merge 10 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ public OutsideFacilityAdapter(ActivityFacilities facilities) {
}

private Id<ActivityFacility> createNextId() {
counter++;
return Id.create("outside_" + counter, ActivityFacility.class);
while (true) {
counter++;
var id = Id.create("outside_" + counter, ActivityFacility.class);
if (!facilities.getFacilities().containsKey(id)) {
return id;
}
}
}

public ActivityFacility getFacility(Link link) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class AnalysisOutputListener implements IterationStartsListener, Iteratio

private final int analysisInterval;
private boolean isAnalysisActive = false;
private boolean doPtAnalysis = true;

private final DistanceUnit scenarioDistanceUnit;
private final DistanceUnit analysisDistanceUnit;
Expand All @@ -51,6 +52,9 @@ public AnalysisOutputListener(EqasimConfigGroup config, OutputDirectoryHierarchy

this.analysisInterval = config.getAnalysisInterval();

// pt analysis throws an error when simulating pt in Qsim
this.doPtAnalysis = config.getUseScheduleBasedTransport();

this.tripAnalysisListener = tripListener;
this.legAnalysisListener = legListener;
this.ptAnalysisListener = ptListener;
Expand All @@ -65,7 +69,9 @@ public void notifyIterationStarts(IterationStartsEvent event) {
isAnalysisActive = true;
event.getServices().getEvents().addHandler(tripAnalysisListener);
event.getServices().getEvents().addHandler(legAnalysisListener);
event.getServices().getEvents().addHandler(ptAnalysisListener);
if (this.doPtAnalysis) {
event.getServices().getEvents().addHandler(ptAnalysisListener);
}
}
}
}
Expand All @@ -84,8 +90,10 @@ public void notifyIterationEnds(IterationEndsEvent event) {
new LegWriter(legAnalysisListener.getLegItems(), scenarioDistanceUnit, analysisDistanceUnit)
.write(outputDirectory.getIterationFilename(event.getIteration(), LEGS_FILE_NAME));

new PublicTransportLegWriter(ptAnalysisListener.getTripItems())
.write(outputDirectory.getIterationFilename(event.getIteration(), PT_FILE_NAME));
if (this.doPtAnalysis) {
new PublicTransportLegWriter(ptAnalysisListener.getTripItems())
.write(outputDirectory.getIterationFilename(event.getIteration(), PT_FILE_NAME));
}
}
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -99,8 +107,10 @@ public void notifyShutdown(ShutdownEvent event) {
new File(outputDirectory.getOutputFilename(TRIPS_FILE_NAME)).toPath());
Files.copy(new File(outputDirectory.getIterationFilename(event.getIteration(), LEGS_FILE_NAME)).toPath(),
new File(outputDirectory.getOutputFilename(LEGS_FILE_NAME)).toPath());
Files.copy(new File(outputDirectory.getIterationFilename(event.getIteration(), PT_FILE_NAME)).toPath(),
new File(outputDirectory.getOutputFilename(PT_FILE_NAME)).toPath());
if (this.doPtAnalysis) {
Files.copy(new File(outputDirectory.getIterationFilename(event.getIteration(), PT_FILE_NAME)).toPath(),
new File(outputDirectory.getOutputFilename(PT_FILE_NAME)).toPath());
}
} catch (IOException e) {
}
}
Expand Down
Loading