CNDSM  1.00
Stepsize Class Referenceabstract

The class Stepsize provides an interface for the stepsize rule, to be used in the SubGrad solver [see SubGrad.h]. More...

#include <Stepsize.h>

Inheritance diagram for Stepsize:
ColorTV FumeroTV Polyak PrimalDual

Public Member Functions

Constructor
 Stepsize (SubGrad *slvr, istream *iStrm=0)
 Constructor of the class. More...
 
 Stepsize (SubGrad *slvr, istream *iStrm=0)
 Constructor of the class. More...
 
Other initializations
virtual void SetSTPLog (ostream *outs=0, const char lvl=0)
 The class outputs "log" information onto the ostream pointed by outs. More...
 
virtual void Format (void)
 The method initializes the stepsize rule. More...
 
virtual void SetSTPLog (ostream *outs=0, const char lvl=0)
 The class outputs "log" information onto the ostream pointed by outs. More...
 
virtual void Format (void)
 The method initializes the stepsize rule. More...
 
Stepsize computation
virtual void NewStep (void)=0
 This method must be called before GetStepsize() [see below]. More...
 
virtual bool NeedsdkM1Gk (void)
 Returns true if the stepsize requires the scalar product $ d_{i-1}^{\top} g_i$. More...
 
virtual void NewStep (void)=0
 This method must be called before GetStepsize() [see below]. More...
 
virtual bool NeedsdkM1Gk (void)
 Returns true if the stepsize requires the scalar product $ d_{i-1}^{\top} g_i$. More...
 
Reading the solution
virtual HpNum GetStepsize (bool StepIsIncr=false)
 This function must be called after NewStep() [see above]. More...
 
virtual HpNum GetLev (void)
 This function must be called after NewStep() [see above]. More...
 
virtual HpNum GetBeta (void)
 This function must be called after NewStep() [see above]. More...
 
virtual HpNum GetStepsize (bool StepIsIncr=false)
 This function must be called after NewStep() [see above]. More...
 
virtual HpNum GetLev (void)
 This function must be called after NewStep() [see above]. More...
 
virtual HpNum GetBeta (void)
 This function must be called after NewStep() [see above]. More...
 
Adding / removing / changing data
virtual void SetMaxBeta (const HpNum alpha)
 Changes the maximum value of $ \beta_i $ for a target value stepsize rule. More...
 
virtual void SetMaxBeta (const HpNum alpha)
 Changes the maximum value of $ \beta_i $ for a target value stepsize rule. More...
 
Destructor
virtual ~Stepsize ()
 
virtual ~Stepsize ()
 

Protected Member Functions

virtual bool UpdateTargetLevel (void)
 It tries to provide a new target level $ f^{lev}_i $. More...
 
virtual bool UpdateTargetLevel (void)
 It tries to provide a new target level $ f^{lev}_i $. More...
 
Protected methods to read from Subgrad

These methods are used to provide access to the information stored into the SubGrad object.

Stepsize is a "friend" of SubGrad and therefore it can read its protected data structures, but classes derived from Stepsize are not friend of SubGrad and cannot. This is why these methods are defined in the base class (and implemented in SubGrad.C).

HpNum GetCoeffDefl (void)
 Returns the deflection coefficient $\alpha_i$. More...
 
FiOracleGetOracle (void)
 Returns the pointer to FiOracle. More...
 
cHpNum GetGiNorm (void)
 Returns the norm of the subgradient $ g_i $. More...
 
cHpNum GetDNorm (void)
 Returns the norm of the direction $ d_i $. More...
 
cHpNum GetdGk (void)
 Returns the scalar product $ g_i^{\top} d_i$. More...
 
HpNum GetdkM1Gk (void)
 Returns the scalar product $ g_i^{\top} d_{i-1}$. More...
 
Index GetNItIcr (void)
 Returns NItIncr, the parameter for incremental iterations [see SubGrad.h].
 
cHpNum ReadFkVal (void)
 Returns FiLambda [ see SubGrad.h ]. More...
 
cHpNum ReadFiBar (void)
 Returns FiBar [ see SubGrad.h ]. More...
 
HpNum GetCoeffDefl (void)
 Returns the deflection coefficient $\alpha_i$. More...
 
FiOracleGetOracle (void)
 Returns the pointer to FiOracle. More...
 
cHpNum GetGiNorm (void)
 Returns the norm of the subgradient $ g_i $. More...
 
cHpNum GetDNorm (void)
 Returns the norm of the direction $ d_i $. More...
 
cHpNum GetdGk (void)
 Returns the scalar product $ g_i^{\top} d_i$. More...
 
HpNum GetdkM1Gk (void)
 Returns the scalar product $ g_i^{\top} d_{i-1}$. More...
 
Index GetNItIcr (void)
 Returns NItIncr, the parameter for incremental iterations [see SubGrad.h].
 
cHpNum ReadFkVal (void)
 Returns FiLambda [ see SubGrad.h ]. More...
 
cHpNum ReadFiBar (void)
 Returns FiBar [ see SubGrad.h ]. More...
 

Protected Attributes

SubGradSolver
 (pointer to) the SubGrad solver
 
ostream * STPLog
 the output stream object
 
char STPLLvl
 the "level of verbosity"
 
HpNum FiLev
 the target level $ f^{lev}_i $
 
HpNum Beta
 beta factor $ \beta_i $
 
HpNum MaxBeta
 maximum value for beta factor
 
HpNum LpsFct
 scaling factor
 

Detailed Description

The class Stepsize provides an interface for the stepsize rule, to be used in the SubGrad solver [see SubGrad.h].

The main functions of the class are NewStep() and GetStepsize(). While NewStep() sets up a new step, the value $\nu_i$ is passed to the SubGrad solver by means of a call to GetStepsize().

The user must extend the class to one or more stepsize rules following this interface.

Constructor & Destructor Documentation

Stepsize ( SubGrad slvr,
istream *  iStrm = 0 
)
inline

Constructor of the class.

The parameter `iStrm', if provided, is taken as a pointer to a istream from which the algorithmic parameters for the stepsize formula are sequentially read in the following order. Each must be placed at the beginning of a separate line, max 255 characters long, with all the rest of the line up to the first newline character '
' (apart from a separating whitespace) being available for comments. Any line whose first character is '#' and any blank line is ignored. If 0 is passed, the file ends before reaching a given parameter, or some parameter is in the wrong format, each non-specified parameter is given a default value, shown in [] below.

Only a few parameters are deemed to be general enough to be put in the basic Stepsize class; however, the same stream can be used for passing the (possibly many more) algorithmic parameters to the derived classes. Since the constructor of Stepsize is executed before the ones of the derived classes, the specific parameters for the derived classes have just to be found in the stream after those of the base class.

HpNum LpsFct [1] a general scaling factor (for instance, it is the Lipschitz factor in the target value SR)

Stepsize ( SubGrad slvr,
istream *  iStrm = 0 
)
inline

Constructor of the class.

The parameter `iStrm', if provided, is taken as a pointer to a istream from which the algorithmic parameters for the stepsize formula are sequentially read in the following order. Each must be placed at the beginning of a separate line, max 255 characters long, with all the rest of the line up to the first newline character '
' (apart from a separating whitespace) being available for comments. Any line whose first character is '#' and any blank line is ignored. If 0 is passed, the file ends before reaching a given parameter, or some parameter is in the wrong format, each non-specified parameter is given a default value, shown in [] below.

Only a few parameters are deemed to be general enough to be put in the basic Stepsize class; however, the same stream can be used for passing the (possibly many more) algorithmic parameters to the derived classes. Since the constructor of Stepsize is executed before the ones of the derived classes, the specific parameters for the derived classes have just to be found in the stream after those of the base class.

HpNum LpsFct [1] a general scaling factor (for instance, it is the Lipschitz factor in the target value SR)

Member Function Documentation

virtual void SetSTPLog ( ostream *  outs = 0,
const char  lvl = 0 
)
inlinevirtual

The class outputs "log" information onto the ostream pointed by outs.

lvl controls the "level of verbosity" of the code: lvl == 0 means that nothing at all is printed, and values larger than 0 mean increasing amounts of information, the specific effect of each value being derived- class-dependent. outs == 0 implies lvl == 0.

Referenced by ColorTV::ColorTV(), FumeroTV::FumeroTV(), and Polyak::Polyak().

virtual void Format ( void  )
inlinevirtual

The method initializes the stepsize rule.

Referenced by ColorTV::ColorTV(), and FumeroTV::FumeroTV().

virtual void NewStep ( void  )
pure virtual

This method must be called before GetStepsize() [see below].

This is indeed the core of every derived class, producing a new step.

If the derived class implements a target value stepsize rule, the method must compute both the scalar $ \beta_i $ and the level $ f^{lev}_i $.

Typically, the previous step will be unavailable after the call to NewStep() [see GetStepsize()].

virtual bool NeedsdkM1Gk ( void  )
inlinevirtual

Returns true if the stepsize requires the scalar product $ d_{i-1}^{\top} g_i$.

The default implementation don't require this value.

virtual HpNum GetStepsize ( bool  StepIsIncr = false)
inlinevirtual

This function must be called after NewStep() [see above].

It returns the step value $\nu_i$.

The default implementation offers support to the target value SR . For that rule the computation is based on the scalar $ \beta_i $ and the level $ f^{lev}_i $ [see NewStep()], i.e. the stepsize has the form of:

\[ \nu_i = \beta_i ( \, f_i - f^{lev}_i \, ) / \|d_i\|^2 . \]

If true is passed, is required the stepsize for an inner iteration, otherwise for an outer iteration.

virtual HpNum GetLev ( void  )
inlinevirtual

This function must be called after NewStep() [see above].

The default implementation returns the level $ f^{lev}_i $ for a target value stepsize rule [see below]. It should throw exception for other forms of the stepsize rule.

virtual HpNum GetBeta ( void  )
inlinevirtual

This function must be called after NewStep() [see above].

The default implementation returns the scalar $ \beta_i $ for a target value stepsize rule [see below]. It should throw exception for other forms of the stepsize rule.

virtual void SetMaxBeta ( const HpNum  alpha)
inlinevirtual

Changes the maximum value of $ \beta_i $ for a target value stepsize rule.

Typically, the method implements the safe rule of the stepsize-restricted approach. Passing the deflection coefficient $ \alpha_i $ does exactly this job.

virtual bool UpdateTargetLevel ( void  )
inlineprotectedvirtual

It tries to provide a new target level $ f^{lev}_i $.

It true is returned, the level has been changed. By default, it returns false.

HpNum GetCoeffDefl ( void  )
protected

Returns the deflection coefficient $\alpha_i$.

FiOracle* GetOracle ( void  )
protected

Returns the pointer to FiOracle.

Thus, stepsize can ask directly the FiOracle object for the function information.

Referenced by ColorTV::ColorTV(), and FumeroTV::FumeroTV().

cHpNum GetGiNorm ( void  )
protected

Returns the norm of the subgradient $ g_i $.

cHpNum GetDNorm ( void  )
protected

Returns the norm of the direction $ d_i $.

cHpNum GetdGk ( void  )
protected

Returns the scalar product $ g_i^{\top} d_i$.

Referenced by ColorTV::ColorTV().

HpNum GetdkM1Gk ( void  )
protected

Returns the scalar product $ g_i^{\top} d_{i-1}$.

cHpNum ReadFkVal ( void  )
protected

Returns FiLambda [ see SubGrad.h ].

Referenced by ColorTV::ColorTV(), and FumeroTV::FumeroTV().

cHpNum ReadFiBar ( void  )
protected

Returns FiBar [ see SubGrad.h ].

virtual void SetSTPLog ( ostream *  outs = 0,
const char  lvl = 0 
)
inlinevirtual

The class outputs "log" information onto the ostream pointed by outs.

lvl controls the "level of verbosity" of the code: lvl == 0 means that nothing at all is printed, and values larger than 0 mean increasing amounts of information, the specific effect of each value being derived- class-dependent. outs == 0 implies lvl == 0.

virtual void Format ( void  )
inlinevirtual

The method initializes the stepsize rule.

virtual void NewStep ( void  )
pure virtual

This method must be called before GetStepsize() [see below].

This is indeed the core of every derived class, producing a new step.

If the derived class implements a target value stepsize rule, the method must compute both the scalar $ \beta_i $ and the level $ f^{lev}_i $.

Typically, the previous step will be unavailable after the call to NewStep() [see GetStepsize()].

virtual bool NeedsdkM1Gk ( void  )
inlinevirtual

Returns true if the stepsize requires the scalar product $ d_{i-1}^{\top} g_i$.

The default implementation don't require this value.

virtual HpNum GetStepsize ( bool  StepIsIncr = false)
inlinevirtual

This function must be called after NewStep() [see above].

It returns the step value $\nu_i$.

The default implementation offers support to the target value SR . For that rule the computation is based on the scalar $ \beta_i $ and the level $ f^{lev}_i $ [see NewStep()], i.e. the stepsize has the form of:

\[ \nu_i = \beta_i ( \, f_i - f^{lev}_i \, ) / \|d_i\|^2 . \]

If true is passed, is required the stepsize for an inner iteration, otherwise for an outer iteration.

virtual HpNum GetLev ( void  )
inlinevirtual

This function must be called after NewStep() [see above].

The default implementation returns the level $ f^{lev}_i $ for a target value stepsize rule [see below]. It should throw exception for other forms of the stepsize rule.

virtual HpNum GetBeta ( void  )
inlinevirtual

This function must be called after NewStep() [see above].

The default implementation returns the scalar $ \beta_i $ for a target value stepsize rule [see below]. It should throw exception for other forms of the stepsize rule.

virtual void SetMaxBeta ( const HpNum  alpha)
inlinevirtual

Changes the maximum value of $ \beta_i $ for a target value stepsize rule.

Typically, the method implements the safe rule of the stepsize-restricted approach. Passing the deflection coefficient $ \alpha_i $ does exactly this job.

virtual bool UpdateTargetLevel ( void  )
inlineprotectedvirtual

It tries to provide a new target level $ f^{lev}_i $.

It true is returned, the level has been changed. By default, it returns false.

HpNum GetCoeffDefl ( void  )
protected

Returns the deflection coefficient $\alpha_i$.

FiOracle* GetOracle ( void  )
protected

Returns the pointer to FiOracle.

Thus, stepsize can ask directly the FiOracle object for the function information.

cHpNum GetGiNorm ( void  )
protected

Returns the norm of the subgradient $ g_i $.

cHpNum GetDNorm ( void  )
protected

Returns the norm of the direction $ d_i $.

cHpNum GetdGk ( void  )
protected

Returns the scalar product $ g_i^{\top} d_i$.

HpNum GetdkM1Gk ( void  )
protected

Returns the scalar product $ g_i^{\top} d_{i-1}$.

cHpNum ReadFkVal ( void  )
protected

Returns FiLambda [ see SubGrad.h ].

cHpNum ReadFiBar ( void  )
protected

Returns FiBar [ see SubGrad.h ].