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

Annotation of /trunk/gadget/sionstep.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef sionstep_h
2 :     #define sionstep_h
3 :    
4 :     #include "areatime.h"
5 :     #include "doublematrixptrvector.h"
6 :     #include "intmatrix.h"
7 :     #include "charptrvector.h"
8 :     #include "conversionindex.h"
9 :     #include "commentstream.h"
10 :     #include "actionattimes.h"
11 :     #include "agebandmatrix.h"
12 :     #include "stockaggregator.h"
13 :     #include "regressionline.h"
14 :     #include "hasname.h"
15 :     #include "gadget.h"
16 :    
17 :     enum FitType { LINEARFIT = 1, LOGLINEARFIT, WEIGHTLINEARFIT, LOGWEIGHTLINEARFIT,
18 :     FIXEDSLOPELINEARFIT, FIXEDSLOPELOGLINEARFIT, FIXEDSLOPEWEIGHTLINEARFIT,
19 :     FIXEDSLOPELOGWEIGHTLINEARFIT, FIXEDINTERCEPTLINEARFIT, FIXEDINTERCEPTLOGLINEARFIT,
20 :     FIXEDINTERCEPTWEIGHTLINEARFIT, FIXEDINTERCEPTLOGWEIGHTLINEARFIT,
21 :     FIXEDLINEARFIT, FIXEDLOGLINEARFIT, FIXEDWEIGHTLINEARFIT, FIXEDLOGWEIGHTLINEARFIT };
22 :     enum SIType { SILENGTH = 1, SIAGE, SIFLEET, SIEFFORT, SIACOUSTIC };
23 :    
24 :     /**
25 :     * \class SIOnStep
26 :     * \brief This is the base class used to calculate a likelihood score by fitting a regression line to the model population and survey index data
27 :     * \note This will always be overridden by the derived classes that actually calculate the survey indices and the likelihood score from the regression line
28 :     */
29 :     class SIOnStep : public HasName {
30 :     public:
31 :     /**
32 :     * \brief This is the default SIOnStep constructor
33 :     * \param infile is the CommentStream to read the SIOnStep data from
34 :     * \param datafilename is the name of the file to read the index data from
35 :     * \param aindex is the CharPtrVector of the names of the areas for the survey indices
36 :     * \param TimeInfo is the TimeClass for the current model
37 :     * \param areas is the IntMatrix of the areas that the survey indices are calculated on
38 :     * \param charindex is the CharPtrVector of the names of the column index for the survey indices
39 :     * \param givenname is the name for the SIOnStep component
40 :     * \param bio is the flag to denote whether the index should be based on the biomass or not
41 :     * \param type is the SIType of the SIOnStep
42 :     */
43 :     SIOnStep(CommentStream& infile, const char* datafilename, const CharPtrVector& aindex,
44 :     const TimeClass* const TimeInfo, const IntMatrix& areas, const CharPtrVector& charindex,
45 :     const char* givenname, int bio, SIType type);
46 :     /**
47 :     * \brief This is the default SIOnStep destructor
48 :     */
49 :     virtual ~SIOnStep();
50 :     /**
51 :     * \brief This function will sum the survey index data
52 :     * \param TimeInfo is the TimeClass for the current model
53 :     */
54 :     virtual void Sum(const TimeClass* const TimeInfo) = 0;
55 :     /**
56 :     * \brief This will select the fleets and stocks required to calculate the regression line
57 :     * \param Fleets is the FleetPtrVector of all the available fleets
58 :     * \param Stocks is the StockPtrVector of all the available stocks
59 :     */
60 :     virtual void setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks) = 0;
61 :     /**
62 :     * \brief This function will reset the SIOnStep information
63 :     */
64 :     virtual void Reset();
65 :     /**
66 :     * \brief This function will print the SIOnStep information
67 :     * \param outfile is the ofstream that all the model information gets sent to
68 :     */
69 :     virtual void Print(ofstream& outfile) const = 0;
70 :     /**
71 :     * \brief This function will print information from each SIOnStep regression calculation
72 :     * \param outfile is the ofstream that all the model likelihood information gets sent to
73 :     * \param TimeInfo is the TimeClass for the current model
74 :     */
75 :     virtual void printLikelihood(ofstream& outfile, const TimeClass* const TimeInfo);
76 :     /**
77 :     * \brief This function will print summary information from each SIOnStep regression calculation
78 :     * \param outfile is the ofstream that all the model likelihood information gets sent to
79 :     * \param weight is the weight of the likelihood component
80 :     */
81 :     virtual void printSummary(ofstream& outfile, const double weight);
82 :     /**
83 :     * \brief This function will calculate the SSE from the regression line
84 :     * \return SSE from the regession line
85 :     */
86 :     virtual double calcSSE();
87 :     /**
88 :     * \brief This will return the fit type for the regression line
89 :     * \return fittype
90 :     */
91 :     FitType getType() const { return fittype; };
92 :     /**
93 :     * \brief This will return the type of survey index data to be used
94 :     * \return sitype
95 :     */
96 :     SIType getSIType() const { return sitype; };
97 :     protected:
98 :     /**
99 :     * \brief This is the IntMatrix used to store information about the areas that the survey index should be calculated on
100 :     */
101 :     IntMatrix Areas;
102 :     /**
103 :     * \brief This is the IntVector used to store information about the years when the survey index should be calculated
104 :     */
105 :     IntVector Years;
106 :     /**
107 :     * \brief This is the IntVector used to store information about the steps when the survey index should be calculated
108 :     */
109 :     IntVector Steps;
110 :     /**
111 :     * \brief This is the IntMatrix used to store information about the ages that the survey index should be calculated on
112 :     */
113 :     IntMatrix Ages;
114 :     /**
115 :     * \brief This is the LengthGroupDivision used to store information about the lengths that the survey index should be calculated on
116 :     */
117 :     LengthGroupDivision* LgrpDiv;
118 :     /**
119 :     * \brief This is the DoubleVector used to store the calculated likelihood information
120 :     */
121 :     DoubleVector likelihoodValues;
122 :     /**
123 :     * \brief This ActionAtTimes stores information about when the survey index should be calculated
124 :     */
125 :     ActionAtTimes AAT;
126 :     /**
127 :     * \brief This is the DoubleMatrixPtrVector used to store the survey indices specified in the input file
128 :     * \note The indices for this object are [time][area][index]
129 :     */
130 :     DoubleMatrixPtrVector obsIndex;
131 :     /**
132 :     * \brief This is the DoubleMatrixPtrVector used to store the survey indices calculated in the model
133 :     * \note The indices for this object are [time][area][index]
134 :     */
135 :     DoubleMatrixPtrVector modelIndex;
136 :     /**
137 :     * \brief This is the DoubleMatrixPtrVector used to store the weights specified for the regression line
138 :     * \note The indices for this object are [time][area][weight]
139 :     */
140 :     DoubleMatrixPtrVector weightIndex;
141 :     /**
142 :     * \brief This is the AgeBandMatrixPtrVector used to temporarily store the information returned from the aggregatation function
143 :     */
144 :     const AgeBandMatrixPtrVector* alptr;
145 :     /**
146 :     * \brief This denotes what type of survey index data is to be used
147 :     */
148 :     SIType sitype;
149 :     /**
150 :     * \brief This is the index of the timesteps for the survey index data
151 :     */
152 :     int timeindex;
153 :     /**
154 :     * \brief This is the flag to denote whether the index should be based on the biomass or not
155 :     * \note The default value for this is 0, which means that the index is based on the number of the population
156 :     */
157 :     int biomass;
158 :     /**
159 :     * \brief This is the flag to denote whether weighted regression line should be used when calculating the fit to the data or not
160 :     * \note The default value for this is 0, which means that the regression line doesnt use weights
161 :     */
162 :     int useweight;
163 :     private:
164 :     /**
165 :     * \brief This function will read the SIOnStep data from the input file
166 :     * \param infile is the CommentStream to read the SIOnStep data from
167 :     * \param TimeInfo is the TimeClass for the current model
168 :     */
169 :     void readSIData(CommentStream& infile, const TimeClass* const TimeInfo);
170 :     /**
171 :     * \brief This function will read the regression data data from the input file
172 :     * \param infile is the CommentStream to read the regression data from
173 :     */
174 :     void readSIRegressionData(CommentStream& infile);
175 :     /**
176 :     * \brief This is used to fix the slope of the regression lines if specified by the user
177 :     */
178 :     double slope;
179 :     /**
180 :     * \brief This is used to fix the intercept of the regression lines if specified by the user
181 :     */
182 :     double intercept;
183 :     /**
184 :     * \brief This is the DoubleMatrix used to store information about the slope of the regression lines
185 :     */
186 :     DoubleMatrix slopes;
187 :     /**
188 :     * \brief This is the DoubleMatrix used to store information about the intercept of the regression lines
189 :     */
190 :     DoubleMatrix intercepts;
191 :     /**
192 :     * \brief This is the DoubleMatrix used to store information about the sse of the regression lines
193 :     */
194 :     DoubleMatrix sse;
195 :     /**
196 :     * \brief This is the DoubleVector used to temporarily store the model indices when calculating the fit to the regression line
197 :     */
198 :     DoubleVector tmpModel;
199 :     /**
200 :     * \brief This is the DoubleVector used to temporarily store the observed data indices when calculating the fit to the regression line
201 :     */
202 :     DoubleVector tmpData;
203 :     /**
204 :     * \brief This is the DoubleVector used to temporarily store the weights when calculating the fit to the regression line
205 :     */
206 :     DoubleVector tmpWeight;
207 :     /**
208 :     * \brief This is the CharPtrVector of the names of the areas
209 :     */
210 :     CharPtrVector areaindex;
211 :     /**
212 :     * \brief This is the CharPtrVector of the names of the indices
213 :     */
214 :     CharPtrVector colindex;
215 :     /**
216 :     * \brief This denotes what type of fit is to be used for the linear regression line
217 :     */
218 :     FitType fittype;
219 :     /**
220 :     * \brief This is a Regression that stores the regression line used when calculating the likelihood score
221 :     */
222 :     Regression* LR;
223 :     };
224 :    
225 :     #endif

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

Powered By FusionForge