Version:

salvus.opt.methods.lbfgs

salvus.opt.methods.lbfgs salvus opt methods lbfgs
L-BFGS approximation of Hessian and inverse Hessian.

Functions

apply_inverse_hessian()

Apply LBFGS inverse Hessian approximation to gradient of current iteration.
This method neither uses a custom initial Hessian nor a preconditioner. For either of those, see the two-stage procedure with apply_inverse_hessian_part1 and apply_inverse_hessian_part2 instead.
SIGNATURE
def apply_inverse_hessian(
    model: ModelType,
    current_iteration: Iteration[ModelType],
    available_iterations: dict[int, Iteration[ModelType]],
    max_lbfgs_history: int,
) -> ModelType: ...
ARGUMENTS
Required
model
Type:ModelType
Description:
Model to apply the inverse L-BFGS Hessian to.
Required
current_iteration
Type:Iteration[ModelType]
Description:
The current iteration.
Required
available_iterations
Type:dict[int, Iteration[ModelType]]
Description:
History of iterations.
Required
max_lbfgs_history
Type:int
Description:
Maximum number of previous iterations to consider for the L-BFGS approximation.
RETURNS
Return type: ModelType

apply_inverse_hessian_part1()

Apply LBFGS inverse Hessian approximation to model.
This computes the first part until the application of the initial Hessian approximation.
SIGNATURE
def apply_inverse_hessian_part1(
    model: ModelType,
    current_iteration: Iteration[ModelType],
    available_iterations: dict[int, Iteration[ModelType]],
    max_lbfgs_history: int,
) -> tuple[ModelType, float, list[LBFGSData]]: ...
ARGUMENTS
Required
model
Type:ModelType
Description:
Model to precondition.
Required
current_iteration
Type:Iteration[ModelType]
Description:
The current iteration.
Required
available_iterations
Type:dict[int, Iteration[ModelType]]
Description:
History of iterations
Required
max_lbfgs_history
Type:int
Description:
Maximum number of previous iterations to consider for the L-BFGS approximation.
RETURNS
Return type: tuple[ModelType, float, list[LBFGSData]]
model: Preconditioned model. gamma: Scaling factor for part 2. lbfgs_data: List of L-BFGS auxiliary data for part 2 sorted from oldest to newest.

apply_inverse_hessian_part2()

Apply LBFGS inverse Hessian approximation to model.
This computes the second part, which returns the product of inverse Hessian approximation times the initially provided model.
SIGNATURE
def apply_inverse_hessian_part2(
    preconditioned_model: ModelType,
    current_iteration: Iteration[ModelType],
    available_iterations: dict[int, Iteration[ModelType]],
    lbfgs_data: list[LBFGSData],
    gamma: float,
) -> ModelType: ...
ARGUMENTS
Required
preconditioned_model
Type:ModelType
Description:
Preconditioned model from part 1.
Required
current_iteration
Type:Iteration[ModelType]
Description:
The current iteration.
Required
available_iterations
Type:dict[int, Iteration[ModelType]]
Description:
Iterations available to the optimizer.
Required
lbfgs_data
Type:list[LBFGSData]
Description:
Precomputed quantities for iteration pairs in part 1, sorted from oldest to newest.
Required
gamma
Type:float
Description:
Scaling factor from part 1.
RETURNS
Return type: ModelType
The finalized matrix-vector product with the inverse L-BFGS Hessian.

apply_lbfgs_hessian()

Apply LBFGS Hessian approximation to model.
SIGNATURE
def apply_lbfgs_hessian(
    model: ModelType,
    lbfgs_data: dict[str, typing.Any],
    n_memory: int | None = None,
) -> ModelType: ...
ARGUMENTS
Required
model
Type:ModelType
Description:
Model to apply the LBFGS Hessian to.
Required
lbfgs_data
Type:dict[str, typing.Any]
Description:
L-BFGS data containing the sorted diffs of models and gradients.
Optional
n_memory
Type:int | None
Default value:None
Description:
Optional length of the L-BFGS history to only consider a subset of lbfgs_data.
RETURNS
Return type: ModelType

setup_lbfgs_data()

Build LBFGS auxiliary data from history of models and gradients. The input lists must be ordered from oldest to newest model.
SIGNATURE
def setup_lbfgs_data(
    models: list[ModelType] | None = None,
    gradients: list[ModelType] | None = None,
) -> dict: ...
ARGUMENTS
Optional
models
Type:list[ModelType] | None
Default value:None
Description:
List of previous models.
Optional
gradients
Type:list[ModelType] | None
Default value:None
Description:
List of previous gradients.
RETURNS
Return type: dict

Classes

LBFGSData

Data structure for L-BFGS approximation.
Naming convention follows standard notation from L-BFGS literature, e.g. Chapter 9 in Numerical Optimization by Nocedal and Wright.
SIGNATURE
class LBFGSData(builtins.object):
    def __init__(
        self,
        current_iteration_id: int,
        previous_iteration_id: int,
        rho: float,
        alpha: float,
    ) -> None: ...
ARGUMENTS
Required
current_iteration_id
Type:int
Description:
ID of the current iteration.
Required
previous_iteration_id
Type:int
Description:
ID of the previous iteration.
Required
rho
Type:float
Description:
Inverse dot product of model diff and gradient diff.
Required
alpha
Type:float
Description:
Scaling factor.

Methods

LBFGSData.to_dict()
Convert the L-BFGS data to a dictionary.
SIGNATURE
def to_dict(self) -> dict: ...
PAGE CONTENTS