Skip to content

Commit

Permalink
[360] fix inversion completion termination
Browse files Browse the repository at this point in the history
  • Loading branch information
voj committed Dec 16, 2024
1 parent 04ef9b1 commit 079938d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions doc/inversion-cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ repeat until completion criteria {
### Completion Criteria

These criteria determine the overall length of the inversion. All three criteria can be set up, and the inversion will end when one of them is satisfied at the beginning of a round.
- `setInversionMinutes()` or `setInversionSeconds()` sets a minimum duration.
- `setInversionMinutes()` or `setInversionSeconds()` sets a minimum duration, default 60 seconds.
- `setIterationCompletionCriteria()` sets a minimum number of iterations.
- `setEnergyChangeCompletionCriteria()` sets an energy change condition.

### Selection Completion Criteria

The length of each `round` is controlled by selection completion criteria. Both can be set up, and each thread will end when one of them is satisfied at the beginning of an iteration step.
- `setSelectionInterval()` minimum round duration in seconds.
The length of each `round` is controlled by selection completion criteria. Only one selection criteria can be set up, and each thread will end when the criteria is satisfied at the beginning of an iteration step. If selection iterations are set up, the selection interval will be ignored.
- `setSelectionInterval()` minimum round duration in seconds, default 10 seconds.
- `setSelectionIterations()` the minimum number of iterations.

### Parallelism
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,16 +760,16 @@ public FaultSystemSolution runInversion() throws IOException, DocumentException
// ....
ProgressTrackingCompletionCriteria progress = new ProgressTrackingCompletionCriteria(completionCriteria);

List<CompletionCriteria> subCompletionCriteriaList = new ArrayList<>();
if (selectionIterations != null) {
subCompletionCriteriaList.add(new IterationCompletionCriteria(selectionIterations));
}
if (!repeatable){
subCompletionCriteriaList.add(TimeCompletionCriteria.getInSeconds(selectionInterval));
}
// this is the "sub completion criteria" - the amount of time and/or iterations
// between solution selection/synchronization
CompletionCriteria subCompletionCriteria = new CompoundCompletionCriteria(subCompletionCriteriaList);
// Note: since OpenSHA breaks if the subcompletionCriteria is a compound completion criteria, we only allow
// one criteria here. See https://github.com/GNS-Science/nzshm-opensha/issues/360
CompletionCriteria subCompletionCriteria;
if (selectionIterations != null) {
subCompletionCriteria = new IterationCompletionCriteria(selectionIterations);
} else {
subCompletionCriteria = TimeCompletionCriteria.getInSeconds(selectionInterval);
}

initialState = inversionInputGenerator.getInitialSolution();

Expand Down

0 comments on commit 079938d

Please sign in to comment.