optimizer
torch_admp.optimizer
Optimization algorithms for torch-admp.
This module implements various optimization algorithms used for charge equilibration and other optimization tasks in the torch-admp package, including line search, conjugate gradient methods, and other optimization utilities.
line_search(func_value: Callable, func_grads: Callable, x0: torch.Tensor, eps: float = 1e-06, fk: torch.Tensor = None, gk: torch.Tensor = None, pk: torch.Tensor = None, **kwargs) -> torch.Tensor
Perform line search to find optimal step size.
| PARAMETER | DESCRIPTION |
|---|---|
func_value
|
Function to compute the value of the objective function
TYPE:
|
func_grads
|
Function to compute gradients of the objective function
TYPE:
|
x0
|
Initial point
TYPE:
|
eps
|
Convergence threshold, by default 1e-6
TYPE:
|
fk
|
Function value at x0, by default None
TYPE:
|
gk
|
Gradient at x0, by default None
TYPE:
|
pk
|
Search direction, by default None
TYPE:
|
**kwargs
|
Additional keyword arguments passed to func_value and func_grads
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Optimal point found by line search |
Source code in torch_admp/optimizer.py
quadratic_optimize(func_value: Callable, func_grads: Callable, xk: torch.Tensor, eps: float = 0.0001, ls_eps: float = 0.0001, max_iter: int = 20, **kwargs)
Perform quadratic optimization with conjugate gradient method.
| PARAMETER | DESCRIPTION |
|---|---|
func_value
|
Function to compute the value of the objective function
TYPE:
|
func_grads
|
Function to compute gradients of the objective function
TYPE:
|
xk
|
Initial point
TYPE:
|
eps
|
Convergence threshold, by default 1e-4
TYPE:
|
ls_eps
|
Line search threshold, by default 1e-4
TYPE:
|
max_iter
|
Maximum number of iterations, by default 20
TYPE:
|
**kwargs
|
Additional keyword arguments passed to func_value and func_grads
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
Tuple containing (xk, fk, gk, converge_iter) where: - xk: optimal point - fk: function value at optimal point - gk: gradient at optimal point - converge_iter: iteration at which convergence was achieved |
Source code in torch_admp/optimizer.py
update_dy(gk: torch.Tensor, pk: torch.Tensor, gk_new: torch.Tensor) -> torch.Tensor
Update search direction using Dai-Yuan Algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
gk
|
Current gradient
TYPE:
|
pk
|
Current search direction
TYPE:
|
gk_new
|
New gradient
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Updated search direction |
Source code in torch_admp/optimizer.py
update_fr(gk: torch.Tensor, pk: torch.Tensor, gk_new: torch.Tensor) -> torch.Tensor
Update search direction using Fletcher-Reeves Algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
gk
|
Current gradient
TYPE:
|
pk
|
Current search direction
TYPE:
|
gk_new
|
New gradient
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Updated search direction |
Source code in torch_admp/optimizer.py
update_hs(gk: torch.Tensor, pk: torch.Tensor, gk_new: torch.Tensor) -> torch.Tensor
Update search direction using Hestenes-Stiefel Algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
gk
|
Current gradient
TYPE:
|
pk
|
Current search direction
TYPE:
|
gk_new
|
New gradient
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Updated search direction |
Source code in torch_admp/optimizer.py
update_hz(gk: torch.Tensor, pk: torch.Tensor, gk_new: torch.Tensor) -> torch.Tensor
Update search direction using Hager-Zhang Algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
gk
|
Current gradient
TYPE:
|
pk
|
Current search direction
TYPE:
|
gk_new
|
New gradient
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Updated search direction |
Source code in torch_admp/optimizer.py
update_pr(gk: torch.Tensor, pk: torch.Tensor, gk_new: torch.Tensor) -> torch.Tensor
Update search direction using Polak-Ribiere Algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
gk
|
Current gradient
TYPE:
|
pk
|
Current search direction
TYPE:
|
gk_new
|
New gradient
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Updated search direction |
Source code in torch_admp/optimizer.py
update_sd(gk: torch.Tensor, pk: torch.Tensor, gk_new: torch.Tensor) -> torch.Tensor
Update search direction using Steepest Descent Algorithm.
| PARAMETER | DESCRIPTION |
|---|---|
gk
|
Current gradient
TYPE:
|
pk
|
Current search direction
TYPE:
|
gk_new
|
New gradient
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Updated search direction |