trellis-runner
Trellis
Trellis is a generic, event-driven numerical engine for iterative procedures.
It provides a structured execution environment for algorithms that evolve a state over time, producing progress signals, convergence diagnostics, and termination conditions.
Policies
Policies control solver execution.
During a run, the engine collects progress information from the procedure and passes it to one or more policies. Policies inspect this information and decide whether the solver should:
- continue running,
- terminate successfully,
- terminate early,
- or request some other engine action.
Policies are the primary mechanism used to implement convergence criteria, iteration limits, stagnation detection and timeout handling.
Policies vs Observers
Policies influence solver behaviour.
Observers only observe solver behaviour.
A policy may terminate a calculation. An observer may not.
Progress ──► Policy ──► Engine Action
│
└────► Observer
Attaching Policies
Policies are attached through the builder.
use ;
;
;
;
let engine = MyProcedure
.build_for
.with_initial_state
.and_policy
.and_policy
.finalise;
Multiple policies may be attached.
The engine stops as soon as any policy requests termination.
Built-in Policies
Trellis provides several commonly useful policies.
| Policy | Purpose |
|---|---|
MaxIterationPolicy |
Stop the engine after a fixed number of iterations |
TimeoutPolicy |
Stops the engine after a maximum wall-clock duration |
AbsoluteTolerancePolicy |
Stops the engine when the mean absolute error over a rolling window falls below a user-defined tolerance |
RelativeTolerancePolicy |
Stops the engine when the mean relative error over a rolling window falls below a user-defined tolerance |
StagnationPolicy |
Stops the engine when the improvement of the best observed value over a rolling window falls below a relative tolerance threshold |
NoProgressPolicy |
Stops the engine when the best observed objective value fails to improve by a relative tolerance for a specified number of consecutive iterations |
TargetValuePolicy |
Stops the engine when the mean absolute distance to a target value remains below a specified tolerance over a rolling window |
CheckpointPolicy |
Define frequency of checkpoint generation |
License: MIT