Skip to content

Commit

Permalink
Merge pull request #294 from carterbox/time-terminate
Browse files Browse the repository at this point in the history
NEW: Stop reconstruction based on wall-time
  • Loading branch information
carterbox authored Dec 11, 2023
2 parents eb8a58d + 66bcb03 commit ba4d02c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tike/ptycho/ptycho.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ def iterate(self, num_iter: int) -> None:
psi_previous = self.parameters.psi[0].copy()
for i in range(num_iter):

if (
np.sum(self.parameters.algorithm_options.times)
> self.parameters.algorithm_options.time_limit
):
logger.info("Maximum reconstruction time exceeded.")
break

logger.info(f"{self.parameters.algorithm_options.name} epoch "
f"{len(self.parameters.algorithm_options.times):,d}")

Expand Down
3 changes: 3 additions & 0 deletions src/tike/ptycho/solvers/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class IterativeOptions(abc.ABC):
"""The number of epochs to consider for convergence monitoring. Set to
any value less than 2 to disable."""

time_limit: float = np.inf
"""Stop reconstruction when wall-time exceeds this number of seconds."""


@dataclasses.dataclass
class DmOptions(IterativeOptions):
Expand Down

0 comments on commit ba4d02c

Please sign in to comment.