Version:

salvus.opt.methods.trustregion

salvus.opt.methods.trustregion salvus opt methods trustregion
Trust-region optimization methods.

Classes

TrustRegion

Base class of trust region methods.
The following rules apply for updating the trust region radius:
  1. 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_linf is applied pointwise for all model parameters, while initial_trust_region_radius measures distance in the model norm. If both parameters are provided, the more restrictive condition is used.
  2. In subsequent iterations, the trust region radius is adaptively adjusted. This is based on the following criteria, where rho\\rho is the ratio of actual and predicted reduction, Deltatr\\Delta_{tr} denotes the current trust region radius, and mathbfm\\|\\mathbf{m}\\| is the norm of the model update:
  • if rho<eta1\\rho < \\eta_1 (poor prediction of the quadratic model):
    Deltatrnew=min(sigma1Deltatr,mathbfm)\\Delta_{tr}^{new} = \\min(\\sigma^{-1}\\Delta_{tr}, \\|\\mathbf{m}\\|)
  • else if rho>eta2\\rho > \\eta_2 and mathbfmgeqgamma2Deltatr\\|\\mathbf{m}\\| \\geq \\gamma_2 \\Delta_{tr} (good prediction and model update sufficiently close to trust-region bound):
    Deltatrnew=sigmaDeltatr \\Delta_{tr}^{new} = \\sigma\\Delta_{tr}
  • else if mathbfm<gamma1Deltatr\\|\\mathbf{m}\\| < \\gamma_1 \\Delta_{tr} (small update):
    Deltatrnew=max(sigma1Deltatr,sigmamathbfm)\\Delta_{tr}^{new} = \\max(\\sigma^{-1}\\Delta_{tr}, \\sigma\\|\\mathbf{m}\\|)
SIGNATURE
class TrustRegion(salvus.flow.utils.serialization_helpers.SerializationMixin):
    def __init__(
        self,
        initial_trust_region_radius: salvus._core.types.float_ | None = None,
        initial_trust_region_linf: (
            salvus._core.types.float_ | typing.Callable | str | None
        ) = None,
        max_lbfgs_history: salvus._core.types.int_ = 10,
        max_lbfgs_radius: salvus._core.types.float_ | None = None,
        min_model_update_norm: salvus._core.types.float_ = 0.0,
        max_trial_models_per_iteration: salvus._core.types.int_ | None = None,
        fail_if_max_trial_models_reached: bool = True,
        convergence_criteria: dict | None = None,
        use_event_dependent_gradients: (
            bool | typing.Literal["auto-detect"]
        ) = "auto-detect",
        use_preconditioner: bool | None = True,
        tr_eta_1: salvus._core.types.float_ = 0.001,
        tr_eta_2: salvus._core.types.float_ = 0.5,
        tr_gamma_1: salvus._core.types.float_ = 0.5,
        tr_gamma_2: salvus._core.types.float_ = 0.9,
        tr_sigma: salvus._core.types.float_ = 2.0,
    ): ...
ARGUMENTS
Optional
initial_trust_region_radius
Type:salvus._core.types.float_ | None
Default value:None
Description:
Initial trust region radius (distance in model norm).
Optional
initial_trust_region_linf
Type:salvus._core.types.float_ | typing.Callable | str | None
Default value:None
Description:
Initial trust region radius (distance in L-infty norm). Either a float or a callback function (intended only for expert users).
Optional
max_lbfgs_history
Type:salvus._core.types.int_
Default value:10
Description:
Maximum history of L-BFGS approximation.
Optional
max_lbfgs_radius
Type:salvus._core.types.float_ | None
Default value:None
Description:
Maximum radius (in model space norm) of models considered in L-BFGS approximation.
Optional
min_model_update_norm
Type:salvus._core.types.float_
Default value:0.0
Description:
Threshold on the norm of the model update.
Optional
max_trial_models_per_iteration
Type:salvus._core.types.int_ | None
Default value:None
Description:
Maximum number of trial models to try at each iteration before returning.
Optional
fail_if_max_trial_models_reached
Type:bool
Default value:True
Description:
Flag to fail if the maximum number of trial models is reached. If set to False, the iteration will complete without failing. The final model of this iteration will then simply correspond to the final model of the previous iteration. If this happens in the first iteration, the inversion will still fail, even if set to False.
Optional
convergence_criteria
Type:dict | None
Default value:None
Description:
Dictionary of covergence criteria. This can also be provided later on.
Optional
use_event_dependent_gradients
Type:bool | typing.Literal['auto-detect']
Default value:'auto-detect'
Description:
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 "auto-detect".
Optional
use_preconditioner
Type:bool | None
Default value:True
Description:
Flag to skip preconditioner.
Optional
tr_eta_1
Type:salvus._core.types.float_
Default value:0.001
Description:
Steering parameter for adjusting the trust region; see formulas above.
Optional
tr_eta_2
Type:salvus._core.types.float_
Default value:0.5
Description:
Steering parameter for adjusting the trust region; see formulas above.
Optional
tr_gamma_1
Type:salvus._core.types.float_
Default value:0.5
Description:
Steering parameter for adjusting the trust region; see formulas above.
Optional
tr_gamma_2
Type:salvus._core.types.float_
Default value:0.9
Description:
Steering parameter for adjusting the trust region; see formulas above.
Optional
tr_sigma
Type:salvus._core.types.float_
Default value:2.0
Description:
Steering parameter for adjusting the trust region; see formulas above.

Class Methods

TrustRegion.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.

Methods

TrustRegion.iterate()
Run or continue a full iteration.
SIGNATURE
def iterate(
    self,
    it: Iteration[ModelType],
    task_manager: dict[str, typing.Callable],
    it_history: dict[int, Iteration[ModelType]] | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = True,
) -> None: ...
ARGUMENTS
Required
it
Type:Iteration[ModelType]
Description:
The current iteration.
Required
task_manager
Type:dict[str, typing.Callable]
Description:
Dictionary of custom callback functions to process the tasks (e.g. for computing misfits) issued during the inversion.
Optional
it_history
Type:dict[int, Iteration[ModelType]] | None
Default value:None
Description:
Dictionary with the iteration history.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:True
Description:
Whether to log messages to the logger.
TrustRegion.resume()
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.
SIGNATURE
def resume(
    self,
    it: Iteration[ModelType],
    it_history: dict[int, Iteration[ModelType]] | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = True,
) -> None: ...
ARGUMENTS
Required
it
Type:Iteration[ModelType]
Description:
Current iteration.
Optional
it_history
Type:dict[int, Iteration[ModelType]] | None
Default value:None
Description:
Dictionary with the iteration history.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:True
Description:
Whether to log messages to the logger.
TrustRegion.solve()
Run or continue an inversion until a maximum number of iterations is reached.
SIGNATURE
def solve(
    self,
    current_iteration: Iteration[ModelType],
    task_manager: dict[str, typing.Callable],
    max_iterations: int,
    it_history: dict[int, Iteration[ModelType]] | None = None,
    convergence_criteria: dict | None = None,
) -> Iteration[ModelType]: ...
ARGUMENTS
Required
current_iteration
Type:Iteration[ModelType]
Description:
The current iteration.
Required
task_manager
Type:dict[str, typing.Callable]
Description:
Dictionary of custom callback functions to process the tasks (e.g. for computing misfits) issued during the inversion.
Required
max_iterations
Type:int
Description:
Maximum number of iterations to be computed.
Optional
it_history
Type:dict[int, Iteration[ModelType]] | None
Default value:None
Description:
Dictionary with the iteration history.
Optional
convergence_criteria
Type:dict | None
Default value:None
Description:
Dictionary of convergence criteria. This can also be provided later on.
TrustRegion.to_json()
Serialize the object to dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...
ARGUMENTS
Optional
external_file_hash
Type:str | None
Default value:None
Description:
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.
Optional
timer
Type:Timer | None
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:int | None
Default value:None
Description:
MPI communicator, if any.
PAGE CONTENTS