sporco.pgm.pgm

Base classes for PGM algorithms.

Classes

PGM(*args, **kwargs)

Base class for Proximal Gradient Method (PGM) algorithms (see for example Ch.

PGMDFT(*args, **kwargs)

Base class for PGM algorithms with gradients and updates computed in the frequency domain.


Class Descriptions

class sporco.pgm.pgm.PGM(*args, **kwargs)[source]

Bases: sporco.common.IterativeSolver

Base class for Proximal Gradient Method (PGM) algorithms (see for example Ch. 10 of [5] and Sec. 4.2 and 4.3 of [39]). Algorithms such as FISTA [6] and a robust variant of FISTA [22] are also supported.

Solve optimisation problems of the form

\[\mathrm{argmin}_{\mathbf{x}} \; f(\mathbf{x}) + g(\mathbf{x}) \;\;,\]

where \(f, g\) are convex functions and \(f\) is smooth.

This class is intended to be a base class of other classes that specialise to specific optimisation problems.

After termination of the solve method, attribute itstat is a list of tuples representing statistics of each iteration. The default fields of the named tuple IterationStats are:

Iter : Iteration number

ObjFun : Objective function value

FVal : Value of smooth objective function component \(f\)

GVal : Value of objective function component \(g\)

F_Btrack : Value of objective function \(f + g\) (see Sec. 2.2 of [6]) when backtracking

Q_Btrack : Value of Quadratic approximation \(Q_L\) (see Sec. 2.3 of [6]) when backtracking

IterBtrack : Number of iterations in backtracking

Rsdl : Residual

L : Inverse of gradient step parameter

Time : Cumulative run time

Parameters
xshapetuple of ints

Shape of working variable X

dtypedata-type

Data type for working variables (overridden by ‘DataType’ option)

optPGM.Options object

Algorithm options

class Options(opt=None)[source]

Bases: sporco.cdict.ConstrainedDict

PGM algorithm options.

Options:

FastSolve : Flag determining whether non-essential computation is skipped. When FastSolve is True and Verbose is False, the functional value and related iteration statistics are not computed. If FastSolve is True residuals are also not calculated, in which case the residual-based stopping method is also disabled, with the number of iterations determined only by MaxMainIter.

Verbose : Flag determining whether iteration status is displayed.

StatusHeader : Flag determining whether status header and separator are displayed.

DataType : Specify data type for solution variables, e.g. np.float32.

X0 : Initial value for X variable.

Callback : Callback function to be called at the end of every iteration.

MaxMainIter : Maximum main iterations.

IterTimer : Label of the timer to use for iteration times.

RelStopTol : Relative convergence tolerance for fixed point residual (see Sec. 4.3 of [33]).

L : Inverse of gradient step parameter \(L\).

AutoStop : Options for adaptive stopping strategy (fixed point residual, see Sec. 4.3 of [33]).

Enabled : Flag determining whether the adaptive stopping relative parameter strategy is enabled.

Tau0 : numerator in adaptive criterion (\(\tau_0\) in [33]).

Monotone : Flag determining whether a monotone PGM version from [7] is used. Default is False.

Momentum : Momentum coefficient adaptation object. Standard options are Nesterov [6] (MomentumNesterov), Linear [14] (MomentumLinear), and GenLinear [40] (MomentumGenLinear), but a custom class derived from MomentumBase may also be specified. Default is MomentumNesterov.

StepSizePolicy : non-iterative L adaptation object. Standard options are Cauchy [63] Sec. 3 (StepSizePolicyCauchy), and Barzilai-Borwein [4] (StepSizePolicyBB), but a custom class derived from StepSizePolicyBase may also be specified. Default is None, no non-iterative L adaptation. Note that in case that both step size and Backtrack strategies are enabled only Backtrack will be used.

Backtrack : PGM backtracking options. Options are Standard [6] (BacktrackStandard) and Robust [22] (BacktrackRobust), but a custom class derived from BacktrackBase may also be specified. Default is None, no backtracking. Note that in case that both step size and Backtrack strategies are enabled only Backtrack will be used.

Parameters
optdict or None, optional (default None)

PGM algorithm options

fwiter = 4

Field width for iteration count display column

fpothr = 2

Field precision for other display columns

itstat_fields_objfn = ('ObjFun', 'FVal', 'GVal')

Fields in IterationStats associated with the objective function; see eval_objfun

itstat_fields_alg = ('Rsdl', 'F_Btrack', 'Q_Btrack', 'IterBTrack', 'L')

Fields in IterationStats associated with the specific solver algorithm

itstat_fields_extra = ()

Non-standard fields in IterationStats; see itstat_extra

hdrtxt_objfn = ('Fnc', 'f', 'g')

Display column headers associated with the objective function; see eval_objfun

hdrval_objfun = {'Fnc': 'ObjFun', 'f': 'FVal', 'g': 'GVal'}

Dictionary mapping display column headers in hdrtxt_objfn to IterationStats entries

xinit(xshape)[source]

Return initialiser for working variable X.

solve()[source]

Start (or re-start) optimisation. This method implements the framework for the iterations of a PGM algorithm. There is sufficient flexibility in overriding the component methods that it calls that it is usually not necessary to override this method in derived clases.

If option Verbose is True, the progress of the optimisation is displayed at every iteration. At termination of this method, attribute itstat is a list of tuples representing statistics of each iteration, unless option FastSolve is True and option Verbose is False.

Attribute timer is an instance of util.Timer that provides the following labelled timers:

init: Time taken for object initialisation by __init__

solve: Total time taken by call(s) to solve

solve_wo_func: Total time taken by call(s) to solve, excluding time taken to compute functional value and related iteration statistics

solve_wo_rsdl : Total time taken by call(s) to solve, excluding time taken to compute functional value and related iteration statistics as well as time take to compute residuals

solve_wo_btrack : Total time taken by call(s) to solve, excluding time taken to compute functional value and related iteration statistics as well as time take to compute residuals and implemented Backtrack mechanism

getmin()[source]

Get minimiser after optimisation.

xstep(grad=None)[source]

Compute proximal update (gradient descent + regularization). Optionally, a monotone PGM version from [7] is available.

ystep()[source]

Build next update by a smart combination of previous updates (standard PGM [6]). Optionally, a monotone PGM version from [7] is available.

eval_linear_approx(Dxy, gradY)[source]

Compute term \(\langle \nabla f(\mathbf{y}), \mathbf{x} - \mathbf{y} \rangle\) that is part of the quadratic function \(Q_L\) used for backtracking.

grad_f(V)[source]

Compute gradient of \(f\) at V.

Overriding this method is required.

prox_g(V)[source]

Compute proximal operator of \(g\).

Overriding this method is required.

hessian_f(V)[source]

Compute Hessian of \(f\) and apply to V.

Overriding this method is required.

on_iteration_start()[source]

Store previous X and Y states.

eval_Dxy()[source]

Evaluate difference of state and auxiliary state updates.

compute_residuals()[source]

Compute residuals and stopping thresholds.

classmethod hdrtxt()[source]

Construct tuple of status display column title.

classmethod hdrval()[source]

Construct dictionary mapping display column title to IterationStats entries.

iteration_stats(k, frcxd)[source]

Construct iteration stats record tuple.

eval_objfn()[source]

Compute components of objective function as well as total contribution to objective function.

itstat_extra()[source]

Non-standard entries for the iteration stats record tuple.

getitstat()[source]

Get iteration stats as named tuple of arrays instead of array of named tuples.

display_start()[source]

Set up status display if option selected. NB: this method assumes that the first entry is the iteration count and the last is the L value.

display_status(fmtstr, itst)[source]

Display current iteration status as selection of fields from iteration stats tuple.

display_end(nsep)[source]

Terminate status display if option selected.

var_x()[source]

Get \(\mathbf{x}\) variable.

var_y(y=None)[source]

Get, or update and get, \(\mathbf{y}\) variable.

var_xprv()[source]

Get \(\mathbf{x}\) variable of previous iteration.

var_momentum()[source]

Most momentum coefficient methods require iteration but Nesterov requires current t.

obfn_f(X)[source]

Compute \(f(\mathbf{x})\) component of PGM objective function.

Overriding this method is required (even if eval_objfun is overriden, since this method is required for backtracking).

obfn_g(X)[source]

Compute \(g(\mathbf{x})\) component of PGM objective function.

Overriding this method is required if eval_objfun is not overridden.

rsdl()[source]

Compute fixed point residual (see Sec. 4.3 of [33]).

class sporco.pgm.pgm.PGMDFT(*args, **kwargs)[source]

Bases: sporco.pgm.pgm.PGM

Base class for PGM algorithms with gradients and updates computed in the frequency domain.


Inheritance diagram of PGMDFT


Solve optimisation problems of the form

\[\mathrm{argmin}_{\mathbf{x}} \; f(\mathbf{x}) + g(\mathbf{x}) \;\;,\]

where \(f, g\) are convex functions and \(f\) is smooth.

This class specialises class PGM, but remains a base class for other classes that specialise to specific optimisation problems.

Parameters
xshapetuple of ints

Shape of working variable X (the primary variable)

Nvtuple of ints

Shape of spatial indices of variable X (needed for DFT)

axisNtuple of ints

Axis indices of spatial components of X (needed for DFT)

dtypedata-type

Data type for working variables

optPGMDFT.Options object

Algorithm options

class Options(opt=None)[source]

Bases: sporco.pgm.pgm.PGM.Options

PGMDFT algorithm options.

Options include all of those defined in PGM.Options.

Parameters
optdict or None, optional (default None)

PGMDFT algorithm options

xstep(gradf=None)[source]

Compute proximal update (gradient descent + constraint). Variables are mapped back and forth between input and frequency domains. Optionally, a monotone PGM version from [7] is available.

ystep()[source]

Update auxiliary state by a smart combination of previous updates in the frequency domain (standard PGM [6]). Optionally, a monotone PGM version from [7] is available.

on_iteration_start()[source]

Store previous X and Y in frequency domain.

eval_Dxy()[source]

Evaluate difference of state and auxiliary state in frequency domain.

var_x()[source]

Get \(\mathbf{x}\) variable in frequency domain.

var_y(y=None)[source]

Get, or update and get, \(\mathbf{y}\) variable in frequency domain.

var_xprv()[source]

Get \(\mathbf{x}\) variable of previous iteration in frequency domain.

eval_linear_approx(Dxy, gradY)[source]

Compute term \(\langle \nabla f(\mathbf{y}), \mathbf{x} - \mathbf{y} \rangle\) (in frequency domain) that is part of the quadratic function \(Q_L\) used for backtracking. Since this class computes the backtracking in the DFT, it is important to preserve the DFT scaling.