ReFRACtor
cost_func_diff.h
Go to the documentation of this file.
1 #ifndef COST_FUNC_DIFF_H
2 #define COST_FUNC_DIFF_H
3 #include <cost_func.h>
4 
5 namespace FullPhysics {
6 
7 //-----------------------------------------------------------------------
20 //-----------------------------------------------------------------------
21 
22 class CostFuncDiff : public CostFunc {
23 
24 public:
25 
26 
27 //-----------------------------------------------------------------------
29 //-----------------------------------------------------------------------
30 
32  : CostFunc(), d_count(0)
33  {}
34 
35 
36  virtual ~CostFuncDiff() {}
37 
38 
39 //-----------------------------------------------------------------------
61 //-----------------------------------------------------------------------
62 
63  virtual blitz::Array<double, 1> gradient() = 0;
64 
65 
66 //-----------------------------------------------------------------------
80 //-----------------------------------------------------------------------
81 
82  virtual blitz::Array<double, 1> gradient_x(const blitz::Array<double, 1>& x)
83  { parameters(x); return gradient(); }
84 
85 
86 //-----------------------------------------------------------------------
106 //-----------------------------------------------------------------------
107 
108  virtual void cost_gradient(
109  double& c, blitz::Array<double, 1>& g);
110 
111 
112 //-----------------------------------------------------------------------
126 //-----------------------------------------------------------------------
127 
128  virtual void cost_gradient_x(const blitz::Array<double, 1>& x,
129  double& c, blitz::Array<double, 1>& g)
130  { parameters(x); cost_gradient(c,g); }
131 
132 
133 //-----------------------------------------------------------------------
137 //-----------------------------------------------------------------------
138 
139  virtual int num_der1_evaluations() const
140  { return d_count; }
141 
142 
143 //-----------------------------------------------------------------------
145 //-----------------------------------------------------------------------
146 
147  virtual void zero_num_evaluations()
148  { CostFunc::zero_num_evaluations(); d_count = 0; }
149 
150 
151 //-----------------------------------------------------------------------
155 //-----------------------------------------------------------------------
156 
157  virtual int gradient_size() const
158  { return expected_parameter_size(); }
159 
160 
161 //-----------------------------------------------------------------------
163 //-----------------------------------------------------------------------
164 
165  virtual void print(std::ostream& Os) const
166  { Os << "CostFuncDiff"; }
167 
168 
169 protected:
170 
171 
172 //-----------------------------------------------------------------------
203 //-----------------------------------------------------------------------
204 
206  { d_count++; }
207 
208 
209 //-----------------------------------------------------------------------
218 //-----------------------------------------------------------------------
219 
220  virtual void set_num_der1_evaluations(int count)
221  { d_count = count; }
222 
223 
224 private:
225 
226  int d_count;
227 
228 };
229 }
230 #endif
virtual void set_num_der1_evaluations(int count)
Sets the gradient evaluation counter to a desired value.
virtual void zero_num_evaluations()
Sets cost and gradient evaluation counters to zero.
The base class for all problem classes that implement a cost function.
Definition: cost_func.h:20
virtual int gradient_size() const
Returns the size of the gradient vector.
virtual void increment_num_der1_evaluations()
Increments (by 1) gradient evaluation counter.
virtual blitz::Array< double, 1 > parameters() const
Returns the current parameters.
virtual int num_der1_evaluations() const
Returns the number of the times gradient has been evaluated.
virtual void cost_gradient(double &c, blitz::Array< double, 1 > &g)
The cost function and its gradient together.
virtual void zero_num_evaluations()
Sets cost evaluation counter to zero.
Definition: cost_func.h:107
virtual blitz::Array< double, 1 > gradient()=0
The gradient of the cost function.
The base class for all problem classes that implement a cost function and its gradient.
virtual void print(std::ostream &Os) const
Prints description of object.
virtual blitz::Array< double, 1 > gradient_x(const blitz::Array< double, 1 > &x)
The gradient function with parameters.
const Unit g("g", 1e-3 *kg)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
CostFuncDiff()
Default Constructor.
virtual void cost_gradient_x(const blitz::Array< double, 1 > &x, double &c, blitz::Array< double, 1 > &g)
The cost function and its gradient with parameters.
virtual int expected_parameter_size() const
Returns the expected size of the parameters.

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:10