Skip to content

Commit

Permalink
Merge branch 'master' into fiss-travel-time
Browse files Browse the repository at this point in the history
  • Loading branch information
marecabo authored Mar 13, 2024
2 parents 1aa9b21 + bc53af4 commit c206584
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public enum CleanIterations {
private static final String COMPRESSION_TYPE = "compressionType";
private static final String EVENT_TYPE_TO_CREATE_SCORING_FUNCTIONS = "createScoringFunctionType";

private static final String MEMORY_OBSERVER_INTERVAL = "memoryObserverInterval";

/*package*/ static final String MOBSIM = "mobsim";
public enum MobsimType {qsim, JDEQSim, hermes}

Expand Down Expand Up @@ -109,6 +111,8 @@ public enum MobsimType {qsim, JDEQSim, hermes}

private CleanIterations cleanItersAtEnd = CleanIterations.keep;

private int memoryObserverInterval = 60;

public ControllerConfigGroup() {
super(GROUP_NAME);
}
Expand Down Expand Up @@ -151,6 +155,7 @@ public final Map<String, String> getComments() {
"to a file. `0' disables snapshots writing completely");
map.put(DUMP_DATA_AT_END, "true if at the end of a run, plans, network, config etc should be dumped to a file");
map.put(CLEAN_ITERS_AT_END, "Defines what should be done with the ITERS directory when a simulation finished successfully");
map.put(MEMORY_OBSERVER_INTERVAL, "Defines the interval for printing memory usage to the log in [seconds]. Must be positive. Defaults to 60.");
return map;
}

Expand Down Expand Up @@ -427,6 +432,17 @@ public EventTypeToCreateScoringFunctions getEventTypeToCreateScoringFunctions()
public void setEventTypeToCreateScoringFunctions(EventTypeToCreateScoringFunctions eventTypeToCreateScoringFunctions) {
this.eventTypeToCreateScoringFunctions = eventTypeToCreateScoringFunctions;
}

@StringGetter(MEMORY_OBSERVER_INTERVAL)
public int getMemoryObserverInterval() {
return memoryObserverInterval;
}

@StringSetter(MEMORY_OBSERVER_INTERVAL)
public void setMemoryObserverInterval(int memoryObserverInterval) {
this.memoryObserverInterval = memoryObserverInterval;
}

// ---
int writePlansUntilIteration = 1 ;
public int getWritePlansUntilIteration() {
Expand All @@ -450,5 +466,8 @@ protected void checkConsistency(Config config) {
log.warn( "this is not recommended, as it might result in a directory containing output from several model runs" );
log.warn( "prefer the options "+OverwriteFileSetting.deleteDirectoryIfExists+" or "+OverwriteFileSetting.failIfDirectoryExists );
}
if(config.controller().getMemoryObserverInterval() < 0) {
log.warn("Memory observer interval is negative. Simulation will most likely crash.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final void setupOutputDirectory(OutputDirectoryHierarchy controlerIO) {
}

protected final void run(final Config config) {
MemoryObserver.start(60);
MemoryObserver.start(config.controller().getMemoryObserverInterval());
MatsimRuntimeModifications.MyRunnable runnable = new MatsimRuntimeModifications.MyRunnable() {
@Override
public void run() throws MatsimRuntimeModifications.UnexpectedShutdownException {
Expand Down

0 comments on commit c206584

Please sign in to comment.