1 : |
agomez |
1 |
#include "predatoroveraggregator.h" |
2 : |
|
|
#include "predator.h" |
3 : |
|
|
#include "errorhandler.h" |
4 : |
|
|
#include "gadget.h" |
5 : |
|
|
#include "global.h" |
6 : |
|
|
|
7 : |
|
|
PredatorOverAggregator::PredatorOverAggregator(const PredatorPtrVector& preds,
|
8 : |
|
|
const IntMatrix& Areas, const LengthGroupDivision* const LgrpDiv)
|
9 : |
|
|
: predators(preds), areas(Areas) {
|
10 : |
|
|
|
11 : |
|
|
int i, j;
|
12 : |
|
|
for (i = 0; i < predators.Size(); i++) {
|
13 : |
|
|
if (!checkLengthGroupStructure(predators[i]->getLengthGroupDiv(), LgrpDiv))
|
14 : |
|
|
handle.logMessage(LOGFAIL, "Error in predatoroveraggregator - invalid length group structure");
|
15 : |
|
|
predConv.AddRows(1, predators[i]->getLengthGroupDiv()->numLengthGroups(), -1);
|
16 : |
|
|
for (j = 0; j < predConv.Ncol(i); j++)
|
17 : |
|
|
predConv[i][j] = LgrpDiv->numLengthGroup(predators[i]->getLengthGroupDiv()->meanLength(j));
|
18 : |
|
|
}
|
19 : |
|
|
total.AddRows(areas.Nrow(), LgrpDiv->numLengthGroups(), 0.0);
|
20 : |
|
|
}
|
21 : |
|
|
|
22 : |
|
|
void PredatorOverAggregator::Reset() {
|
23 : |
|
|
total.setToZero();
|
24 : |
|
|
}
|
25 : |
|
|
|
26 : |
|
|
void PredatorOverAggregator::Sum() {
|
27 : |
|
|
int i, j, k, l;
|
28 : |
|
|
|
29 : |
|
|
this->Reset();
|
30 : |
|
|
//Sum over the appropriate predators, areas, and lengths.
|
31 : |
|
|
for (k = 0; k < predators.Size(); k++)
|
32 : |
|
|
for (i = 0; i < areas.Nrow(); i++)
|
33 : |
|
|
for (j = 0; j < areas.Ncol(i); j++)
|
34 : |
|
|
if ((predators[k]->isInArea(areas[i][j])) && (predators[k]->hasOverConsumption(areas[i][j])))
|
35 : |
|
|
for (l = 0; l < predConv.Ncol(k); l++)
|
36 : |
|
|
if (predConv[k][l] >= 0)
|
37 : |
|
|
total[i][predConv[k][l]] += (predators[k]->getOverConsumption(areas[i][j]))[l];
|
38 : |
|
|
|
39 : |
|
|
}
|