1 : |
agomez |
1 |
#include "maturity.h" |
2 : |
|
|
#include "agebandmatrixratio.h" |
3 : |
|
|
#include "gadget.h" |
4 : |
|
|
|
5 : |
ulcessvp |
4 |
void AgeBandMatrixRatio::Grow(const Matrix& Lgrowth, const AgeBandMatrix& Total) {
|
6 : |
agomez |
1 |
|
7 : |
|
|
int numTagExperiments = this->numTagExperiments();
|
8 : |
|
|
int i, lgrp, grow, maxlgrp, tag;
|
9 : |
|
|
|
10 : |
|
|
if (numTagExperiments > 0) {
|
11 : |
|
|
DoubleVector number(numTagExperiments, 0.0);
|
12 : |
|
|
|
13 : |
|
|
maxlgrp = Lgrowth.Nrow();
|
14 : |
|
|
for (i = 0; i < nrow; i++) {
|
15 : |
|
|
//The part that grows to or above the highest length group.
|
16 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
17 : |
|
|
number[tag] = 0.0;
|
18 : |
|
|
|
19 : |
|
|
for (lgrp = v[i]->maxCol() - 1; lgrp >= v[i]->maxCol() - maxlgrp; lgrp--)
|
20 : |
|
|
for (grow = v[i]->maxCol() - lgrp - 1; grow < maxlgrp; grow++)
|
21 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
22 : |
|
|
number[tag] += Lgrowth[grow][lgrp] * (*(*v[i])[lgrp][tag].N);
|
23 : |
|
|
|
24 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
25 : |
|
|
(*(*v[i])[v[i]->maxCol() - 1][tag].N) = number[tag];
|
26 : |
|
|
|
27 : |
|
|
//The center part of the length division
|
28 : |
|
|
for (lgrp = v[i]->maxCol() - 2; lgrp >= v[i]->minCol() + maxlgrp - 1; lgrp--) {
|
29 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
30 : |
|
|
number[tag] = 0.0;
|
31 : |
|
|
|
32 : |
|
|
for (grow = 0; grow < maxlgrp; grow++)
|
33 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
34 : |
|
|
number[tag] += Lgrowth[grow][lgrp - grow] * (*(*v[i])[lgrp - grow][tag].N);
|
35 : |
|
|
|
36 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
37 : |
|
|
(*(*v[i])[lgrp][tag].N) = number[tag];
|
38 : |
|
|
}
|
39 : |
|
|
|
40 : |
|
|
//The lowest part of the length division.
|
41 : |
|
|
for (lgrp = v[i]->minCol() + maxlgrp - 2; lgrp >= v[i]->minCol(); lgrp--) {
|
42 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
43 : |
|
|
number[tag] = 0.0;
|
44 : |
|
|
|
45 : |
|
|
for (grow = 0; grow <= lgrp - v[i]->minCol(); grow++)
|
46 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
47 : |
|
|
number[tag] += Lgrowth[grow][lgrp - grow] * (*(*v[i])[lgrp - grow][tag].N);
|
48 : |
|
|
|
49 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++)
|
50 : |
|
|
(*(*v[i])[lgrp][tag].N) = number[tag];
|
51 : |
|
|
}
|
52 : |
|
|
}
|
53 : |
|
|
this->updateRatio(Total);
|
54 : |
|
|
}
|
55 : |
|
|
}
|
56 : |
|
|
|
57 : |
|
|
//Same program with certain number of fish made mature.
|
58 : |
ulcessvp |
4 |
void AgeBandMatrixRatio::Grow(const Matrix& Lgrowth, const AgeBandMatrix& Total, Maturity* const Mat, int area) {
|
59 : |
agomez |
1 |
|
60 : |
|
|
int numTagExperiments = this->numTagExperiments();
|
61 : |
|
|
int i, lgrp, grow, maxlgrp, age, tag;
|
62 : |
|
|
double tmp, ratio;
|
63 : |
|
|
|
64 : |
|
|
if (numTagExperiments > 0) {
|
65 : |
|
|
DoubleVector number(numTagExperiments, 0.0);
|
66 : |
|
|
DoubleVector matnum(numTagExperiments, 0.0);
|
67 : |
|
|
|
68 : |
|
|
maxlgrp = Lgrowth.Nrow();
|
69 : |
|
|
for (i = 0; i < nrow; i++) {
|
70 : |
|
|
age = i + minage;
|
71 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
72 : |
|
|
number[tag] = 0.0;
|
73 : |
|
|
matnum[tag] = 0.0;
|
74 : |
|
|
}
|
75 : |
|
|
|
76 : |
|
|
//The part that grows to or above the highest length group.
|
77 : |
|
|
for (lgrp = v[i]->maxCol() - 1; lgrp >= v[i]->maxCol() - maxlgrp; lgrp--) {
|
78 : |
|
|
for (grow = v[i]->maxCol() - lgrp - 1; grow < maxlgrp; grow++) {
|
79 : |
|
|
ratio = Mat->calcMaturation(age, lgrp, grow, Total[i + minage][lgrp].W);
|
80 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
81 : |
|
|
tmp = Lgrowth[grow][lgrp] * (*(*v[i])[lgrp][tag].N);
|
82 : |
|
|
matnum[tag] += tmp * ratio;
|
83 : |
|
|
number[tag] += tmp;
|
84 : |
|
|
}
|
85 : |
|
|
}
|
86 : |
|
|
}
|
87 : |
|
|
|
88 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
89 : |
|
|
if (isZero(number[tag])) {
|
90 : |
|
|
//no fish grow to this length cell
|
91 : |
|
|
(*(*v[i])[v[i]->maxCol() - 1][tag].N) = 0.0;
|
92 : |
|
|
Mat->storeMatureTagStock(area, age, v[i]->maxCol() - 1, 0.0, tag);
|
93 : |
|
|
} else if (number[tag] - matnum[tag] < verysmall) {
|
94 : |
|
|
//all the fish that grow to this length cell mature
|
95 : |
|
|
(*(*v[i])[v[i]->maxCol() - 1][tag].N) = 0.0;
|
96 : |
|
|
Mat->storeMatureTagStock(area, age, v[i]->maxCol() - 1, matnum[tag], tag);
|
97 : |
|
|
} else if (isZero(matnum[tag])) {
|
98 : |
|
|
//none of the fish that grow to this length cell mature
|
99 : |
|
|
(*(*v[i])[v[i]->maxCol() - 1][tag].N) = number[tag];
|
100 : |
|
|
Mat->storeMatureTagStock(area, age, v[i]->maxCol() - 1, 0.0, tag);
|
101 : |
|
|
} else {
|
102 : |
|
|
(*(*v[i])[v[i]->maxCol() - 1][tag].N) = number[tag] - matnum[tag];
|
103 : |
|
|
Mat->storeMatureTagStock(area, age, v[i]->maxCol() - 1, matnum[tag], tag);
|
104 : |
|
|
}
|
105 : |
|
|
}
|
106 : |
|
|
|
107 : |
|
|
//The center part of the length division
|
108 : |
|
|
for (lgrp = v[i]->maxCol() - 2; lgrp >= v[i]->minCol() + maxlgrp - 1; lgrp--) {
|
109 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
110 : |
|
|
number[tag] = 0.0;
|
111 : |
|
|
matnum[tag] = 0.0;
|
112 : |
|
|
}
|
113 : |
|
|
|
114 : |
|
|
for (grow = 0; grow < maxlgrp; grow++) {
|
115 : |
|
|
ratio = Mat->calcMaturation(age, lgrp, grow, Total[i + minage][lgrp - grow].W);
|
116 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
117 : |
|
|
tmp = Lgrowth[grow][lgrp - grow] * (*(*v[i])[lgrp - grow][tag].N);
|
118 : |
|
|
matnum[tag] += tmp * ratio;
|
119 : |
|
|
number[tag] += tmp;
|
120 : |
|
|
}
|
121 : |
|
|
}
|
122 : |
|
|
|
123 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
124 : |
|
|
if (isZero(number[tag])) {
|
125 : |
|
|
//no fish grow to this length cell
|
126 : |
|
|
(*(*v[i])[lgrp][tag].N) = 0.0;
|
127 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, 0.0, tag);
|
128 : |
|
|
} else if (number[tag] - matnum[tag] < verysmall) {
|
129 : |
|
|
//all the fish that grow to this length cell mature
|
130 : |
|
|
(*(*v[i])[lgrp][tag].N) = 0.0;
|
131 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, matnum[tag], tag);
|
132 : |
|
|
} else if (isZero(matnum[tag])) {
|
133 : |
|
|
//none of the fish that grow to this length cell mature
|
134 : |
|
|
(*(*v[i])[lgrp][tag].N) = number[tag];
|
135 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, 0.0, tag);
|
136 : |
|
|
} else {
|
137 : |
|
|
(*(*v[i])[lgrp][tag].N) = number[tag] - matnum[tag];
|
138 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, matnum[tag], tag);
|
139 : |
|
|
}
|
140 : |
|
|
}
|
141 : |
|
|
}
|
142 : |
|
|
|
143 : |
|
|
//The lowest part of the length division.
|
144 : |
|
|
for (lgrp = v[i]->minCol() + maxlgrp - 2; lgrp >= v[i]->minCol(); lgrp--) {
|
145 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
146 : |
|
|
number[tag] = 0.0;
|
147 : |
|
|
matnum[tag] = 0.0;
|
148 : |
|
|
}
|
149 : |
|
|
|
150 : |
|
|
for (grow = 0; grow <= lgrp - v[i]->minCol(); grow++) {
|
151 : |
|
|
ratio = Mat->calcMaturation(age, lgrp, grow, Total[i + minage][lgrp - grow].W);
|
152 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
153 : |
|
|
tmp = Lgrowth[grow][lgrp - grow] * (*(*v[i])[lgrp - grow][tag].N);
|
154 : |
|
|
matnum[tag] += tmp * ratio;
|
155 : |
|
|
number[tag] += tmp;
|
156 : |
|
|
}
|
157 : |
|
|
}
|
158 : |
|
|
|
159 : |
|
|
for (tag = 0; tag < numTagExperiments; tag++) {
|
160 : |
|
|
if (isZero(number[tag])) {
|
161 : |
|
|
//no fish grow to this length cell
|
162 : |
|
|
(*(*v[i])[lgrp][tag].N) = 0.0;
|
163 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, 0.0, tag);
|
164 : |
|
|
} else if (number[tag] - matnum[tag] < verysmall) {
|
165 : |
|
|
//all the fish that grow to this length cell mature
|
166 : |
|
|
(*(*v[i])[lgrp][tag].N) = 0.0;
|
167 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, matnum[tag], tag);
|
168 : |
|
|
} else if (isZero(matnum[tag])) {
|
169 : |
|
|
//none of the fish that grow to this length cell mature
|
170 : |
|
|
(*(*v[i])[lgrp][tag].N) = number[tag];
|
171 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, 0.0, tag);
|
172 : |
|
|
} else {
|
173 : |
|
|
(*(*v[i])[lgrp][tag].N) = number[tag] - matnum[tag];
|
174 : |
|
|
Mat->storeMatureTagStock(area, age, lgrp, matnum[tag], tag);
|
175 : |
|
|
}
|
176 : |
|
|
}
|
177 : |
|
|
}
|
178 : |
|
|
}
|
179 : |
|
|
this->updateRatio(Total);
|
180 : |
|
|
}
|
181 : |
|
|
}
|