pycif.plugins.minimizers.congrad — API reference#
Configuration reference: congrad plugin
- pycif.plugins.minimizers.congrad.check.check_options(self, chi, **kwargs)[source]#
Validate CONGRAD parameters and fill missing ones with defaults.
- Parameters:
self (Plugin) – CONGRAD minimizer plugin instance. Reads/sets:
zreduc(default 1e-15),pevbnd(default 0.01),kvadim,kverbose(default 1),ldsolve(default True),maxiter(mandatory),knevecout.chi (np.ndarray) – initial iterate; used only to read its dimension.
**kwargs – unused; accepted for interface consistency.
- Returns:
selfwith all resolved parameters written back.- Return type:
- Raises:
AttributeError – if
maxiteris not defined on the plugin.
- pycif.plugins.minimizers.congrad.congrad.congrad(self, px, pgrad, planc1, **kwargs)[source]#
Execute the CONGRAD Lanczos inner loop.
Builds a Krylov subspace basis via the Lanczos iteration, solves the resulting tridiagonal least-squares problem, and simultaneously accumulates the leading eigenvector estimates (
pevecs) of the inverse Hessian.- Parameters:
self (Plugin) – CONGRAD plugin instance with all parameters already resolved by
check_options(zreduc,pevbnd,kvadim,maxiter,kverbose,ldsolve).px (np.ndarray) – initial iterate \(\chi_0\), shape
(n,).pgrad (np.ndarray) – initial gradient \(\nabla J(\chi_0)\), shape
(n,).planc1 (np.ndarray) – first Lanczos vector (copy of
pgradon entry), shape(n,).**kwargs – forwarded to the simulator.
- Returns:
(xopt, gradopt, preduc, pevecs, iiter)xopt(np.ndarray): optimal iterate.gradopt(np.ndarray): gradient atxopt.preduc(float): achieved relative gradient-norm reduction.pevecs(np.ndarray): estimated leading eigenvectors of \((\mathbf{I} + \mathbf{H}\mathbf{B}\mathbf{H}^\top)^{-1}\), shape(maxiter, n).iiter(int): number of Lanczos iterations performed.
- Return type:
tuple
- pycif.plugins.minimizers.congrad.minimize.minimize(self, finit, gradinit, chi0, **kwargs)[source]#
Run the CONGRAD Lanczos minimisation and return the optimal iterate.
- Parameters:
self (Plugin) – CONGRAD minimizer plugin instance.
finit (float) – initial cost function value \(J(\chi_0)\).
gradinit (np.ndarray) – initial gradient \(\nabla J(\chi_0)\), shape
(n,).chi0 (np.ndarray) – initial iterate \(\chi_0\), shape
(n,).**kwargs – forwarded to the simulator.
- Returns:
optimal iterate \(\chi_\mathrm{opt}\), shape
(n,).- Return type:
np.ndarray
- pycif.plugins.minimizers.congrad.wrevecs.wrevecs(kdprob, knits, kmaxit, kverbose, pevals, pbnds, pblim, pv, plancv, logfile)[source]#
Python version of the congrad minimization algorithm
Mike Fisher (ECMWF), April 2002 Frederic Chevallier (LSCE), April 2004, for the Python adaptation verbose from the Fortran subroutine:
WREVECS - Called from CONGRAD. Computes and saves eigenvectors.
Purpose. –
Interface. -
- CALL WREVECS (kdprob,knits,kmaxit,pevals,pbnds,pblim,pv,plancv,&
&kngood,ptheta)
Explicit arguments:
- Inputs: kdprob – dimension of the problem.
knits – Number of Lanczos vectors. kmaxit – First dimension of ‘pv’. kulout – unit number for information messages (e.g. standard output) kverbose – verbosity (0 => no messages, 1 => taciturn, 2 => verbose) pevals – Approximate eigenvalues (Ritz values). pbnds – Error bounds on eigenvectors. pblim – Error bound below which eigenvector is ‘good’. pv – Eigenvector matrix of tridiagonal problem. plancv – Lanczos vectors
- Outputs: kngood – Number of eigenvectors writen.
ptheta – Eigenvalues . pvcglev – Eigenvectors prcglev – Eigenvalues again (originally, this was a file)
Externals. -
Reference. -
None yet!
Author. -
Mike Fisher ECMWF
modifications. –
Original 20/5/94 M. Fisher 01-01-96 : Optionally save vectors in memory M. Fisher 26-11-96 : USE YOM_DISTRIBUTED_VECTORS M. Fisher 31-03-99 : Removed the last vestiges of the MIO package F. Chevallier 04/05: Translate into python