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

View of /trunk/gadget/sibyeffortonstep.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Mon Feb 10 17:09:07 2014 UTC (10 years, 4 months ago) by agomez
File size: 1733 byte(s)
Initial version based on Gadget 2.2.00
#include "sibyeffortonstep.h"
#include "areatime.h"
#include "mathfunc.h"
#include "errorhandler.h"
#include "gadget.h"
#include "global.h"

SIByEffortOnStep::SIByEffortOnStep(CommentStream& infile, const IntMatrix& areas,
  const CharPtrVector& areaindex, const CharPtrVector& fleetindex,
  const TimeClass* const TimeInfo, const char* datafilename, const char* givenname, int bio)
  : SIOnStep(infile, datafilename, areaindex, TimeInfo, areas, fleetindex, givenname, bio, SIEFFORT) {
}

SIByEffortOnStep::~SIByEffortOnStep() {
  if (aggregator != 0)
    delete aggregator;
}

void SIByEffortOnStep::setFleetsAndStocks(FleetPtrVector& Fleets, StockPtrVector& Stocks) {
  if (Stocks.Size() == 0)
    handle.logMessage(LOGFAIL, "Error in surveyindex - failed to initialise stock data");
  if (Fleets.Size() == 0)
    handle.logMessage(LOGFAIL, "Error in surveyindex - failed to initialise fleet data");
  aggregator = new FleetEffortAggregator(Fleets, Stocks, Areas);
}

void SIByEffortOnStep::Sum(const TimeClass* const TimeInfo) {
  if (!AAT.atCurrentTime(TimeInfo))
    return;

  int a, i, j;
  timeindex = -1;
  for (i = 0; i < Years.Size(); i++)
    if ((Years[i] == TimeInfo->getYear()) && (Steps[i] == TimeInfo->getStep()))
      timeindex = i;
  if (timeindex == -1)
    handle.logMessage(LOGFAIL, "Error in surveyindex - invalid timestep");

  if (handle.getLogLevel() >= LOGMESSAGE)
    handle.logMessage(LOGMESSAGE, "Calculating index for surveyindex component", this->getName());

  aggregator->Sum();
  for (a = 0; a < Areas.Nrow(); a++) {
    dptr = aggregator->getSum()[a];
    for (i = 0; i < dptr->Nrow(); i++)
      for (j = 0; j < dptr->Ncol(i); j++)
        (*modelIndex[timeindex])[a][i] += (*dptr)[i][j];
  }
}

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

Powered By FusionForge