STIR 6.4.0
stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, ParentT > Class Template Reference

A base class for sums of 'generalised' objective functions, i.e. objective functions for which at least a 'gradient' is defined. More...

#include "stir/recon_buildblock/SumOfGeneralisedObjectiveFunctions.h"

Inheritance diagram for stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, ParentT >:

Public Member Functions

template<typename IterT>
 SumOfGeneralisedObjectiveFunctions (IterT begin, IterT end)
 
template<typename IterT>
void set_functions (IterT begin, IterT end)
 
virtual Succeeded set_up (shared_ptr< TargetT > const &target_sptr)
 Has to be called before using this object.
 
virtual void compute_sub_gradient_without_penalty (TargetT &gradient, const TargetT &current_estimate, const int subset_num)
 This computes the gradient of the unregularised objective function at the current_estimate.
 
virtual double actual_compute_objective_function_without_penalty (const TargetT &current_estimate, const int subset_num)
 Implementation of function that computes the objective function for the current subset.
 
virtual int set_num_subsets (const int num_subsets)
 Attempts to change the number of subsets.
 
- Public Member Functions inherited from stir::GeneralisedObjectiveFunction< TargetT >
virtual TargetT * construct_target_ptr () const =0
 Creates a suitable target as determined by the parameters.
 
virtual void compute_sub_gradient (TargetT &gradient, const TargetT &current_estimate, const int subset_num)
 Compute the subset-gradient of the objective function at current_estimate.
 
virtual void compute_gradient (TargetT &gradient, const TargetT &current_estimate)
 Compute the gradient of the objective function at the current_estimate.
 
virtual void compute_gradient_without_penalty (TargetT &gradient, const TargetT &current_estimate)
 Compute the gradient of the unregularised objective function at the current_estimate.
 
virtual double compute_objective_function_without_penalty (const TargetT &current_estimate, const int subset_num)
 Compute the value of the unregularised sub-objective function at the current_estimate.
 
virtual double compute_objective_function_without_penalty (const TargetT &current_estimate)
 Compute the value of the unregularised objective function at the current_estimate.
 
double compute_penalty (const TargetT &current_estimate, const int subset_num)
 Compute the value of the sub-penalty at the current_estimate.
 
double compute_penalty (const TargetT &current_estimate)
 Compute the value of the penalty at the current_estimate.
 
double compute_objective_function (const TargetT &current_estimate, const int subset_num)
 Compute the value of the sub-objective function at the current_estimate.
 
double compute_objective_function (const TargetT &current_estimate)
 Compute the value of the objective function at the current_estimate.
 
double compute_value (const TargetT &current_estimate)
 Alias for compute_objective_function(const TargetT&)
 
virtual void fill_nonidentifiable_target_parameters (TargetT &target, const float value) const
 Fill any elements that we cannot estimate with a fixed value.
 
Succeeded add_multiplication_with_approximate_sub_Hessian_without_penalty (TargetT &output, const TargetT &input, const int subset_num) const
 Functions that multiply the approximate (sub)Hessian with a \'vector\'.
 
Succeeded add_multiplication_with_approximate_sub_Hessian (TargetT &output, const TargetT &input, const int subset_num) const
 
Succeeded add_multiplication_with_approximate_Hessian_without_penalty (TargetT &output, const TargetT &input) const
 
Succeeded add_multiplication_with_approximate_Hessian (TargetT &output, const TargetT &input) const
 
Succeeded accumulate_Hessian_times_input (TargetT &output, const TargetT &current_image_estimate, const TargetT &input) const
 Functions that multiply the True (sub)Hessian with a \'vector\'.
 
Succeeded accumulate_Hessian_times_input_without_penalty (TargetT &output, const TargetT &current_image_estimate, const TargetT &input) const
 
Succeeded accumulate_sub_Hessian_times_input (TargetT &output, const TargetT &current_image_estimate, const TargetT &input, const int subset_num) const
 
Succeeded accumulate_sub_Hessian_times_input_without_penalty (TargetT &output, const TargetT &current_image_estimate, const TargetT &input, const int subset_num) const
 
std::string get_objective_function_values_report (const TargetT &current_estimate)
 Construct a string with info on the value of objective function with and without penalty.
 
int get_num_subsets () const
 Return the number of subsets in-use.
 
virtual std::unique_ptr< ExamInfoget_exam_info_uptr_for_target () const
 
bool subsets_are_approximately_balanced () const
 Checks of the current subset scheme is approximately balanced.
 
bool subsets_are_approximately_balanced (std::string &warning_message) const
 Checks of the current subset scheme is approximately balanced and constructs a warning message.
 
bool prior_is_zero () const
 check if the prior is set (or the penalisation factor is 0)
 
GeneralisedPrior< TargetT > *const get_prior_ptr () const
 Read-only access to the prior.
 
shared_ptr< GeneralisedPrior< TargetT > > get_prior_sptr ()
 
void set_prior_sptr (const shared_ptr< GeneralisedPrior< TargetT > > &)
 Change the prior.
 
virtual void set_input_data (const shared_ptr< ExamData > &)=0
 set_input_data
 
virtual const ExamDataget_input_data () const =0
 get input data
 
virtual void set_additive_proj_data_sptr (const shared_ptr< ExamData > &)=0
 set_additive_proj_data_sptr
 
virtual void set_normalisation_sptr (const shared_ptr< BinNormalisation > &)=0
 set_normalisation_sptr
 
- Public Member Functions inherited from stir::RegisteredObjectBase
virtual std::string get_registered_name () const =0
 Returns the name of the type of the object.
 
- Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
 
ParsingObjectoperator= (const ParsingObject &)
 
bool parse (std::istream &f)
 
bool parse (const char *const filename)
 
void ask_parameters ()
 
virtual std::string parameter_info ()
 

Protected Types

typedef std::vector< ObjFuncT > _functions_type
 
typedef _functions_type::iterator _functions_iterator_type
 
typedef _functions_type::const_iterator _functions_const_iterator_type
 
- Protected Types inherited from stir::RegisteredObject< GeneralisedObjectiveFunction< TargetT > >
typedef GeneralisedObjectiveFunction< TargetT > *(* RootFactory) (std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
 
typedef FactoryRegistry< std::string, RootFactory, interfile_lessRegistryType
 The type of the registry.
 

Protected Member Functions

virtual bool actual_subsets_are_approximately_balanced (std::string &warning_message) const
 Implementation of function that checks subset balancing.
 
void set_defaults () override
 sets any default values
 
void initialise_keymap () override
 sets parsing keys
 
virtual Succeeded actual_add_multiplication_with_approximate_sub_Hessian_without_penalty (TargetT &output, const TargetT &input, const int subset_num) const
 Implementation of the function that multiplies the approximate sub-Hessian with a vector.
 
virtual Succeeded actual_accumulate_sub_Hessian_times_input_without_penalty (TargetT &output, const TargetT &current_image_estimate, const TargetT &input, const int subset_num) const
 Implementation of the function computes the sub-Hessian and multiplies by a vector.
 
virtual bool post_processing ()
 This will be called at the end of the parsing.
 
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called.
 

Protected Attributes

_functions_type _functions
 
int num_subsets
 
bool already_set_up
 
shared_ptr< GeneralisedPrior< TargetT > > prior_sptr
 
KeyParser parser
 

Additional Inherited Members

- Static Public Member Functions inherited from stir::RegisteredObject< GeneralisedObjectiveFunction< TargetT > >
static GeneralisedObjectiveFunction< TargetT > * read_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream.
 
static GeneralisedObjectiveFunction< TargetT > * ask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type)
 
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream.
 
- Static Protected Member Functions inherited from stir::RegisteredObject< GeneralisedObjectiveFunction< TargetT > >
static RegistryTyperegistry ()
 Static function returning the registry.
 

Detailed Description

template<typename ObjFuncT, typename TargetT, typename ParentT = GeneralisedObjectiveFunction<TargetT>>
class stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, ParentT >

A base class for sums of 'generalised' objective functions, i.e. objective functions for which at least a 'gradient' is defined.

Todo

document why use of ParentT template

doc subsets

Member Function Documentation

◆ set_up()

template<typename ObjFuncT, typename TargetT, typename Parent>
Succeeded stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, Parent >::set_up ( shared_ptr< TargetT > const & target_sptr)
inlinevirtual

Has to be called before using this object.

Will call set_up() for all terms in the sum, but will stop as soon as one set_up() fails.

Reimplemented from stir::GeneralisedObjectiveFunction< TargetT >.

References set_up().

Referenced by set_up().

◆ compute_sub_gradient_without_penalty()

template<typename ObjFuncT, typename TargetT, typename Parent>
void stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, Parent >::compute_sub_gradient_without_penalty ( TargetT & gradient,
const TargetT & current_estimate,
const int subset_num )
inlinevirtual

This computes the gradient of the unregularised objective function at the current_estimate.

It is computed as the sum of the subgradients for each term, depending on the subset scheme.

Implements stir::GeneralisedObjectiveFunction< TargetT >.

References compute_sub_gradient_without_penalty().

Referenced by compute_sub_gradient_without_penalty().

◆ actual_compute_objective_function_without_penalty()

template<typename ObjFuncT, typename TargetT, typename Parent>
double stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, Parent >::actual_compute_objective_function_without_penalty ( const TargetT & current_estimate,
const int subset_num )
inlinevirtual

Implementation of function that computes the objective function for the current subset.

See also
compute_objective_function_without_penalty(const Target&,const int)
Developer\'s note

The reason we have this function is that overloading a function in a derived class, hides all functions of the same name.

Implements stir::GeneralisedObjectiveFunction< TargetT >.

Reimplemented in stir::PoissonLogLikelihoodWithLinearModelForMeanAndGatedProjDataWithMotion< TargetT >.

References actual_compute_objective_function_without_penalty().

Referenced by actual_compute_objective_function_without_penalty().

◆ set_num_subsets()

template<typename ObjFuncT, typename TargetT, typename Parent>
int stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, Parent >::set_num_subsets ( const int num_subsets)
inlinevirtual

Attempts to change the number of subsets.

Returns
The number of subsets that will be used later, which is not guaranteed to be what you asked for.

Implements stir::GeneralisedObjectiveFunction< TargetT >.

Reimplemented in stir::PoissonLogLikelihoodWithLinearModelForMeanAndGatedProjDataWithMotion< TargetT >.

References stir::error(), and set_num_subsets().

Referenced by set_num_subsets().

◆ actual_subsets_are_approximately_balanced()

template<typename ObjFuncT, typename TargetT, typename Parent>
bool stir::SumOfGeneralisedObjectiveFunctions< ObjFuncT, TargetT, Parent >::actual_subsets_are_approximately_balanced ( std::string & warning_message) const
inlineprotectedvirtual

The documentation for this class was generated from the following files: