ReFRACtor
cost_func.h
Go to the documentation of this file.
1 #ifndef COST_FUNC_H
2 #define COST_FUNC_H
3 #include <problem_state.h>
4 
5 namespace FullPhysics {
6 
7 //-----------------------------------------------------------------------
18 //-----------------------------------------------------------------------
19 
20 class CostFunc :
21  virtual public ProblemState {
22 
23 public:
24 
25 
26 //-----------------------------------------------------------------------
36 //-----------------------------------------------------------------------
37 
38  enum message_t {
39  NONE,
42  };
43 
44 
45 //-----------------------------------------------------------------------
47 //-----------------------------------------------------------------------
48 
50  : c_count(0), mssg(NONE)
51  {}
52 
53 
54  virtual ~CostFunc() {}
55 
56 
57 //-----------------------------------------------------------------------
71 //-----------------------------------------------------------------------
72 
73  virtual double cost() = 0;
74 
75 
76 //-----------------------------------------------------------------------
87 //-----------------------------------------------------------------------
88 
89  virtual double cost_x(const blitz::Array<double, 1>& x)
90  { parameters(x); return cost(); }
91 
92 
93 //-----------------------------------------------------------------------
97 //-----------------------------------------------------------------------
98 
99  virtual int num_cost_evaluations() const
100  { return c_count; }
101 
102 
103 //-----------------------------------------------------------------------
105 //-----------------------------------------------------------------------
106 
107  virtual void zero_num_evaluations()
108  { c_count = 0; }
109 
110 
111 //-----------------------------------------------------------------------
125 //-----------------------------------------------------------------------
126 
127  virtual message_t message() const
128  { return mssg; }
129 
130 
131 //-----------------------------------------------------------------------
147 //-----------------------------------------------------------------------
148 
149  virtual const char * const message_str() const;
150 
151 
152 //-----------------------------------------------------------------------
154 //-----------------------------------------------------------------------
155 
156  virtual void print(std::ostream& Os) const
157  { Os << "CostFunc"; }
158 
159 
160 protected:
161 
162 
164 
165 //-----------------------------------------------------------------------
196 //-----------------------------------------------------------------------
197 
199  { c_count++; }
200 
201 
202 //-----------------------------------------------------------------------
211 //-----------------------------------------------------------------------
212 
213  virtual void set_num_cost_evaluations(int count)
214  { c_count = count; }
215 
216 
217 private:
218 
219  int c_count;
220 
221 };
222 }
223 #endif
virtual void increment_num_cost_evaluations()
Increments (by 1) cost evaluation counter.
Definition: cost_func.h:198
virtual double cost()=0
The cost function.
virtual void set_num_cost_evaluations(int count)
Sets the cost evaluation counter to a desired value.
Definition: cost_func.h:213
message_t
Enum type for the message generated by the problem.
Definition: cost_func.h:38
CostFunc()
Default Constructor.
Definition: cost_func.h:49
The base class for all problem classes that implement a cost function.
Definition: cost_func.h:20
virtual blitz::Array< double, 1 > parameters() const
Returns the current parameters.
virtual void zero_num_evaluations()
Sets cost evaluation counter to zero.
Definition: cost_func.h:107
virtual message_t message() const
Returns a value of CostFunc::message_t type.
Definition: cost_func.h:127
virtual ~CostFunc()
Definition: cost_func.h:54
The problem is solved.
Definition: cost_func.h:40
There is an error in the problem.
Definition: cost_func.h:41
virtual int num_cost_evaluations() const
Returns the number of the times cost has been evaluated.
Definition: cost_func.h:99
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
The base class for all problem states.
Definition: problem_state.h:51
There are no messages.
Definition: cost_func.h:39
virtual const char *const message_str() const
Returns the string version of the problem message.
Definition: cost_func.cc:14
virtual void print(std::ostream &Os) const
Prints description of object.
Definition: cost_func.h:156
virtual double cost_x(const blitz::Array< double, 1 > &x)
The cost function with parameters.
Definition: cost_func.h:89

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