Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/catchdistribution.h
[mareframe] / trunk / gadget / catchdistribution.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/catchdistribution.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef catchdistribution_h
2 :     #define catchdistribution_h
3 :    
4 :     #include "likelihood.h"
5 :     #include "fleetpreyaggregator.h"
6 :     #include "doublematrixptrmatrix.h"
7 :     #include "actionattimes.h"
8 :     #include "ludecomposition.h"
9 :     #include "multinomial.h"
10 :     #include "charptrvector.h"
11 :     #include "formulavector.h"
12 :    
13 :     /**
14 :     * \class CatchDistribution
15 :     * \brief This is the class used to calculate a likelihood score based on distribution data sampled from the stocks caught by fleets
16 :     *
17 :     * This class calculates a likelihood score based on the difference between distribution data sampled from stocks caught according to the model and that caught by fleets, according to the landings data. The distribution data can either be aggregated into age groups (giving a distribution of length groups for each age), length groups (giving a distribution of age groups for each length) or into age-length groups. The model will calculate the distribution data for the stock that is caught according to the model parameters, and aggregate this into the specified age and/or length groups. This distribution data is then compared to the corresponding data calculated from the landings data.
18 :     */
19 :     class CatchDistribution : public Likelihood {
20 :     public:
21 :     /**
22 :     * \brief This is the CatchDistribution constructor
23 :     * \param infile is the CommentStream to read the CatchDistribution data from
24 :     * \param Area is the AreaClass for the current model
25 :     * \param TimeInfo is the TimeClass for the current model
26 :     * \param keeper is the Keeper for the current model
27 :     * \param weight is the weight for the likelihood component
28 :     * \param name is the name for the likelihood component
29 :     */
30 :     CatchDistribution(CommentStream& infile, const AreaClass* const Area,
31 :     const TimeClass* const TimeInfo, Keeper* const keeper, double weight, const char* name);
32 :     /**
33 :     * \brief This is the default CatchDistribution destructor
34 :     */
35 :     virtual ~CatchDistribution();
36 :     /**
37 :     * \brief This function will calculate the likelihood score for the CatchDistribution component
38 :     * \param TimeInfo is the TimeClass for the current model
39 :     */
40 :     virtual void addLikelihood(const TimeClass* const TimeInfo);
41 :     /**
42 :     * \brief This function will reset the CatchDistribution likelihood information
43 :     * \param keeper is the Keeper for the current model
44 :     */
45 :     virtual void Reset(const Keeper* const keeper);
46 :     /**
47 :     * \brief This function will print the summary CatchDistribution likelihood information
48 :     * \param outfile is the ofstream that all the model information gets sent to
49 :     */
50 :     virtual void Print(ofstream& outfile) const;
51 :     /**
52 :     * \brief This will select the fleets and stocks required to calculate the CatchDistribution likelihood score
53 :     * \param Fleets is the FleetPtrVector of all the available fleets
54 :     * \param Stocks is the StockPtrVector of all the available stocks
55 :     */
56 :     void setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks);
57 :     /**
58 :     * \brief This function will print information from each CatchDistribution calculation
59 :     * \param outfile is the ofstream that all the model likelihood information gets sent to
60 :     * \param TimeInfo is the TimeClass for the current model
61 :     */
62 :     virtual void printLikelihood(ofstream& outfile, const TimeClass* const TimeInfo);
63 :     /**
64 :     * \brief This function will print summary information from each CatchDistribution likelihood calculation
65 :     * \param outfile is the ofstream that all the model likelihood information gets sent to
66 :     */
67 :     virtual void printSummary(ofstream& outfile);
68 :     private:
69 :     /**
70 :     * \brief This function will read the CatchDistribution data from the input file
71 :     * \param infile is the CommentStream to read the CatchDistribution data from
72 :     * \param TimeInfo is the TimeClass for the current model
73 :     * \param numarea is the number of areas that the likelihood data covers
74 :     * \param numage is the number of age groups that the likelihood data covers
75 :     * \param numlen is the number of length groups that the likelihood data covers
76 :     */
77 :     void readDistributionData(CommentStream& infile, const TimeClass* TimeInfo,
78 :     int numarea, int numage, int numlen);
79 :     /**
80 :     * \brief This function will calculate the likelihood score for the current timestep based on a multinomial function
81 :     * \return likelihood score
82 :     */
83 :     double calcLikMultinomial();
84 :     /**
85 :     * \brief This function will calculate the likelihood score for the current timestep based on a Pearson function
86 :     * \param TimeInfo is the TimeClass for the current model
87 :     * \return likelihood score
88 :     */
89 :     double calcLikPearson(const TimeClass* const TimeInfo);
90 :     /**
91 :     * \brief This function will calculate the likelihood score for the current timestep based on a gamma function
92 :     * \param TimeInfo is the TimeClass for the current model
93 :     * \return likelihood score
94 :     */
95 :     double calcLikGamma(const TimeClass* const TimeInfo);
96 :     /**
97 :     * \brief This function will calculate the likelihood score for the current timestep based on a sum of squares function
98 :     * \param TimeInfo is the TimeClass for the current model
99 :     * \return likelihood score
100 :     */
101 :     double calcLikSumSquares(const TimeClass* const TimeInfo);
102 :     /**
103 :     * \brief This function will calculate the likelihood score for the current timestep based on a multivariate normal function
104 :     * \return likelihood score
105 :     */
106 :     double calcLikMVNormal();
107 :     /**
108 :     * \brief This function will calculate the likelihood score for the current timestep based on a multivariate logistic function
109 :     * \return likelihood score
110 :     */
111 :     double calcLikMVLogistic();
112 :     /**
113 :     * \brief This function will calculate the likelihood score for the current timestep based on a logarithmic function
114 :     * \param TimeInfo is the TimeClass for the current model
115 :     * \return likelihood score
116 :     */
117 :     double calcLikLog(const TimeClass* const TimeInfo);
118 :     /**
119 :     * \brief This function will calculate the likelihood score for the current timestep based on a sum of squares function, based on data that has been collected from a stratified sampling scheme
120 :     * \param TimeInfo is the TimeClass for the current model
121 :     * \return likelihood score
122 :     */
123 :     double calcLikStratified(const TimeClass* const TimeInfo);
124 :     /**
125 :     * \brief This function will calculate the correlation matrix used for the multivariate normal function
126 :     */
127 :     void calcCorrelation();
128 :     /**
129 :     * \brief This is the DoubleMatrixPtrMatrix used to store age-length distribution information specified in the input file
130 :     * \note The indices for this object are [time][area][age][length]
131 :     */
132 :     DoubleMatrixPtrMatrix obsDistribution;
133 :     /**
134 :     * \brief This is the DoubleMatrixPtrMatrix used to store age-length distribution information calculated in the model
135 :     * \note The indices for this object are [time][area][age][length]
136 :     */
137 :     DoubleMatrixPtrMatrix modelDistribution;
138 :     /**
139 :     * \brief This is the DoubleMatrix used to store the calculated likelihood information
140 :     * \note The indices for this object are [time][area]
141 :     */
142 :     DoubleMatrix likelihoodValues;
143 :     /**
144 :     * \brief This is the FleetPreyAggregator used to collect information about the fleets
145 :     */
146 :     FleetPreyAggregator* aggregator;
147 :     /**
148 :     * \brief This is the CharPtrVector of the names of the fleets that will be used to calculate the likelihood score
149 :     */
150 :     CharPtrVector fleetnames;
151 :     /**
152 :     * \brief This is the CharPtrVector of the names of the stocks that will be used to calculate the likelihood score
153 :     */
154 :     CharPtrVector stocknames;
155 :     /**
156 :     * \brief This is the IntMatrix used to store area information
157 :     */
158 :     IntMatrix areas;
159 :     /**
160 :     * \brief This is the IntMatrix used to store age information
161 :     */
162 :     IntMatrix ages;
163 :     /**
164 :     * \brief This is the DoubleVector used to store length information
165 :     */
166 :     DoubleVector lengths;
167 :     /**
168 :     * \brief This is the CharPtrVector of the names of the areas
169 :     */
170 :     CharPtrVector areaindex;
171 :     /**
172 :     * \brief This is the CharPtrVector of the names of the age groups
173 :     */
174 :     CharPtrVector ageindex;
175 :     /**
176 :     * \brief This is the CharPtrVector of the names of the length groups
177 :     */
178 :     CharPtrVector lenindex;
179 :     /**
180 :     * \brief This is the flag to denote whether the likelihood calculation should take overconsumption into account or not
181 :     */
182 :     int overconsumption;
183 :     /**
184 :     * \brief This is the identifier of the function to be used to calculate the likelihood component
185 :     */
186 :     int functionnumber;
187 :     /**
188 :     * \brief This is the name of the function to be used to calculate the likelihood component
189 :     */
190 :     char* functionname;
191 :     /**
192 :     * \brief This is the index of the timesteps for the likelihood component data
193 :     */
194 :     int timeindex;
195 :     /**
196 :     * \brief This ActionAtTimes stores information about when the likelihood score should be calculated
197 :     */
198 :     ActionAtTimes AAT;
199 :     /**
200 :     * \brief This is the IntVector used to store information about the years when the likelihood score should be calculated
201 :     */
202 :     IntVector Years;
203 :     /**
204 :     * \brief This is the IntVector used to store information about the steps when the likelihood score should be calculated
205 :     */
206 :     IntVector Steps;
207 :     /**
208 :     * \brief This is the DoubleMatrixPtrVector used to aggreate the age-length distribution information from the model data over a year, if the likelihood calculation is based on the aggregated data
209 :     * \note The indices for this object are [area][age][length]
210 :     */
211 :     DoubleMatrixPtrVector modelYearData;
212 :     /**
213 :     * \brief This is the DoubleMatrixPtrVector used to aggreate the age-length distribution information from the observed data over a year, if the likelihood calculation is based on the aggregated data
214 :     * \note The indices for this object are [area][age][length]
215 :     */
216 :     DoubleMatrixPtrVector obsYearData;
217 :     /**
218 :     * \brief This is the flag to denote whether the likelihood calculation should aggregate data over a whole year
219 :     * \note The default value is 0, which calculates the likelihood score on each timestep
220 :     */
221 :     int yearly;
222 :     /**
223 :     * \brief This is the LengthGroupDivision used to store length information
224 :     */
225 :     LengthGroupDivision* LgrpDiv;
226 :     /**
227 :     * \brief This is the value of epsilon used when calculating the likelihood score
228 :     */
229 :     double epsilon;
230 :     /**
231 :     * \brief This is the Formula used to store sigma when calculating the likelihood score, if the multivariate normal function or the multivariate logistic function has been selected
232 :     */
233 :     Formula sigma;
234 :     /**
235 :     * \brief This is the FormulaVector used to store the parameters when calculating the likelihood score, if the multivariate normal function has been selected
236 :     */
237 :     FormulaVector params;
238 :     /**
239 :     * \brief This is the number of the parameters used when calculating the likelihood score, if the multivariate normal function has been selected
240 :     */
241 :     int lag;
242 :     /**
243 :     * \brief This is the flag used to denote whether the correlation matrix is valid, if the multivariate normal function has been selected
244 :     */
245 :     int illegal;
246 :     /**
247 :     * \brief This is the LUDecomposition that can be used when calculating the likelihood score, if the multivariate normal function has been selected
248 :     * \note This is set to zero, and not used, if the multivariate normal function is not used
249 :     */
250 :     LUDecomposition LU;
251 :     /**
252 :     * \brief This is the Multinomial that can be used when calculating the likelihood score, if the multinomial function has been selected
253 :     * \note This is set to zero, and not used, if the multinomial function is not used
254 :     */
255 :     Multinomial MN;
256 :     /**
257 :     * \brief This is the AgeBandMatrixPtrVector used to temporarily store the information returned from the aggregatation function
258 :     * \note The indices for this object are [area][age][length]
259 :     */
260 :     const AgeBandMatrixPtrVector* alptr;
261 :     };
262 :    
263 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge