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/stockdistribution.h
[mareframe] / trunk / gadget / stockdistribution.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/stockdistribution.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef stockdistribution_h
2 :     #define stockdistribution_h
3 :    
4 :     #include "likelihood.h"
5 :     #include "commentstream.h"
6 :     #include "charptrvector.h"
7 :     #include "fleetpreyaggregator.h"
8 :     #include "doublematrixptrmatrix.h"
9 :     #include "multinomial.h"
10 :     #include "actionattimes.h"
11 :    
12 :     /**
13 :     * \class StockDistribution
14 :     * \brief This is the class used to calculate a likelihood score based on distribution data for different stocks sampled from the stocks caught by fleets
15 :     *
16 :     * This class calculates a likelihood score based on the difference between distribution data sampled from different stocks caught according to the model and that caught by fleets, according to the landings data. This is typically used to compare Gadget stocks that are based on the same species, but have differing biological properties (eg. immature and mature fish). 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 stocks that are 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.
17 :     */
18 :     class StockDistribution : public Likelihood {
19 :     public:
20 :     /**
21 :     * \brief This is the StockDistribution constructor
22 :     * \param infile is the CommentStream to read the StockDistribution data from
23 :     * \param Area is the AreaClass for the current model
24 :     * \param TimeInfo is the TimeClass for the current model
25 :     * \param weight is the weight for the likelihood component
26 :     * \param name is the name for the likelihood component
27 :     */
28 :     StockDistribution(CommentStream& infile, const AreaClass* const Area,
29 :     const TimeClass* const TimeInfo, double weight, const char* name);
30 :     /**
31 :     * \brief This is the default StockDistribution destructor
32 :     */
33 :     virtual ~StockDistribution();
34 :     /**
35 :     * \brief This function will calculate the likelihood score for the StockDistribution component
36 :     * \param TimeInfo is the TimeClass for the current model
37 :     */
38 :     virtual void addLikelihood(const TimeClass* const TimeInfo);
39 :     /**
40 :     * \brief This function will reset the StockDistribution likelihood information
41 :     * \param keeper is the Keeper for the current model
42 :     */
43 :     virtual void Reset(const Keeper* const keeper);
44 :     /**
45 :     * \brief This function will print the summary StockDistribution likelihood information
46 :     * \param outfile is the ofstream that all the model information gets sent to
47 :     */
48 :     virtual void Print(ofstream& outfile) const;
49 :     /**
50 :     * \brief This function will print summary information from each StockDistribution likelihood calculation
51 :     * \param outfile is the ofstream that all the model likelihood information gets sent to
52 :     */
53 :     virtual void printSummary(ofstream& outfile);
54 :     /**
55 :     * \brief This function will print information from each StockDistribution calculation
56 :     * \param outfile is the ofstream that all the model likelihood information gets sent to
57 :     * \param TimeInfo is the TimeClass for the current model
58 :     */
59 :     virtual void printLikelihood(ofstream& outfile, const TimeClass* const TimeInfo);
60 :     /**
61 :     * \brief This will select the fleets and stocks required to calculate the StockDistribution likelihood score
62 :     * \param Fleets is the FleetPtrVector of all the available fleets
63 :     * \param Stocks is the StockPtrVector of all the available stocks
64 :     */
65 :     void setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks);
66 :     private:
67 :     /**
68 :     * \brief This function will read the StockDistribution data from the input file
69 :     * \param infile is the CommentStream to read the StockDistribution data from
70 :     * \param TimeInfo is the TimeClass for the current model
71 :     * \param numarea is the number of areas that the likelihood data covers
72 :     * \param numage is the number of age groups that the likelihood data covers
73 :     * \param numlen is the number of length groups that the likelihood data covers
74 :     */
75 :     void readStockData(CommentStream& infile, const TimeClass* TimeInfo,
76 :     int numarea, int numage, int numlen);
77 :     /**
78 :     * \brief This function will calculate the likelihood score for the current timestep based on a multinomial function
79 :     * \return likelihood score
80 :     */
81 :     double calcLikMultinomial();
82 :     /**
83 :     * \brief This function will calculate the likelihood score for the current timestep based on a sum of squares function
84 :     * \param TimeInfo is the TimeClass for the current model
85 :     * \return likelihood score
86 :     */
87 :     double calcLikSumSquares(const TimeClass* const TimeInfo);
88 :     /**
89 :     * \brief This is the DoubleMatrixPtrMatrix used to store age-length distribution information specified in the input file
90 :     * \note The indices for this object are [time][area][stock][id] where id = age+(numage*length)
91 :     */
92 :     DoubleMatrixPtrMatrix obsDistribution;
93 :     /**
94 :     * \brief This is the DoubleMatrixPtrMatrix used to store age-length distribution information calculated in the model
95 :     * \note The indices for this object are [time][area][stock][id] where id = age+(numage*length)
96 :     */
97 :     DoubleMatrixPtrMatrix modelDistribution;
98 :     /**
99 :     * \brief This is the DoubleMatrix used to store the calculated likelihood information
100 :     * \note The indices for this object are [time][area]
101 :     */
102 :     DoubleMatrix likelihoodValues;
103 :     /**
104 :     * \brief This is the FleetPreyAggregator used to collect information about the fleets
105 :     */
106 :     FleetPreyAggregator** aggregator;
107 :     /**
108 :     * \brief This is the CharPtrVector of the names of the fleets that will be used to calculate the likelihood score
109 :     */
110 :     CharPtrVector fleetnames;
111 :     /**
112 :     * \brief This is the CharPtrVector of the names of the stocks that will be used to calculate the likelihood score
113 :     */
114 :     CharPtrVector stocknames;
115 :     /**
116 :     * \brief This is the IntMatrix used to store area information
117 :     */
118 :     IntMatrix areas;
119 :     /**
120 :     * \brief This is the IntMatrix used to store age information
121 :     */
122 :     IntMatrix ages;
123 :     /**
124 :     * \brief This is the IntVector used to store information about the years when the likelihood score should be calculated
125 :     */
126 :     IntVector Years;
127 :     /**
128 :     * \brief This is the IntVector used to store information about the steps when the likelihood score should be calculated
129 :     */
130 :     IntVector Steps;
131 :     /**
132 :     * \brief This is the CharPtrVector of the names of the areas
133 :     */
134 :     CharPtrVector areaindex;
135 :     /**
136 :     * \brief This is the CharPtrVector of the names of the age groups
137 :     */
138 :     CharPtrVector ageindex;
139 :     /**
140 :     * \brief This is the CharPtrVector of the names of the length groups
141 :     */
142 :     CharPtrVector lenindex;
143 :     /**
144 :     * \brief This is the DoubleVector used to store length information
145 :     */
146 :     DoubleVector lengths;
147 :     /**
148 :     * \brief This is the LengthGroupDivision used to store length information
149 :     */
150 :     LengthGroupDivision* LgrpDiv;
151 :     /**
152 :     * \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
153 :     * \note The indices for this object are [area][stock][id] where id = age+(numage*length)
154 :     */
155 :     DoubleMatrixPtrVector modelYearData;
156 :     /**
157 :     * \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
158 :     * \note The indices for this object are [area][stock][id] where id = age+(numage*length)
159 :     */
160 :     DoubleMatrixPtrVector obsYearData;
161 :     /**
162 :     * \brief This is the flag to denote whether the likelihood calculation should aggregate data over a whole year
163 :     * \note The default value is 0, which calculates the likelihood score on each timestep
164 :     */
165 :     int yearly;
166 :     /**
167 :     * \brief This is the flag to denote whether the likelihood calculation should take overconsumption into account or not
168 :     */
169 :     int overconsumption;
170 :     /**
171 :     * \brief This is the identifier of the function to be used to calculate the likelihood component
172 :     */
173 :     int functionnumber;
174 :     /**
175 :     * \brief This is the name of the function to be used to calculate the likelihood component
176 :     */
177 :     char* functionname;
178 :     /**
179 :     * \brief This is the index of the timesteps for the likelihood component data
180 :     */
181 :     int timeindex;
182 :     /**
183 :     * \brief This ActionAtTimes stores information about when the likelihood score should be calculated
184 :     */
185 :     ActionAtTimes AAT;
186 :     /**
187 :     * \brief This is the value of epsilon used when calculating the likelihood score
188 :     */
189 :     double epsilon;
190 :     /**
191 :     * \brief This is the Multinomial that can be used when calculating the likelihood score, if the multinomial function has been selected
192 :     * \note This is set to zero, and not used, if the multinomial function is not used
193 :     */
194 :     Multinomial MN;
195 :     /**
196 :     * \brief This is the AgeBandMatrixPtrVector used to temporarily store the information returned from the aggregatation function
197 :     * \note The indices for this object are [area][age][length]
198 :     */
199 :     const AgeBandMatrixPtrVector* alptr;
200 :     };
201 :    
202 :     #endif

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

Powered By FusionForge