CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
src/optimizer/iPenaltyTemplate.cc
Go to the documentation of this file.
1 
8 #include "iPenaltyTemplate.hh"
9 
10 // =====================================================================
11 // ---------------------------------------------------------------------
12 // ---------------------------------------------------------------------
13 // =====================================================================
14 
16 {
17  // ---------------------------
18  // Mandatory member parameters
19  // (inherited from vPenalty)
20  // ---------------------------
21 
22  // Specify here the derivative order of the penalty.
23  // Most algorithms able to handle penalties require 1 derivative,
24  // and some 2 derivatives. If infinite, then set INT_MAX.
25  m_penaltyDerivativesOrder = INT_MAX;
26 
27  // --------------------------
28  // Specific member parameters
29  // --------------------------
30 
31  // Set here the default values of the parameters specific to this optimizer
32 
33 }
34 
35 // =====================================================================
36 // ---------------------------------------------------------------------
37 // ---------------------------------------------------------------------
38 // =====================================================================
39 
41 {
42  // Delete or free ONLY things that were built into this class
43 }
44 
45 // =====================================================================
46 // ---------------------------------------------------------------------
47 // ---------------------------------------------------------------------
48 // =====================================================================
49 
51 {
52  cout << "This penalty is only a squeleton template to explain how to add a penalty into CASToR. If you" << endl;
53  cout << "want to implement your own penalty, start from here and look at the specific documentation." << endl;
54 }
55 
56 // =====================================================================
57 // ---------------------------------------------------------------------
58 // ---------------------------------------------------------------------
59 // =====================================================================
60 
61 int iPenaltyTemplate::ReadConfigurationFile(const string& a_configurationFile)
62 {
63  // This function is designed to read parameters specific to the optimizer through a configuration file.
64  // To do that, use the ReadDataASCIIFile() function, and take a look at other optimizers to see how it is done.
65  // Do not check the parameters' values, the CheckSpecificParameters() function is designed to do that.
66  // Return 1 if any problem. See other penalties' implementation to get guidance.
67 
68  // Normal end
69  return 0;
70 }
71 
72 // =====================================================================
73 // ---------------------------------------------------------------------
74 // ---------------------------------------------------------------------
75 // =====================================================================
76 
77 int iPenaltyTemplate::ReadOptionsList(const string& a_optionsList)
78 {
79  // This function is designed to read parameters specific to the optimizer through a list of options in a string.
80  // To do that, use the ReadStringOption() function, and take a look at other optimizers to see how it is done.
81  // Do not check the parameters' values, the CheckSpecificParameters() function is designed to do that.
82  // Return 1 if any problem. See other penalties' implementation to get guidance.
83 
84  // Normal end
85  return 0;
86 }
87 
88 // =====================================================================
89 // ---------------------------------------------------------------------
90 // ---------------------------------------------------------------------
91 // =====================================================================
92 
94 {
95  // This function is designed to check that all parameters specific to the optimizer have been set properly.
96  // Return 1 if any problem.
97 
98  // Normal end
99  return 0;
100 }
101 
102 // =====================================================================
103 // ---------------------------------------------------------------------
104 // ---------------------------------------------------------------------
105 // =====================================================================
106 
108 {
109  // Verbose
110  if (m_verbose>=2) Cout("iOptimizerTemplate::InitializeSpecific() -> Use the template optimizer" << endl);
111 
112  // This function is designed to initialize everything that should be initialized before being able to launch the iteration.
113  // Return 1 if any problem.
114 
115  // Normal end
116  return 0;
117 }
118 
119 // =====================================================================
120 // ---------------------------------------------------------------------
121 // ---------------------------------------------------------------------
122 // =====================================================================
123 
125 {
126  // This is where you must implement the computation of the penalty value, for the provided parameters.
127  // It is used to compute the overall cost function.
128  // This function is called inside a parallel loop. The index of the thread is provided.
129  // See other penalties' implementation to get guidance.
130  FLTNB penalty = 0.;
131  return penalty;
132 }
133 
134 // =====================================================================
135 // ---------------------------------------------------------------------
136 // ---------------------------------------------------------------------
137 // =====================================================================
138 
140 {
141  // This is where you must implement the computation of the penalty's first derivative value, for the
142  // provided parameters. It is used by the optimizer to compute the next update.
143  // This function is called inside a parallel loop. The index of the thread is provided.
144  // See other penalties' implementation to get guidance.
145  FLTNB first_derivative = 0.;
146  return first_derivative;
147 }
148 
149 
150 // =====================================================================
151 // ---------------------------------------------------------------------
152 // ---------------------------------------------------------------------
153 // =====================================================================
154 
156 {
157  // This is where you must implement the computation of the penalty's second derivative value, for the
158  // provided parameters. It may be used by the optimizer to compute the next update.
159  // If the penalty does not admit a second derivative, then just let the function as is.
160  // This function is called inside a parallel loop. The index of the thread is provided.
161  // See other penalties' implementation to get guidance.
162  FLTNB second_derivative = 0.;
163  return second_derivative;
164 }
int ReadOptionsList(const string &a_optionsList)
int ReadConfigurationFile(const string &a_configurationFile)
FLTNB ComputePenaltyValue(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)
void ShowHelpSpecific()
A function used to show help about the child penalty.
int InitializeSpecific()
This function is used to initialize specific stuff to the child penalty.
int CheckSpecificParameters()
A private function used to check the parameters settings specific to the child penalty.
~iPenaltyTemplate()
The destructor of iPenaltyTemplate.
FLTNB ComputeFirstDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)
This class is designed to generically described any penalty applied to MAP algorithms.
FLTNB ComputeSecondDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)
iPenaltyTemplate()
The constructor of iPenaltyTemplate.
#define Cout(MESSAGE)