This file is indexed.

/usr/include/mia-2.4/mia/core/minimizer.hh is in libmia-2.4-dev 2.4.3-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/* -*- mia-c++  -*-
 *
 * This file is part of MIA - a toolbox for medical image analysis 
 * Copyright (c) Leipzig, Madrid 1999-2016 Gert Wollny
 *
 * MIA is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MIA; if not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef mia_core_minimizer_hh
#define mia_core_minimizer_hh

#include <memory>
#include <vector>

#include <mia/core/factory.hh>
#include <mia/core/handler.hh>
#include <mia/core/vector.hh>

NS_MIA_BEGIN


/**
   \ingroup basic 
   \brief A class for generalized minimization problems 
   
   This class defined the interface for a generalized minimizer that may use 
   gradient information. Specific implementations are provided as plug-ins. 
   
 */
class EXPORT_CORE  CMinimizer : public CProductBase {
public: 

	/// plug-in searchpath typedef helper
	typedef CMinimizer plugin_data; 
	/// plug-in searchpath typedef helper
	typedef CMinimizer plugin_type; 

	/// Pointer type of this minimizer 
	typedef std::shared_ptr<CMinimizer> Pointer; 
	
	/// enum to describe whether optimization succeeded 
	enum EMinimizerResult {failure, /**< optimization failed */ 
			       success  /**< optimization succeeded */ 
	}; 

	/// plug-in searchpath helper
	static const char *const type_descr; 
	
	/// plug-in searchpath helper
	static const char *const data_descr; 
	
	/**
	   \brief Base class for all optimization problems that can be run 
	   by CMinimizer
	   
	   This is the abstract base class for all optimization problems that can be run by
	   CMinimizer. In order to implement a real optimizable problem, the abstract functions 
		- virtual double  do_f(const CDoubleVector& x) = 0; 
		- virtual void    do_df(const CDoubleVector& x, CDoubleVector&  g) = 0; 
		- virtual double  do_fdf(const CDoubleVector& x, CDoubleVector&  g) = 0; 

   	   have to be implemented in the derived class.
	   These functions must provide the functionality as documented for the public member functions 
	        - double  f(size_t n, const double *x); 
		- void    df(size_t n, const double *x, double *g); 
		- double  fdf(size_t n, const double *x, double *g); 
	*/
	class Problem : public CPropertyFlagHolder{
	public:
		virtual ~Problem(); 

		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function value.  
		   @param n number of parameters 
		   @param x vector of parameters 
		   @returns function value 
		*/
		double  f(size_t n, const double *x); 

		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function gradient.  
		   @param n number of parameters 
		   @param x vector of parameters 
		   @param[out] g vector of gradient  of the objective function 
		   
		*/
		
		void    df(size_t n, const double *x, double *g); 
		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function gradient and the function value.  
		   @param n number of parameters 
		   @param x vector of parameters 
		   @param[out] g vector of gradient  of the objective function 
		   @returns objective function value 
		*/
		double  fdf(size_t n, const double *x, double *g); 

		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function value.  
		   @param x vector of parameters 
		   @returns function value 
		   
		*/
		double  f(const std::vector<double>& x); 
		
		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function gradient.  
		   @param x vector of parameters 
		   @param[out] g vector of gradient  of the objective function 
		   
		*/
		void    df(const std::vector<double>& x, std::vector<double>& g); 
		
                /**
		   The function that is called by the optimizer to evaluate the 
		   objective function gradient and the function value.  
		   @param x vector of parameters 
		   @param[out] g vector of gradient  of the objective function 
		   @returns objective function value 
		*/
		double  fdf(const std::vector<double>& x, std::vector<double>& g); 

		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function value.  
		   @param x vector of parameters 
		   @returns function value 
		   
		*/
		double  f(const CDoubleVector& x); 
		
		/**
		   The function that is called by the optimizer to evaluate the 
		   objective function gradient.  
		   @param x vector of parameters 
		   @param[out] g vector of gradient  of the objective function 
		   
		*/
		void    df(const CDoubleVector& x, CDoubleVector& g); 
		
                /**
		   The function that is called by the optimizer to evaluate the 
		   objective function gradient and the function value.  
		   @param x vector of parameters 
		   @param[out] g vector of gradient  of the objective function 
		   @returns objective function value 
		*/
		double  fdf(const CDoubleVector& x, CDoubleVector& g); 


		/// \returns number of parameters to optimize
		size_t size() const; 
	private: 
		virtual double  do_f(const CDoubleVector& x) = 0; 
		virtual void    do_df(const CDoubleVector& x, CDoubleVector&  g) = 0; 
		virtual double  do_fdf(const CDoubleVector& x, CDoubleVector&  g) = 0; 
		virtual size_t do_size() const = 0; 
	}; 

	/// pointer type for the optimization problem 
	typedef std::shared_ptr<Problem> PProblem; 

	/**
	   Construtor of the optimizer. 
	 */
	CMinimizer(); 

	/**
	   Set the optimization problem 
	   \param x problem to be optimized 
	*/
	void set_problem(PProblem x);
	
	
	virtual ~CMinimizer(); 

	
	/**
	   Run the optimization 
	   \param[in,out] x at entry contains the start point of the optimization at exit the optimized value 
	   \returns returns a status whether the optimization succeeded or why it stopped 
	 */
	int run(CDoubleVector& x); 
	
protected: 
	/// @returns a raw pointer to the optimization problem 
	Problem *get_problem_pointer();  
	
	/// @returns the size  (degrees of freedom) of the optimization problem
	size_t size() const; 

	/// \returns a read/write reference to the current optimization problem
	Problem& get_problem(); 
private: 
	virtual void do_set_problem();
	virtual int do_run(CDoubleVector& x) = 0;

	PProblem m_problem;
}; 

/// Pointer type for the CMinimizer class 
typedef CMinimizer::Pointer PMinimizer; 

/// Base class for the CMinimizer creator plugins 
typedef TFactory<CMinimizer> CMinimizerPlugin;

/// The minimizer plugin handler 
typedef THandlerSingleton<TFactoryPluginHandler<CMinimizerPlugin> > CMinimizerPluginHandler;

/// Trait to make the minimizer definition parsable on the command line  
FACTORY_TRAIT(CMinimizerPluginHandler); 

inline CMinimizer::Problem& CMinimizer::get_problem()
{
	return *m_problem;
}

inline 
PMinimizer produce_minimizer(const std::string& descr) 
{
	return CMinimizerPluginHandler::instance().produce(descr); 
}

	
NS_MIA_END

#endif