qimpy.algorithms.LinearSolve

class LinearSolve(*, checkpoint_in, comm, n_iterations, gradient_threshold, name='')

Bases: Generic[Vector], ABC, TreeNode

Parameters:
  • checkpoint_in (CheckpointPath)

  • comm (Comm)

  • n_iterations (int)

  • gradient_threshold (float)

  • name (str)

__init__(*, checkpoint_in, comm, n_iterations, gradient_threshold, name='')

Initialize minimization algorithm parameters.

Parameters:
  • checkpoint_in (CheckpointPath)

  • comm (MPI.Comm)

  • n_iterations (int)

  • gradient_threshold (float)

  • name (str)

Return type:

None

Methods

__init__

Initialize minimization algorithm parameters.

add_child

Construct child object self.`attr_name` of type cls.

add_child_one_of

Invoke add_child on one of several child options in args.

hessian

Multiply by the hessian of the objective function.

precondition

Multiply by the preconditioner.

save_checkpoint

Save self and all children in hierarchy to cp_path.

solve

Solve hessian`(`x) = rhs by the conjugate-gradients method.

Attributes

comm

Communicator over which algorithm operates in unison

n_iterations

Maximum number of iterations

gradient_threshold

Convergence threshold on preconditioned residual norm

name

Line prefix in log for convergence progress; don't log if empty

child_names

Names of attributes with child objects.

variant_name

Version of children having variants (if any)

abstractmethod hessian(v)

Multiply by the hessian of the objective function. Derived classes must override this to specify the objective function.

Parameters:

v (Vector)

Return type:

Vector

precondition(v)

Multiply by the preconditioner. Derived classes may override this to specify a preconditioner (defaullt: none).

Parameters:

v (Vector)

Return type:

Vector

solve(rhs, x)

Solve hessian`(`x) = rhs by the conjugate-gradients method. Start from initial guess in x and return the result in place. Return the number of iterations taken to converge.

Parameters:
Return type:

int

comm: Comm

Communicator over which algorithm operates in unison

gradient_threshold: float

Convergence threshold on preconditioned residual norm

n_iterations: int

Maximum number of iterations

name: str

Line prefix in log for convergence progress; don’t log if empty