salvus.opt.methods.trustregion
Trust-region optimization methods
Classes
TrustRegion
TrustRegionclass TrustRegion(salvus.flow.utils.serialization_helpers.SerializationMixin):
def __init__(
self,
initial_trust_region_radius: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
initial_trust_region_linf: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
max_lbfgs_history: Union[int, numpy.int32, numpy.int64] = 10,
max_lbfgs_radius: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
min_model_update_norm: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 0.0,
convergence_criteria: Dict = {},
use_event_dependent_gradients: Union[
bool, Literal["auto-detect"]
] = True,
use_preconditioner: Optional[bool] = True,
tr_eta_1: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 0.001,
tr_eta_2: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 0.5,
tr_gamma_1: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 0.5,
tr_gamma_2: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 0.9,
tr_sigma: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 2.0,
): ...Base class of trust region methods.
The following rules apply for updating the trust region radius:
-
In the first iteration, the initial trust region radius is computed such that the suggested model update satisfies the provided bound on its norm. Here,
initial_trust_region_linfis applied pointwise for all model parameters, whileinitial_trust_region_radiusmeasures distance in the model norm. If both parameters are provided, the more restrictive condition is used. -
In subsequent iterations, the trust region radius is adaptively adjusted. This is based on the following criteria, where is the ratio of actual and predicted reduction, denotes the current trust region radius, and is the norm of the model update:
- if (poor prediction of the quadratic model):
- else if and (good prediction and model update sufficiently close to trust-region bound):
- else if (small update):
initial_trust_region_radiusOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Initial trust region radius (distance in model norm).initial_trust_region_linfOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Initial trust region radius (distance in L-infty norm).max_lbfgs_historyUnion[int, numpy.int32, numpy.int64] — Maximum history of L-BFGS approximation.max_lbfgs_radiusOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Maximum radius (in model space norm) of models considered in L-BFGS approximation.min_model_update_normUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Threshold on the norm of the model update.convergence_criteriaDict — Dictionary of covergence criteria. This can also be provided later on.use_event_dependent_gradientsUnion[bool, Literal['auto-detect']] — Flag to indicate whether the event-dependent gradients should be computed independently or whether it is sufficient to directly obtain the summed gradient accumulated from all events. Can be set to “auto-detect”, which means that the InverseProblemConfiguration object will check if the forward simulation used event-dependent mesh masking and set the flag accordingly. Defaults to True.use_preconditionerOptional[bool] — Flag to skip preconditioner.tr_eta_1Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Steering parameter for adjusting the trust region; see formulas above.tr_eta_2Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Steering parameter for adjusting the trust region; see formulas above.tr_gamma_1Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Steering parameter for adjusting the trust region; see formulas above.tr_gamma_2Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Steering parameter for adjusting the trust region; see formulas above.tr_sigmaUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Steering parameter for adjusting the trust region; see formulas above.
from_json()
from_json()def from_json(d: Dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dDict — Dictionary containing its init parameters and a few other things.
iterate()
iterate()def iterate(
self,
it: salvus.opt.iteration.Iteration,
task_manager: Dict[str, Callable],
it_history: Optional[Dict[int, salvus.opt.iteration.Iteration]] = {},
) -> None: ...Run or continue a full iteration.
itsalvus.opt.iteration.Iteration — The current iteration.task_managerDict[str, Callable] — Dictionary of custom callback functions to process the tasks (e.g. for computing misfits) issued during the inversion.it_historyOptional[Dict[int, salvus.opt.iteration.Iteration]] — Dictionary with the iteration history.
resume()
resume()def resume(
self,
it: salvus.opt.iteration.Iteration,
it_history: Optional[Dict[int, salvus.opt.iteration.Iteration]] = {},
) -> None: ...Resume an iteration. This function continues to compute a model update until the next compute intensive task (e.g. querying misfits) is reached. The iteration data will be updated internally.
The function will raise an error if there are unfinished tasks.
itsalvus.opt.iteration.Iteration — Current iteration.it_historyOptional[Dict[int, salvus.opt.iteration.Iteration]] — Dictionary with the iteration history.
solve()
solve()def solve(
self,
current_iteration: salvus.opt.iteration.Iteration,
task_manager: Dict[str, Callable],
max_iterations: int,
it_history: Dict[int, salvus.opt.iteration.Iteration] = {},
convergence_criteria: Dict = {},
) -> salvus.opt.iteration.Iteration: ...Run or continue an inversion until a maximum number of iterations is reached.
current_iterationsalvus.opt.iteration.Iteration — The current iteration.task_managerDict[str, Callable] — Dictionary of custom callback functions to process the tasks (e.g. for computing misfits) issued during the inversion.max_iterationsint — Maximum number of iterations to be computed.it_historyDict[int, salvus.opt.iteration.Iteration] — Dictionary with the iteration history.convergence_criteriaDict — Dictionary of covergence criteria. This can also be provided later on.
to_json()
to_json()def to_json(self, external_file_hash: Optional[str] = None) -> Dict: ...Serialize the object to dictionary that can be written to JSON.
external_file_hashOptional[str] — Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.