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

Annotation of /trunk/gadget/sibyeffortonstep.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "sibyeffortonstep.h"
2 :     #include "areatime.h"
3 :     #include "mathfunc.h"
4 :     #include "errorhandler.h"
5 :     #include "gadget.h"
6 :     #include "global.h"
7 :    
8 :     SIByEffortOnStep::SIByEffortOnStep(CommentStream& infile, const IntMatrix& areas,
9 :     const CharPtrVector& areaindex, const CharPtrVector& fleetindex,
10 :     const TimeClass* const TimeInfo, const char* datafilename, const char* givenname, int bio)
11 :     : SIOnStep(infile, datafilename, areaindex, TimeInfo, areas, fleetindex, givenname, bio, SIEFFORT) {
12 :     }
13 :    
14 :     SIByEffortOnStep::~SIByEffortOnStep() {
15 :     if (aggregator != 0)
16 :     delete aggregator;
17 :     }
18 :    
19 :     void SIByEffortOnStep::setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks) {
20 :     if (Stocks.Size() == 0)
21 :     handle.logMessage(LOGFAIL, "Error in surveyindex - failed to initialise stock data");
22 :     if (Fleets.Size() == 0)
23 :     handle.logMessage(LOGFAIL, "Error in surveyindex - failed to initialise fleet data");
24 :     aggregator = new FleetEffortAggregator(Fleets, Stocks, Areas);
25 :     }
26 :    
27 :     void SIByEffortOnStep::Sum(const TimeClass* const TimeInfo) {
28 :     if (!AAT.atCurrentTime(TimeInfo))
29 :     return;
30 :    
31 :     int a, i, j;
32 :     timeindex = -1;
33 :     for (i = 0; i < Years.Size(); i++)
34 :     if ((Years[i] == TimeInfo->getYear()) && (Steps[i] == TimeInfo->getStep()))
35 :     timeindex = i;
36 :     if (timeindex == -1)
37 :     handle.logMessage(LOGFAIL, "Error in surveyindex - invalid timestep");
38 :    
39 :     if (handle.getLogLevel() >= LOGMESSAGE)
40 :     handle.logMessage(LOGMESSAGE, "Calculating index for surveyindex component", this->getName());
41 :    
42 :     aggregator->Sum();
43 :     for (a = 0; a < Areas.Nrow(); a++) {
44 :     dptr = aggregator->getSum()[a];
45 :     for (i = 0; i < dptr->Nrow(); i++)
46 :     for (j = 0; j < dptr->Ncol(i); j++)
47 :     (*modelIndex[timeindex])[a][i] += (*dptr)[i][j];
48 :     }
49 :     }

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

Powered By FusionForge