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

Annotation of /trunk/gadget/areatime.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef areatime_h
2 :     #define areatime_h
3 :    
4 :     #include "doublematrix.h"
5 :     #include "formulavector.h"
6 :     #include "commentstream.h"
7 :     #include "keeper.h"
8 :    
9 :     class AreaClass;
10 :     class TimeClass;
11 :    
12 :     /**
13 :     * \class AreaClass
14 :     * \brief This is the class used to store information about the areas used for the current model
15 :     *
16 :     * This class keeps an index of the areas in the model. The areas are read in with a numerical identifier, which is stored along with an internal identifier for the areas, which is a simple index starting from 0.
17 :     */
18 :     class AreaClass {
19 :     public:
20 :     /**
21 :     * \brief This is the AreaClass constructor
22 :     * \param infile is the CommentStream to read the area data from
23 :     * \param keeper is the Keeper for the current model
24 :     * \param TimeInfo is the TimeClass for the current model
25 :     */
26 :     AreaClass(CommentStream& infile, Keeper* const keeper, const TimeClass* const TimeInfo);
27 :     /**
28 :     * \brief This is the default AreaClass destructor
29 :     */
30 :     ~AreaClass() {};
31 :     /**
32 :     * \brief This will return the number of areas for the current model
33 :     * \return number
34 :     */
35 :     int numAreas() const { return modelAreas.Size(); };
36 :     /**
37 :     * \brief This will return the size of an area
38 :     * \param area is the identifier for the required area
39 :     * \return size
40 :     */
41 :     double getSize(int area) const { return size[area]; };
42 :     /**
43 :     * \brief This will return the temperature of an area on a timestep
44 :     * \param area is the identifier for the required area
45 :     * \param time is the identifier for the required timestep
46 :     * \return temperature
47 :     */
48 :     double getTemperature(int area, int time) const { return temperature[time][area]; };
49 :     /**
50 :     * \brief This will return the internal identifier of an area
51 :     * \param area is the identifier for the required area
52 :     * \return innerarea
53 :     */
54 :     int getInnerArea(int area) const;
55 :     /**
56 :     * \brief This will return the external identifier of an area
57 :     * \param area is the identifier for the required area
58 :     * \return outerarea
59 :     */
60 :     int getModelArea(int area) const { return modelAreas[area]; };
61 :     /**
62 :     * \brief This will return the the IntVector of all the areas in the current model
63 :     * \return modelAreas
64 :     */
65 :     const IntVector& getAllModelAreas() const { return modelAreas; };
66 :     protected:
67 :     /**
68 :     * \brief This is the IntVector of the areas in the current model
69 :     */
70 :     IntVector modelAreas;
71 :     /**
72 :     * \brief This is the FormulaVector of the size of the areas in the current model
73 :     */
74 :     FormulaVector size;
75 :     /**
76 :     * \brief This is the DoubleMatrix of the temperature, for each timestep, of the areas in the current model
77 :     */
78 :     DoubleMatrix temperature;
79 :     };
80 :    
81 :     /**
82 :     * \class TimeClass
83 :     * \brief This is the class used to store information about the timesteps used for the current model
84 :     *
85 :     * This class keeps an index of the timesteps in the model. A step is a subdivision of a year, and is usually defined in terms of months, and is the same in each year of the model. A check is made to ensure that the total length of all the steps adds up to 12.
86 :     */
87 :     class TimeClass {
88 :     public:
89 :     /**
90 :     * \brief This is the TimeClass constructor
91 :     * \param infile is the CommentStream to read the time data from
92 :     * \param maxratio is the maximum ratio of a stock that will be consumed on any given timestep
93 :     */
94 :     TimeClass(CommentStream& infile, double maxratio);
95 :     /**
96 :     * \brief This is the TimeClass destructor
97 :     */
98 :     ~TimeClass() {};
99 :     /**
100 :     * \brief This will return the current substep of the model simulation
101 :     * \return currentsubstep
102 :     */
103 :     int getSubStep() const { return currentsubstep; };
104 :     /**
105 :     * \brief This will return the current step of the model simulation
106 :     * \return currentstep
107 :     */
108 :     int getStep() const { return currentstep; };
109 :     /**
110 :     * \brief This will return the current year of the model simulation
111 :     * \return currentyear
112 :     */
113 :     int getYear() const { return currentyear; };
114 :     /**
115 :     * \brief This will return the total number of timesteps that have taken place in the simulation from the start of the model simulation until the current timestep
116 :     * \return number of timesteps taken from the start of the simulation
117 :     */
118 :     int getTime() const { return this->calcSteps(currentyear, currentstep); };
119 :     /**
120 :     * \brief This will return the first step of the model simulation
121 :     * \return firststep
122 :     */
123 :     int getFirstStep() const { return firststep; };
124 :     /**
125 :     * \brief This will return the first year of the model simulation
126 :     * \return firstyear
127 :     */
128 :     int getFirstYear() const { return firstyear; };
129 :     /**
130 :     * \brief This will return the last step of the model simulation
131 :     * \return laststep
132 :     */
133 :     int getLastStep() const { return laststep; };
134 :     /**
135 :     * \brief This will return the last year of the model simulation
136 :     * \return lastyear
137 :     */
138 :     int getLastYear() const { return lastyear; };
139 :     /**
140 :     * \brief This will return the length of the current step of the model simulation as a proportion of the whole year
141 :     * \return proportion of year
142 :     */
143 :     double getTimeStepSize() const { return (timesteps[currentstep] * lengthofyear); };
144 :     /**
145 :     * \brief This will return the length of the current step of the model simulation
146 :     * \return length of step
147 :     */
148 :     double getTimeStepLength() const { return timesteps[currentstep]; };
149 :     /**
150 :     * \brief This will return the total number of timesteps that have taken place in the simulation from the start of the model simulation until a specifed year and step
151 :     * \param year is the specified year
152 :     * \param step is the specified step
153 :     * \return number of timesteps taken
154 :     */
155 :     int calcSteps(int year, int step) const {
156 :     return (numtimesteps * (year - firstyear) + step - firststep + 1); };
157 :     /**
158 :     * \brief This will return the total number of timesteps in the model simulation
159 :     * \return total number of timesteps
160 :     */
161 :     int numTotalSteps() const {
162 :     return (numtimesteps * (lastyear - firstyear) + laststep - firststep + 1); };
163 :     /**
164 :     * \brief This will return the number of steps in each year of the model simulation
165 :     * \return numtimesteps
166 :     */
167 :     int numSteps() const { return numtimesteps; };
168 :     /**
169 :     * \brief This is the function that increases the timestep for the model simulation
170 :     */
171 :     void IncrementTime();
172 :     /**
173 :     * \brief This is the function that will check to see if specified year and step are within the time period covered by the model simulation
174 :     * \param year is the specified year
175 :     * \param step is the specified step
176 :     * \return 1 if the timestep is within the model period, 0 otherwise
177 :     */
178 :     int isWithinPeriod(int year, int step) const;
179 :     /**
180 :     * \brief This is the function that resets the timestep to the beginning of the model simulation
181 :     */
182 :     void Reset();
183 :     /**
184 :     * \brief This will return the number of substeps in the current timestep of the model simulation
185 :     * \return number of substeps
186 :     */
187 :     int numSubSteps() const { return numsubsteps[currentstep - 1]; };
188 :     /**
189 :     * \brief This is the function that increases the substep within the current timestep
190 :     */
191 :     void IncrementSubstep() { currentsubstep++; };
192 :     /**
193 :     * \brief This is the function that will check to see if the length of the current timestep has changed from the previous timestep
194 :     * \return 1 if the length of the timestep has changed, 0 otherwise
195 :     */
196 :     int didStepSizeChange() const;
197 :     /**
198 :     * \brief This function will return the maximum ratio of any stock that can be consumed on the current substep
199 :     * \return maximum ratio of the stock that can be consumed on the current substep
200 :     */
201 :     double getMaxRatioConsumed() const;
202 :     protected:
203 :     /**
204 :     * \brief This is the current step of the model simulation
205 :     */
206 :     int currentstep;
207 :     /**
208 :     * \brief This is the current year of the model simulation
209 :     */
210 :     int currentyear;
211 :     /**
212 :     * \brief This is the first year in the model simulation
213 :     */
214 :     int firstyear;
215 :     /**
216 :     * \brief This is the first step in the model simulation
217 :     */
218 :     int firststep;
219 :     /**
220 :     * \brief This is the last year in the model simulation
221 :     */
222 :     int lastyear;
223 :     /**
224 :     * \brief This is the last step in the model simulation
225 :     */
226 :     int laststep;
227 :     /**
228 :     * \brief This is the number of steps in a year in the model simulation
229 :     */
230 :     int numtimesteps;
231 :     /**
232 :     * \brief This is the length of a year in the model simulation (should be 12)
233 :     * \note This is stored as 1/length of year to save processing time
234 :     */
235 :     double lengthofyear;
236 :     /**
237 :     * \brief This is the maximum ratio of stock that can be consumed in any given timestep
238 :     * \note This value will enforce a limit on the consumption of a stock which should prevent a stock from collapsing on any given timestep. If the calculated consumption is over this ratio, then the consumption is limited to this value and the rest is treated as "overconsumption", which will lead to understocking.
239 :     */
240 :     double maxratioconsumed;
241 :     /**
242 :     * \brief This is the DoubleVector of timesteps in each year
243 :     */
244 :     DoubleVector timesteps;
245 :     /**
246 :     * \brief This is the IntVector of substeps in each step
247 :     */
248 :     IntVector numsubsteps;
249 :     /**
250 :     * \brief This is the current substep of the model simulation
251 :     */
252 :     int currentsubstep;
253 :     };
254 :    
255 :     #endif

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

Powered By FusionForge