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

Annotation of /trunk/gadget/grower.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (view) (download)

1 : agomez 1 #ifndef grower_h
2 :     #define grower_h
3 :    
4 :     #include "areatime.h"
5 :     #include "conversionindex.h"
6 :     #include "commentstream.h"
7 :     #include "popinfomatrix.h"
8 :     #include "doublematrixptrvector.h"
9 :     #include "livesonareas.h"
10 :     #include "formulavector.h"
11 :     #include "keeper.h"
12 :     #include "growthcalc.h"
13 : ulcessvp 2 #include "matrix.h"
14 : agomez 1
15 :     /**
16 :     * \class Grower
17 :     * \brief This is the class used to calculate, and implement, the affect of growth on the stock
18 :     *
19 :     * This class calculates the growth of the stock, according to the different growth functions derived from the GrowthCalcBase class. Since the growth calculations can take place on a coarser scale than the stock is defined on, the calculated growth is then interpolated to take the length group of the stock into account. This growth is then implemented by moving the fish up from the old length groups to the new length groups, taking care to ensure that the fish that would move to beyond the largest length group are kept in the plus group.
20 :     */
21 :     class Grower : public HasName, protected LivesOnAreas {
22 :     public:
23 :     /**
24 :     * \brief This is the Grower constructor
25 :     * \param infile is the CommentStream to read the growth data from
26 :     * \param OtherLgrpDiv is the LengthGroupDivision of the stock
27 :     * \param GivenLgrpDiv is the LengthGroupDivision that the growth will be calculated on
28 :     * \param Areas is the IntVector of areas that the stock lives on
29 :     * \param TimeInfo is the TimeClass for the current model
30 :     * \param keeper is the Keeper for the current model
31 :     * \param refWeight is the name of the file containing the reference weight information for the stock
32 :     * \param givenname is the name of the stock for this Grower class
33 :     * \param Area is the AreaClass for the current model
34 :     * \param lenindex is the CharPtrVector of the lengths used for the growth of the stock
35 :     */
36 :     Grower(CommentStream& infile, const LengthGroupDivision* const OtherLgrpDiv,
37 :     const LengthGroupDivision* const GivenLgrpDiv, const IntVector& Areas,
38 :     const TimeClass* const TimeInfo, Keeper* const keeper, const char* refWeight,
39 :     const char* givenname, const AreaClass* const Area, const CharPtrVector& lenindex);
40 :     /**
41 :     * \brief This is the default Grower destructor
42 :     */
43 :     ~Grower();
44 :     /**
45 :     * \brief This will calculate the growth of the stock for the current timestep on a given area
46 :     * \param area is the area that the growth is being calculated on
47 :     * \param Area is the AreaClass for the current model
48 :     * \param TimeInfo is the TimeClass for the current model
49 :     * \param FeedingLevel is the DoubleVector of the feeding level of the stock
50 :     * \param Consumption is the DoubleVector of the maximum consumption of the stock
51 :     */
52 :     void calcGrowth(int area, const AreaClass* const Area, const TimeClass* const TimeInfo,
53 :     const DoubleVector& FeedingLevel, const DoubleVector& Consumption);
54 :     /**
55 :     * \brief This will calculate the growth of the stock for the current timestep on a given area
56 :     * \param area is the area that the growth is being calculated on
57 :     * \param Area is the AreaClass for the current model
58 :     * \param TimeInfo is the TimeClass for the current model
59 :     */
60 :     void calcGrowth(int area, const AreaClass* const Area, const TimeClass* const TimeInfo);
61 :     /**
62 :     * \brief This will implement the calculated changes due to growth of the stock
63 :     * \param area is the area that the growth is being calculated on
64 :     * \param NumberInArea is the PopInfoVector giving the current population of the stock
65 :     * \param Lengths is the LengthGroupDivision of the stock
66 :     */
67 :     void implementGrowth(int area, const PopInfoVector& NumberInArea,
68 :     const LengthGroupDivision* const Lengths);
69 :     /**
70 :     * \brief This will implement the calculated changes due to growth of the stock
71 :     * \param area is the area that the growth is being calculated on
72 :     * \param Lengths is the LengthGroupDivision of the stock
73 :     */
74 :     void implementGrowth(int area, const LengthGroupDivision* const Lengths);
75 :     /**
76 :     * \brief This will calculate the amount of the stock that is on a given area and timestep
77 :     * \param NumberInArea is the PopInfoVector giving the amount of the stock in the area
78 :     * \param area is the area that the growth is being calculated on
79 :     */
80 :     void Sum(const PopInfoVector& NumberInArea, int area);
81 :     /**
82 :     * \brief This will reset the growth information for the current model run
83 :     */
84 :     void Reset();
85 :     /**
86 :     * \brief This function will print the growth data
87 :     * \param outfile is the ofstream that all the model information gets sent to
88 :     */
89 :     void Print(ofstream& outfile) const;
90 :     /**
91 :     * \brief This function will return the calculated length increase due to growth on an area
92 :     * \param area is the area that the growth is being calculated on
93 :     * \return lgrowth, a DoubleMatrix containing the length increase
94 :     */
95 : ulcessvp 2 // const DoubleMatrix& getLengthIncrease(int area) const { return *lgrowth[this->areaNum(area)]; };
96 : ulcessvp 4 const Matrix& getLengthIncrease(int area) const { return *lgrowth; };
97 : agomez 1 /**
98 :     * \brief This function will return the calculated weight increase due to growth on an area
99 :     * \param area is the area that the growth is being calculated on
100 :     * \return wgrowth, a DoubleMatrix containing the weight increase
101 :     */
102 : ulcessvp 2 // const DoubleMatrix& getWeightIncrease(int area) const { return *wgrowth[this->areaNum(area)]; };
103 : ulcessvp 4 const Matrix& getWeightIncrease(int area) const { return *wgrowth; };
104 : agomez 1 /**
105 :     * \brief This function will return the fixed weight increase due to growth on an area
106 :     * \param area is the area that the growth is being calculated on
107 :     * \return interpWeightGrowth, a DoubleVector containing the weight increase
108 :     */
109 :     const DoubleVector& getWeight(int area) const { return interpWeightGrowth[this->areaNum(area)]; };
110 :     /**
111 :     * \brief This will return the flag used to denote whether the weights have been fixed or not
112 :     * \return fixedweights
113 :     */
114 :     int getFixedWeights() { return fixedweights; };
115 :     protected:
116 :     /**
117 :     * \brief This is the PopInfoMatrix used to store information about the current population of the stock that is to grow according to the growth calculations
118 :     */
119 :     PopInfoMatrix numGrow;
120 :     /**
121 :     * \brief This is the LengthGroupDivision used to store length information
122 :     */
123 :     LengthGroupDivision* LgrpDiv;
124 : ulcessvp 2
125 : ulcessvp 12 /**
126 :     * \brief This array of doubles store the raising mean length of all the group to the power term of the length
127 :     */
128 : ulcessvp 2 double * meanlength_vectorPow;
129 :     int vector_OK;
130 :    
131 : agomez 1 /**
132 :     * \brief This is the ConversionIndex used to convert from the stock LengthGroupDivision to the LengthGroupDivision used for the growth calculation
133 :     */
134 :     ConversionIndex* CI;
135 :     /**
136 :     * \brief This is the DoubleMatrix used to store the increase in length on the current timestep
137 :     * \note The indices for this object are [area][stock length]
138 :     */
139 :     DoubleMatrix interpLengthGrowth;
140 :     /**
141 :     * \brief This is the DoubleMatrix used to store the increase in weight on the current timestep
142 :     * \note The indices for this object are [area][stock length]
143 :     */
144 :     DoubleMatrix interpWeightGrowth;
145 :     /**
146 : ulcessvp 12 * \brief This is the Matrix of doubles used to store the calculated increase in length on the current timestep
147 : agomez 1 * \note The indices for this object are [area][length]
148 :     */
149 : ulcessvp 4 Matrix calcLengthGrowth;
150 : agomez 1 /**
151 : ulcessvp 12 * \brief This is the Matrix of doubles used to store the calculated increase in weight on the current timestep
152 : agomez 1 * \note The indices for this object are [area][length]
153 :     */
154 : ulcessvp 4 Matrix calcWeightGrowth;
155 : agomez 1 /**
156 :     * \brief This is the DoubleMatrixPtrVector used to store the calculated increase in length for each length group on the current timestep
157 :     * \note The indices for this object are [area][change in length][stock length]
158 :     */
159 : ulcessvp 2 // DoubleMatrixPtrVector lgrowth;
160 : ulcessvp 4 Matrix* lgrowth;
161 : agomez 1 /**
162 :     * \brief This is the DoubleMatrixPtrVector used to store the calculated increase in weight for each length group on the current timestep
163 :     * \note The indices for this object are [area][change in length][stock length]
164 :     */
165 : ulcessvp 2 // DoubleMatrixPtrVector wgrowth;
166 : ulcessvp 4 Matrix* wgrowth;
167 : agomez 1 /**
168 :     * \brief This is the dummy DoubleVector used during the growth calculation
169 :     * \note The values of this vector are set to zero, and never used, unless the growth function depends on the feeding level of the stock (ie. growth is based on consumption of preys)
170 :     */
171 :     DoubleVector dummyfphi;
172 :     /**
173 :     * \brief This is the GrowthCalcBase used to calculate the growth information
174 :     */
175 :     GrowthCalcBase* growthcalc;
176 :     /**
177 :     * \brief This is the identifier of the function to be used to calculate the growth
178 :     */
179 :     int functionnumber;
180 :     /**
181 :     * \brief This is the flag used to denote whether the change is weight is to be calculated, or fixed to values specified in the input files
182 :     */
183 :     int fixedweights;
184 :     /**
185 :     * \brief This is the maximum number of length groups that an individual fish from the stock can grow on one timestep
186 :     */
187 :     int maxlengthgroupgrowth;
188 :     /**
189 :     * \brief This is the mean growth, as calculated for this length group by the GrowthCalc function
190 :     */
191 :     double growth;
192 :     /**
193 :     * \brief This is the value of alpha in the beta binomial distribution
194 :     */
195 :     double alpha;
196 :     /**
197 :     * \brief This is the value of beta in the beta binomial distribution
198 :     */
199 :     Formula beta;
200 :     /**
201 :     * \brief This is a DoubleVector used when calculating the beta binomial distribution
202 :     * \note This stores the value of n*(n-1)*....(n-x+1)/x!
203 :     */
204 :     DoubleVector part1;
205 :     /**
206 :     * \brief This is a DoubleVector used when calculating the beta binomial distribution
207 :     * \note This stores the value of gamma(n-x+beta)/gamma(beta)
208 :     */
209 :     DoubleVector part2;
210 :     /**
211 :     * \brief This is a double used when calculating the beta binomial distribution
212 :     * \note This stores the value of gamma(alpha+beta)/gamma(n+alpha+beta)
213 :     */
214 :     double part3;
215 :     /**
216 :     * \brief This is a DoubleVector used when calculating the beta binomial distribution
217 :     * \note This stores the value of gamma(x+alpha)/gamma(x)
218 :     */
219 :     DoubleVector part4;
220 :     };
221 :    
222 :     #endif

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

Powered By FusionForge