-
Notifications
You must be signed in to change notification settings - Fork 1
/
Population.hpp
3362 lines (2866 loc) · 161 KB
/
Population.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Population.hpp
* Author: matthewsupernaw
*
* Created on September 14, 2016, 1:44 PM
*/
#ifndef POPULATION_HPP
#define POPULATION_HPP
#include <memory>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include "Area.hpp"
//#include "../AutoDiff_Standalone/AutoDiff/AutoDiff.hpp"
#include "Movement.hpp"
#include "Recruitment.hpp"
#include "HarvestControlRule.hpp"
#include "MaximumSustainableYield.hpp"
#include "third_party/ATL/lib/Variable.hpp"
namespace mas {
/** @defgroup pop_dynamics Population Dynamics
*
* @{
*/
template<class REAL_T>
class Population;
/**
* Run time calculated information for a population in a specific area, by sex.
*/
template<class REAL_T>
struct Subpopulation {
typedef typename mas::VariableTrait<REAL_T>::variable variable;
int id;
int uid = -9999;
mas::FishSexType sex;
std::vector<variable> ages;
int spawning_season = 1;
/* NOTE: these values need to be defined elsewhere*/
variable spawning_season_offset = 0.0;
variable catch_season_offset = 1.0;
variable survey_season_offset = 1.0;
variable kg_to_tonnes = 1000.0; // convert kg to metric tonnes
REAL_T sex_fraction_value = 0.5;
/*==================================*/
bool males = true;
Population<REAL_T>* natal_population;
bool natal_homing = false;
std::shared_ptr<Area<REAL_T> > area;
std::shared_ptr<Area<REAL_T> > natal_area;
std::shared_ptr<GrowthBase<REAL_T> > growth_model;
std::shared_ptr<mas::NaturalMortality<REAL_T> > natural_mortality_model; // population - area specific
std::shared_ptr<mas::RecruitmentBase<REAL_T> > recruitment_model; // population - area specific
std::unordered_map<int, std::shared_ptr<mas::RecruitmentBase<REAL_T> > > seasonal_recruitment_models;
std::vector<REAL_T> maturity; // should be the same across areas, same length as ages
// these PARAMETERS can be fixed or estimated; should be in model config
#warning hard coded value initialF
variable initialF = static_cast<REAL_T> (0.0);
std::vector<variable> initialS;
std::vector<variable> M;
std::vector<variable> F; // this PARAMETER vector is shared between males and females
std::unordered_set<int> active_fleets;
std::unordered_map<int, std::vector<variable> > F_at_age; // access by fleet id these values may differ between males and females
std::unordered_map<int, std::vector<variable> > Z_at_age; // access by fleet id these values may differ between males and females
std::unordered_map<int, std::vector<variable> > SN_at_age; // access by fleet id these values may differ between males and females
// these are shared by males and females for a specific population and area
variable R0; // PARAMETER: fixed or estimated
variable S0;
variable unfished_spawning_biomass_per_recruit;
variable unfished_spawners_per_recruit;
variable fished_spawning_biomass_per_recruit;
variable fished_spawners_per_recruit;
variable fished_yield_per_recruit;
variable fished_max_yield_per_recruit;
//biological reference points
std::vector<variable> F100;
std::vector<variable> SB100;
std::vector<variable> F40;
std::vector<variable> SB40;
std::vector<variable> F35;
std::vector<variable> SB35;
std::vector<variable> F20;
std::vector<variable> S20;
std::vector<variable> SB_target;
variable avgR;
variable SB0; // derived variable, retrieve from the recruitment functor at finalize
std::vector<variable> initial_numbers;
std::vector<variable> initial_equilibrium_numbers;
std::vector<variable> initial_deviations; // PARAMETER: fixed or estimated
//
int years;
int seasons;
int forecast_years = 5;
std::vector<variable> length_at_season_start;
std::vector<variable> length_at_spawning;
std::vector<variable> length_at_catch_time;
std::vector<variable> length_at_survey_time;
std::vector<variable> weight_at_season_start;
std::vector<variable> weight_at_spawning;
std::vector<variable> weight_at_catch_time;
std::vector<variable> weight_at_survey_time;
std::vector<variable> equilibrium_to_survival_at_spawning;
std::vector<variable> fecundity_at_age;
std::vector<variable> spawning_stock_biomass;
std::vector<variable> redistributed_recruits;
std::vector<variable> immigrant_recruits;
std::vector<variable> immigrant_recruits_biomass;
std::vector<variable> emigrant_recruits;
std::vector<variable> emigrant_recruits_biomass;
std::vector<variable> imigrants;
std::vector<variable> imigrants_biomass;
std::vector<variable> emigrants;
std::vector<variable> emigrants_biomass;
std::vector<variable> growth;
std::vector<variable> recruitment;
std::vector<variable> spawning_numbers_at_age;
std::vector<variable> biomass_total;
std::vector<variable> fishing_mortality_total;
std::vector<variable> sum_selectivity;
std::vector<variable> Z;
std::vector<variable> P; //selectivity at age.
variable sum_of_Z;
std::vector<variable> S;
std::vector<variable> numbers_at_age;
std::vector<variable> biomass_at_age;
std::vector<variable> abundance;
std::vector<variable> survey_numbers_at_age; //survey numbers at age
std::vector<variable> survey_index_at_age; //survey index at age
std::vector<REAL_T> survey_biomass_total; //survey index total
std::vector<variable> catch_at_age;
std::vector<variable> catch_biomass_at_age;
std::vector<REAL_T> catch_biomass_total;
std::vector<variable> expected_N;
std::vector<variable> N_proj; // numbers-at-age in endyear + 1
static uint32_t length_weight_key_carryout;
MaximumSustainableYield<REAL_T> msy;
REAL_T MSY; // maximum sustainable yield
REAL_T Dmsy; // dead discards at MSY
REAL_T Fmsy; // fishing rate at MSY
REAL_T SSBmsy; // spawning stock biomass at msy
REAL_T Rmsy; // equilibrium recruitment at msy
REAL_T Bmsy; // total biomass (male and female) at msy
REAL_T Emsy; // exploitation rate at msy (total catch / number of fish)
REAL_T spr_msy; // spawners per recruit at msy
REAL_T SPRmsy; // spawning potential ratio (spr_msy/spr_virgin)
/**************************
* Forecasting Containers *
**************************/
std::vector<std::vector<REAL_T> > BootNumbers;
void Initialize() {
typename Area<REAL_T>::active_fleets_iterator af_it;
for (af_it = this->area->active_fleets.begin(); af_it != this->area->active_fleets.end(); ++af_it) {
(*af_it)->f_at_age[this->area->id][this->id].resize(years * seasons * ages.size());
(*af_it)->z_at_age[this->area->id][this->id].resize(years * seasons * ages.size());
if (this->sex == mas::MALE) {
(*af_it)->f_at_age_males[this->area->id][this->id].resize(years * seasons * ages.size());
(*af_it)->z_at_age_males[this->area->id][this->id].resize(years * seasons * ages.size());
} else {
(*af_it)->f_at_age_females[this->area->id][this->id].resize(years * seasons * ages.size());
(*af_it)->z_at_age_females[this->area->id][this->id].resize(years * seasons * ages.size());
}
}
length_at_season_start.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size() + 1);
length_at_spawning.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size());
length_at_catch_time.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size());
length_at_survey_time.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size());
weight_at_season_start.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size() + 1);
weight_at_spawning.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size());
weight_at_catch_time.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size());
weight_at_survey_time.resize(length_weight_key_carryout + this->years * this->seasons * this->ages.size());
equilibrium_to_survival_at_spawning.resize(years * seasons * ages.size());
fecundity_at_age.resize(years * seasons * ages.size());
spawning_numbers_at_age.resize(years * seasons * ages.size());
spawning_stock_biomass.resize(years * seasons);
recruitment.resize(years * seasons);
redistributed_recruits.resize(years * seasons);
immigrant_recruits.resize(years * seasons);
emigrant_recruits.resize(years * seasons);
abundance.resize(years * seasons);
initial_numbers.resize(this->ages.size()*3);
initial_equilibrium_numbers.resize(this->ages.size()*3);
// these are all (fixed or estimated) PARAMETERS
#warning hard coded vector initialS
initialS.resize(this->ages.size(), 1.0); //fixed
M.resize(this->ages.size()); //estimated
initial_deviations.resize(this->ages.size()); //fixed
this->sum_selectivity.resize(years * seasons * this->ages.size());
this->fishing_mortality_total.resize(years * seasons);
// F_at_age.resize(years * seasons * ages.size());
#warning needs to be more efficient, possibly allocating unused memory
std::unordered_set<int>::iterator fit;
for (fit = this->active_fleets.begin(); fit != this->active_fleets.end(); ++fit) {
F_at_age[(*fit)].resize(years * seasons * ages.size());
Z_at_age[(*fit)].resize(years * seasons * ages.size());
}
emigrants.resize(years * seasons * ages.size());
emigrants_biomass.resize(years * seasons * ages.size());
imigrants.resize(years * seasons * ages.size());
imigrants_biomass.resize(years * seasons * ages.size());
growth.resize(years * seasons * ages.size());
Z.resize(years * seasons * ages.size());
F.resize(years * seasons * ages.size());
P.resize(years * seasons * ages.size());
S.resize(years * seasons * ages.size());
biomass_total.resize(years * seasons);
survey_numbers_at_age.resize(years * seasons * ages.size());
survey_index_at_age.resize(years * seasons * ages.size());
survey_biomass_total.resize(years, seasons);
numbers_at_age.resize((years + 1) * seasons * ages.size());
biomass_at_age.resize(years * seasons * ages.size());
catch_at_age.resize(years * seasons * ages.size());
catch_biomass_at_age.resize(years * seasons * ages.size());
catch_biomass_total.resize(years * seasons);
expected_N.resize(years * seasons * ages.size());
N_proj.resize(seasons * ages.size());
}
inline void Reset() {
std::fill(this->catch_biomass_total.begin(), this->catch_biomass_total.end(), static_cast<REAL_T> (0.0));
std::fill(this->survey_biomass_total.begin(), this->survey_biomass_total.end(), static_cast<REAL_T> (0.0));
for (int i = 0; i < numbers_at_age.size(); i++) {
mas::VariableTrait<REAL_T>::SetValue(numbers_at_age[i], static_cast<REAL_T> (0.0));
}
for (int i = 0; i < survey_numbers_at_age.size(); i++) {
mas::VariableTrait<REAL_T>::SetValue(emigrants[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(emigrants_biomass[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(imigrants[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(imigrants_biomass[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(growth[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(Z[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(F[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(P[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(S[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(biomass_at_age[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(survey_numbers_at_age[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(survey_index_at_age[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(catch_at_age[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(catch_biomass_at_age[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(expected_N[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(fecundity_at_age[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(equilibrium_to_survival_at_spawning[i], static_cast<REAL_T> (0.0));
}
for (int i = 0; i < recruitment.size(); i++) {
mas::VariableTrait<REAL_T>::SetValue(recruitment[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(redistributed_recruits[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(immigrant_recruits[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(emigrant_recruits[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(abundance[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(spawning_stock_biomass[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(biomass_total[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(fishing_mortality_total[i], static_cast<REAL_T> (0.0));
}
for (int i = 0; i < this->initial_numbers.size(); i++) {
mas::VariableTrait<REAL_T>::SetValue(initial_numbers[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(initial_equilibrium_numbers[i], static_cast<REAL_T> (0.0));
}
for (int i = 0; i < this->sum_selectivity.size(); i++) {
mas::VariableTrait<REAL_T>::SetValue(this->sum_selectivity[i], static_cast<REAL_T> (0.0));
}
for (int i = 0; i < this->length_at_spawning.size(); i++) {
mas::VariableTrait<REAL_T>::SetValue(weight_at_season_start[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(length_at_season_start[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(length_at_spawning[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(length_at_catch_time[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(length_at_survey_time[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(weight_at_spawning[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(weight_at_catch_time[i], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(weight_at_survey_time[i], static_cast<REAL_T> (0.0));
}
mas::VariableTrait<REAL_T>::SetValue(weight_at_season_start[this->length_at_spawning.size()], static_cast<REAL_T> (0.0));
mas::VariableTrait<REAL_T>::SetValue(length_at_season_start[this->length_at_spawning.size()], static_cast<REAL_T> (0.0));
std::unordered_set<int>::iterator fit;
for (fit = this->active_fleets.begin(); fit != this->active_fleets.end(); ++fit) {
std::fill(F_at_age[(*fit)].begin(), F_at_age[(*fit)].end(), static_cast<REAL_T> (0.0));
std::fill(Z_at_age[(*fit)].begin(), Z_at_age[(*fit)].end(), static_cast<REAL_T> (0.0));
}
typename Area<REAL_T>::active_fleets_iterator af_it;
for (af_it = this->area->active_fleets.begin(); af_it != this->area->active_fleets.end(); ++af_it) {
std::vector<variable>& f_l = (*af_it)->f_at_age[this->area->id][this->id];
std::vector<variable>& z_l = (*af_it)->z_at_age[this->area->id][this->id];
std::fill(f_l.begin(), f_l.end(), static_cast<REAL_T> (0.0));
std::fill(z_l.begin(), z_l.end(), static_cast<REAL_T> (0.0));
if (this->sex == mas::MALE) {
std::vector<variable>& f_m_l = (*af_it)->f_at_age_males[this->area->id][this->id];
std::vector<variable>& z_m_l = (*af_it)->z_at_age_males[this->area->id][this->id];
std::fill(f_m_l.begin(), f_m_l.end(), static_cast<REAL_T> (0.0));
std::fill(z_m_l.begin(), z_m_l.end(), static_cast<REAL_T> (0.0));
} else {
std::vector<variable>& f_f_l = (*af_it)->f_at_age_females[this->area->id][this->id];
std::vector<variable>& z_f_l = (*af_it)->z_at_age_females[this->area->id][this->id];
std::fill(f_f_l.begin(), f_f_l.end(), static_cast<REAL_T> (0.0));
std::fill(z_f_l.begin(), z_f_l.end(), static_cast<REAL_T> (0.0));
}
}
}
/**
* Evaluates length at age and weight at age
*
* time of spawning, peak fishing, and survey could differ across areas for a population
*/
inline void CalculateWeightAtAge() {
std::vector<variable> length_at_season_start_temp(this->ages.size());
std::vector<variable> length_at_spawning_temp(this->ages.size());
std::vector<variable> length_at_catch_time_temp(this->ages.size());
std::vector<variable> length_at_survey_time_temp(this->ages.size());
for (int i = 0; i < ages.size(); ++i) {
variable a = ages[i];
length_at_season_start_temp[i] = this->growth_model->Evaluate(a, this->sex);
length_at_spawning_temp[i] = this->growth_model->Evaluate(a + this->spawning_season_offset, this->sex);
length_at_catch_time_temp[i] = this->growth_model->Evaluate(a + this->catch_season_offset, this->sex);
length_at_survey_time_temp[i] = this->growth_model->Evaluate(a + this->survey_season_offset, this->sex);
}
for (int y = 0; y < this->years; y++) {
for (int s = 0; s < this->seasons; s++) {
for (int a = 0; a < ages.size(); ++a) {
//dimension folded index
size_t index = y * this->seasons * this->ages.size() + s * this->ages.size() + a;
// length at age
length_at_season_start[index] = length_at_season_start_temp[a];
length_at_spawning[index] = length_at_spawning_temp[a];
length_at_catch_time[index] = length_at_catch_time_temp[a];
length_at_survey_time[index] = length_at_survey_time_temp[a];
//weight at season start
this->growth_model->GetWeight(y, s,
this->length_at_season_start[a],
ages[a].GetValue(),
this->sex, this->id, mas::MEAN_WEIGHT_AT_AGE_SEASON_START, weight_at_season_start[index]);
//weight at spawning
this->growth_model->GetWeight(y, s,
this->length_at_spawning[a],
ages[a].GetValue() + this->spawning_season_offset.GetValue(),
this->sex, this->id, mas::MEAN_WEIGHT_AT_AGE_SPAWNING, weight_at_spawning[index]);
this->fecundity_at_age[index] = this->weight_at_spawning[index] * this->maturity[a];
//weight at catch time
this->growth_model->GetWeight(y, s,
this->length_at_catch_time[a],
ages[a].GetValue() + this->catch_season_offset.GetValue(),
this->sex, this->id, mas::CATCH_MEAN_WEIGHT_AT_AGE, weight_at_catch_time[index]);
//weight at survey time
this->growth_model->GetWeight(y, s,
this->length_at_survey_time[a],
ages[a].GetValue() + this->survey_season_offset.GetValue(),
this->sex, this->id, mas::SURVEY_MEAN_WEIGHT_AT_AGE, weight_at_survey_time[index]);
}
}
}
}
inline REAL_T CalculateUnfishedSpawningBiomassPerRecruit() {
std::vector<variable > sb_per_recruit(this->years);
std::vector<variable > s_per_recruit(this->years);
for (int y = 0; y < this->years; y++) {
variable ntemp0 = 1.0;
for (int s = 0; s < this->seasons; s++) {
for (int a = 0; a < ages.size() - 1; a++) {
size_t index = y * this->seasons * this->ages.size() + (s) * this->ages.size() + a;
sb_per_recruit[y] += ntemp0 * (this->weight_at_spawning[index] * this->M[a]) *
mas::mfexp(-1.0 * this->spawning_season_offset * M[a]);
s_per_recruit[y] += ntemp0 * (this->fecundity_at_age[index] * this->M[a]) *
mas::mfexp(-1.0 * this->spawning_season_offset * M[a]);
ntemp0 *= mas::mfexp(-1.0 * this->spawning_season_offset * M[a]);
}
size_t plus_group = this->ages.size() - 1;
size_t index = y * this->seasons * this->ages.size() + (s) * this->ages.size() + plus_group;
ntemp0 /= (1.0 - mas::mfexp(-1.0 * M[plus_group]));
sb_per_recruit[y] += ntemp0 * (this->weight_at_spawning[index] * this->M[this->ages.size() - 1])
* mas::mfexp(-1.0 * this->spawning_season_offset * M[plus_group]);
s_per_recruit[y] += ntemp0 * (this->fecundity_at_age[index] * this->M[this->ages.size() - 1])
* mas::mfexp(-1.0 * this->spawning_season_offset * M[plus_group]);
}
}
this->unfished_spawning_biomass_per_recruit = (sb_per_recruit[this->years - 1]);
this->unfished_spawners_per_recruit = (s_per_recruit[this->years - 1]);
variable ret = sb_per_recruit[this->years - 1];
return ret.GetValue();
}
inline REAL_T CalculateFishedSpawningBiomassPerRecruit_(REAL_T F) {
std::vector<variable> faa(this->F.size());
variable z_sum;
for (int y = 0; y < this->years; y++) {
for (int s = 0; s < this->seasons; s++) {
for (int a = 0; a < ages.size() - 1; a++) {
size_t index = y * this->seasons * this->ages.size() + (s) * this->ages.size() + a;
faa[index] = P[index] * F;
z_sum = faa[index] + M[a];
}
}
}
std::vector<variable > s_per_recruit(this->years);
for (int y = 0; y < this->years; y++) {
variable ntemp0 = 1.0;
for (int s = 0; s < this->seasons; s++) {
for (int a = 0; a < ages.size() - 1; a++) {
size_t index = y * this->seasons * this->ages.size() + (s) * this->ages.size() + a;
s_per_recruit[y] += ntemp0 * (this->weight_at_spawning[index] * this->M[a]) *
mas::mfexp(-1.0 * this->spawning_season_offset * M[a]
- z_sum - P[index] * faa[index]);
ntemp0 *= mas::mfexp(-1.0 * this->spawning_season_offset * M[a]);
}//end a
//plus group
size_t plus_index = this->ages.size() - 1;
size_t index = y * this->seasons * this->ages.size() + (s) * this->ages.size() + plus_index;
ntemp0 /= (1.0 - mas::mfexp(-1.0 * M[plus_index]));
s_per_recruit[y] += ntemp0 * (this->weight_at_spawning[index] * this->M[this->ages.size() - 1])
* mas::mfexp(-1.0 * M[plus_index] -
z_sum - this->spawning_season_offset * P[index] * faa[index]);
}//end s
}//end y
this->fished_spawning_biomass_per_recruit = s_per_recruit[this->years - 1] * this->sex_fraction_value;
variable ret = s_per_recruit[this->years - 1] * this->sex_fraction_value;
return ret.GetValue();
}
inline REAL_T CalculateFishedSpawningBiomassPerRecruit(int year, int season, REAL_T F) {
for (int i = 0; i < this->ages.size(); i++) {
size_t index = year * this->seasons * this->ages.size() + season * this->ages.size() + i;
REAL_T temp = 0.0;
for (int j = 0; j < i; j++) {
size_t index2 = year * this->seasons * this->ages.size() + season * this->ages.size() + j;
temp += F * this->S[index2].GetValue() + this->M[j].GetValue();
}
}
}
inline REAL_T CalculateYieldPerRecruit(REAL_T F) {
REAL_T ret;
for (int i = 0; i < this->ages.size(); i++) {
size_t index = (this->years - 1) * this->seasons * this->ages.size() + (this->seasons - 1) * this->ages.size() + i;
ret += ((this->weight_at_catch_time[index].GetValue() * F * this->sum_selectivity[index].GetValue()) /
(F * this->sum_selectivity[index].GetValue() + this->M[i].GetValue())) * this->CalculateProbabilityOfCaptureAtAge(i, this->years - 1, this->seasons - 1, F) *
this->CalculateProbabilityOfSurvivalToAge(i, this->years - 1, this->seasons - 1, F);
std::cout << ((this->weight_at_catch_time[index].GetValue() * F * this->sum_selectivity[index].GetValue()) /
(F * this->sum_selectivity[index].GetValue() + this->M[i].GetValue())) << " * " << this->CalculateProbabilityOfCaptureAtAge(i, this->years - 1, this->seasons - 1, F) << " * " <<
this->CalculateProbabilityOfSurvivalToAge(i, this->years - 1, this->seasons - 1, F) << std::endl;
// +
// this->CalculateProbabilityOfCaptureAtAgeAOrOlder(this->ages.size() - 1, this->years - 1, this->seasons - 1, F) *
// this->CalculateProbabilityOfSurvivalToAge(i, this->years - 1, this->seasons - 1, F);
}
return ret + this->CalculateProbabilityOfCaptureAtAgeAOrOlder(this->ages.size() - 1, this->years - 1, this->seasons - 1, F) *
this->CalculateProbabilityOfSurvivalToAge(this->ages.size() - 1, this->years - 1, this->seasons - 1, F);
}
inline REAL_T CalculateProbabilityOfSurvivalToAge(int a, int year, int season, REAL_T F) {
REAL_T sum_z = 0;
for (int i = 0; i < a; i++) {
size_t index = year * this->seasons * this->ages.size() + (season) * this->ages.size() + i;
sum_z += F * this->sum_selectivity[index].GetValue() + this->M[i].GetValue();
}
return std::exp(-1.0 * sum_z);
}
inline REAL_T CalculateProbabilityOfCaptureAtAge(int a, int year, int season, REAL_T F) {
size_t index = year * this->seasons * this->ages.size() + (season) * this->ages.size() + a;
return (1.0 - std::exp(-1.0 * F * this->Z[index].GetValue()));
}
inline REAL_T CalculateProbabilityOfCaptureAtAgeAOrOlder(int a, int year, int season, REAL_T F) {
size_t index = year * this->seasons * this->ages.size() + (season) * this->ages.size() + a;
return (this->weight_at_catch_time[index].GetValue() * F * this->sum_selectivity[index].GetValue()) /
(F * this->sum_selectivity[index].GetValue() + this->M[a].GetValue());
}
inline REAL_T CalculateSPR(REAL_T F) {
variable ret = this->CalculateFishedSpawningBiomassPerRecruit(this->years - 1, this->seasons - 1, F) / this->CalculateUnfishedSpawningBiomassPerRecruit();
return ret.GetValue();
}
inline REAL_T CalculateFSPR(REAL_T fraction) {
REAL_T distance = std::numeric_limits<REAL_T>::max();
REAL_T fspr = 0.0;
for (REAL_T f = 0.0; f < 3.0; f += 0.01) {
REAL_T spr = this->CalculateSPR(f);
REAL_T dist = std::fabs(spr - fraction);
if (dist < distance) {
distance = dist;
fspr = f;
}
}
return fspr;
}
inline REAL_T CalculateFMax(const std::vector<REAL_T>& f) {
REAL_T max_yield_per_recruit = std::numeric_limits<REAL_T>::min();
REAL_T Fmax = 0.0;
for (int i = 0; i < f.size(); i++) {
REAL_T mypr = this->CalculateYieldPerRecruit(f[i]);
if (mypr > max_yield_per_recruit) {
max_yield_per_recruit = mypr;
Fmax = f[i];
}
}
return Fmax;
}
inline REAL_T CalculateEquilibriumSpawningBiomass(REAL_T F) {
REAL_T sbpr = this->CalculateFishedSpawningBiomassPerRecruit(this->years - 1, this->seasons - 1, F);
return this->recruitment_model->CalculateEquilibriumSpawningBiomass(sbpr);
}
inline REAL_T CalculateEquilibriumRecruitment(REAL_T F) {
REAL_T esb = CalculateEquilibriumSpawningBiomass(F);
return this->recruitment_model->CalculateEquilibriumRecruitment(esb);
}
inline REAL_T CalculateEquilibriumYield(REAL_T F) {
return this->CalculateEquilibriumRecruitment(F) *
this->CalculateYieldPerRecruit(F);
}
void CalculateMaximumSustainableYield(
REAL_T& msy,
REAL_T& f_msy,
REAL_T& s_msy) {
REAL_T max_yield = std::numeric_limits<REAL_T>::min();
REAL_T f_max = 0.0;
REAL_T s_max = 0.0;
for (REAL_T f = 0.0; f <= 3.0; f += 0.01) {
REAL_T equil_yield = this->CalculateEquilibriumYield(f);
if (equil_yield > max_yield) {
max_yield = equil_yield;
REAL_T esb = this->CalculateEquilibriumSpawningBiomass(f);
f_max = f;
s_max = esb;
}
}
msy = max_yield;
f_msy = f_max;
s_msy = s_max;
}
void InitializeM() {
for (int a = 0; a < this->ages.size(); a++) {
this->M[a] = this->natural_mortality_model->Evaluate(a);
}
}
void CalculateInitialNumbersEquilibrium() {
//note initial_numbers and initial_equilibrium_numbers vectors
//are both size 3*ages.size()
this->R0 = this->sex_fraction_value * mas::mfexp(this->recruitment_model->log_R0);
this->initial_equilibrium_numbers[0] = this->R0;
int a;
for (a = 1; a < this->ages.size(); a++) {
this->initial_equilibrium_numbers[a] = this->initial_equilibrium_numbers[a - 1] *
mas::exp(static_cast<REAL_T> (-1.0) * (this->M[a - 1]));
}
variable m = this->M[a - 1];
variable sum;
for (a = this->ages.size(); a < this->initial_equilibrium_numbers.size(); a++) {
this->initial_equilibrium_numbers[a] = this->initial_equilibrium_numbers[a - 1] * mas::exp(static_cast<REAL_T> (-1.0) * (m));
sum += this->initial_equilibrium_numbers[a];
}
this->initial_equilibrium_numbers[ this->ages.size() - 1] += sum +
(this->initial_equilibrium_numbers[this->initial_equilibrium_numbers.size() - 1] * mas::exp(static_cast<REAL_T> (-1.0) * (m))) /
(1.0 - mas::exp(static_cast<REAL_T> (-1.0) * (m)));
}
void CalculateInitialNumbers() {
// variable sigma_r = this->recruitment_model->sigma_r;
int a;
for (a = 0; a < this->ages.size(); a++) {
this->initial_numbers[a] = (mas::exp(static_cast<REAL_T> (-1.0) *
this->M[a] - this->initialF) * this->initial_equilibrium_numbers[a] *
mas::exp(initial_deviations[a] - static_cast<REAL_T> (0.5)
/* mas::pow(sigma_r, static_cast<REAL_T> (2.0))*/));
}
// /*
// this->initial_numbers[a] = (mas::exp(static_cast<REAL_T> (-1.0) *
// this->M[a] - this->initialF) * this->initial_equilibrium_numbers[a]/*
// mas::exp(initial_deviations[a] - static_cast<REAL_T> (0.5))*/);
// */
}
void CalculateUnfishedEquilSpawningBiomass() {
if (this->sex == FEMALE) {
this->R0 = this->sex_fraction_value * mas::mfexp(this->recruitment_model->log_R0);
this->S0 = this->unfished_spawners_per_recruit * this->R0;
variable temp;
for (int a = 0; a < this->ages.size(); a++) {
temp += this->initial_equilibrium_numbers[a] *
this->weight_at_spawning[a] * this->maturity[a] *
mas::exp(-1.0 * this->spawning_season_offset * this->M[a]);
}
this->recruitment_model->SB0[this->id][this->area->id] = temp;
this->SB0 = temp;
}
}
variable spr_unfished(int year) {
avgR = 0.0;
variable Ntmp = 1.0;
variable SBtmp;
size_t a = 0;
size_t s = 0;
for (size_t i = 0; i < year; i++) {
size_t index = year * this->seasons * this->ages.size() + s * this->ages.size() + a;
avgR += this->numbers_at_age[index];
}
avgR /= (REAL_T)this->years;
for (a = 0; a < this->ages.size(); a++) {
size_t index = year * this->seasons * this->ages.size() + s * this->ages.size() + a;
SBtmp += (Ntmp * this->maturity[a] * this->weight_at_spawning[index] * mas::exp(-1.0 * this->spawning_season_offset * this->M[a]));
Ntmp *= (mas::exp(-1.0 * this->M[a]));
}
size_t index = year * this->seasons * this->ages.size() + s * this->ages.size() + a - 1;
Ntmp /= (mas::exp(-1.0 * this->M[a - 1]));
SBtmp += (Ntmp * this->maturity[a - 1] * this->weight_at_spawning[index] * mas::exp(-1.0 * this->spawning_season_offset * this->M[a - 1]));
return SBtmp;
}
variable spr_ratio(const variable& trial_F, int curryr) {
std::vector<variable> Ntmp(this->ages.size());
std::vector<variable> srvtmp(this->ages.size());
std::vector<variable> Ftmp(this->ages.size());
variable SBcurr;
variable SB0;
variable phi0;
size_t jj = 0;
size_t s = 0;
for (jj = 0; jj < this->ages.size(); jj++) {
size_t index = curryr * this->seasons * this->ages.size() + s * this->ages.size() + jj;
Ftmp[jj] = this->P[index] * trial_F;
srvtmp[jj] = Ftmp[jj] + this->M[jj];
}
SB0 = spr_unfished(curryr);
phi0 = SB0 / avgR;
jj = 0;
size_t index = curryr * this->seasons * this->ages.size() + s * this->ages.size() + jj;
Ntmp[jj] = avgR;
SBcurr += (Ntmp[jj] * this->maturity[jj] * this->weight_at_spawning[index] * mas::exp(-1.0 * this->spawning_season_offset * srvtmp[jj]));
for (jj = 1; jj <this->ages.size(); jj++) {
size_t index = curryr * this->seasons * this->ages.size() + s * this->ages.size() + jj;
Ntmp[jj] = Ntmp[jj - 1] * mas::exp(-1.0 * srvtmp[jj - 1]);
SBcurr += (Ntmp[jj] * this->maturity[jj] * this->weight_at_spawning[index] * mas::exp(-1.0 * this->spawning_season_offset * srvtmp[jj]));
}
size_t end_age = this->ages.size() - 1;
Ntmp[end_age] = (Ntmp[end_age - 1] * mas::exp(-srvtmp[end_age - 1]) / (1.0 - mas::exp(-1.0 * srvtmp[end_age])));
SBcurr += (Ntmp[end_age] * this->maturity[jj] * this->weight_at_spawning[index] * mas::exp(-1.0 * this->spawning_season_offset * srvtmp[end_age]));
return (SBcurr / SB0);
}
variable get_spr_rates(const variable& spr_percent, int curryr) {
REAL_T df = 1.e-3;
variable F1, F2, F3;
variable yld1, yld2, yld3;
variable dyld, dyldp;
F1 = 0.3;
for (int ii = 1; ii <= 10; ii++) // arbitrary fixed intervals
{
F2 = F1 + df;
F3 = F1 - df;
yld1 = /*-1000. */ mas::pow(mas::log(spr_percent / spr_ratio(F1, curryr)), 2.0);
yld2 = /*-1000. */ mas::pow(mas::log(spr_percent / spr_ratio(F2, curryr)), 2.0);
yld3 = /*-1000. */ mas::pow(mas::log(spr_percent / spr_ratio(F3, curryr)), 2.0);
dyld = (yld2 - yld3) / (2. * df); // First derivative (to find the root of this)
dyldp = (yld3 - (2. * yld1) + yld2) / (df * df); // Newton-Raph approximation 2nd deriv
F1 -= (dyld / dyldp);
}
return F1;
}
void BuildBootStrapNumbers() {
this->BootNumbers.resize(this->years,
std::vector<REAL_T>(this->ages.size()));
std::vector<std::vector<REAL_T> >
compressed_numbers(this->years,
std::vector<REAL_T>(this->ages.size()));
std::vector<std::vector<REAL_T> >
compressed_survivability(this->years,
std::vector<REAL_T>(this->ages.size()));
std::vector<REAL_T> NAAbsn(this->ages.size() + 1);
for (int y = 0; y < this->years; y++) {
for (int a = 0; a < this->ages.size(); a++) {
REAL_T temp_n = 0.0;
REAL_T temp_s = 0.0;
for (int s = 0; s < this->seasons; s++) {
size_t index = (y * this->seasons * this->ages.size())+
(s * this->ages.size()) + a;
temp_n += this->numbers_at_age[index].GetValue();
temp_s += this->S[index].GetValue();
}
compressed_numbers[y][a] = temp_n;
std::cout << compressed_numbers[y][a] << " ";
compressed_survivability[y][a] = temp_s;
}
std::cout << "\n";
}
REAL_T tempR = 0.0;
for (int y = 0; y < this->years; y++) {
tempR += std::log(compressed_numbers[y][0]);
}
NAAbsn[0] = std::exp(tempR / (this->years + 1.0));
//NAAbsn(iage) = NAA(nyears, iage - 1) * S(nyears, iage - 1);
std::cout << "BSN Recruitment Vector:\nSex " << this->sex << "\n";
for (int a = 1; a < this->ages.size(); a++) {
NAAbsn[a] = compressed_numbers[this->years - 1][a - 1] *
compressed_survivability[this->years - 1][a - 1];
std::cout << NAAbsn[a] << " ";
}
NAAbsn[this->ages.size()] =
compressed_numbers[this->years - 1][this->ages.size() - 1] *
compressed_survivability[this->years - 1][this->ages.size() - 1];
std::cout << NAAbsn[this->ages.size()] << " ";
std::cout << "\n\n\n";
}
inline void IncrementTime(int& y, int& s) {
if (s == this->seasons) {
y += 1;
s = 1;
} else {
s++;
}
}
inline void DecrementTime(int& y, int& s) {
if (s == 1) {
y -= 1;
s = seasons;
} else {
s--;
}
}
// /**
// * Calculate the F required to harvest the observed catch biomass
// * by 1 fleet in one time period (year) in 1 area with 1 population
// * using bisection search*/
// inline void FitInitialF(size_t max_iterations = 1000, REAL_T tolerance = 1e-5) {
// bool recording = variable::tape.recording;
// variable::tape.recording = false;
// mas::Tape<REAL_T> tape_l; //local tape
// tape_l.derivative_trace_level = atl::SECOND_ORDER_REVERSE;
// atl::Variable<REAL_T> f_l;
// atl::Variable<REAL_T> c_biomass;
// atl::Variable<REAL_T> sum;
// this->initialF.SetValue(static_cast<REAL_T> (0.0));
// tape_l.recording = true;
// REAL_T previous = 0;
// for (size_t iter = 0; iter < max_iterations; iter++) {
// f_l.SetValue(0.0);
// c_biomass.SetValue(0.0);
// sum.SetValue(0.0);
// std::vector< std::shared_ptr<mas::Fleet<REAL_T> > >& fleets = this->area->seasonal_fleet_operations[1];
// for (int f = 0; f < fleets.size(); f++) {
// for (int a = 0; a < this->ages.size(); a++) {
// // variable length_at_catch = this->growth_model->Evaluate(this->ages[a].GetValue() + this->catch_season_offset, this->sex);
// // variable wct = this->weight_at_catch_time[a];
//
// c_biomass.Assign(tape_l, c_biomass + this->weight_at_catch_time[a] *
// fleets[f]->season_area_selectivity[1][this->area->id]->Evaluate(this->ages[a]) *
// this->initialF * this->initial_equilibrium_numbers[a] *
// (1.0 - atl::exp(-this->M[a] - this->initialF)) /
// (this->M[a] + this->initialF), tape_l.NextIndex());
//
// }
// REAL_T C_B = fleets[f]->catch_biomass_data->get(0, 0); //*1000.0;
//
// f_l.Assign(tape_l, f_l + ((C_B) - (c_biomass))*((C_B) - (c_biomass)));
// }
// std::cout << tape_l.Value(this->initialF.info->id) << " " << tape_l.stack_current << "---->\n";
// tape_l.AccumulateSecondOrder();
// REAL_T deltaX = tape_l.Value(this->initialF.info->id) / tape_l.Value(this->initialF.info->id, this->initialF.info->id);
// if (std::fabs(tape_l.Value(this->initialF.info->id)) <= tolerance ||
// deltaX != deltaX) {
// tape_l.Reset();
// break;
// }
// this->initialF.SetValue(this->initialF.GetValue() - deltaX);
// if (iter) {
// if (std::fabs(previous - this->initialF.GetValue()) < 1e-5) {
// tape_l.Reset();
// break;
// }
// }
// previous = this->initialF.GetValue();
// tape_l.Reset();
// }
// variable::tape.recording = recording;
// }
/**
* Calculate the F required to harvest the observed catch biomass
* by 1 fleet in one time period (year) in 1 area with 1 population
* using bisection search*/
inline void FCalc() {
// if (this->initialF.GetValue() == 0.0) {
bool recording = variable::tape.recording;
variable::tape.recording = false;
// this->InitialNumbersEquilibrium();
this->initialF = static_cast<REAL_T> (0.0);
std::vector< std::shared_ptr<Fleet<REAL_T> > >& fleets = this->area->seasonal_fleet_operations[1];
variable wct, wct2;
for (int f = 0; f < fleets.size(); f++) {
if (fleets[f]->catch_biomass_data.get() != NULL) {
// std::shared_ptr<mas::FishingMortality<REAL_T> >& fm =
// fleets[f]->season_area_fishing_mortality[1][this->area->id];
REAL_T Epsilon = 0.0001;
REAL_T LowerBound = 0.0;
REAL_T UpperBound = 10.0;
REAL_T HasConverged = 0;
int Iteration = 0;
int amax = this->ages.size();
while (HasConverged == 0) {
REAL_T MidPoint = (LowerBound + UpperBound) / 2.0;
Iteration = Iteration + 1;
if ((UpperBound - MidPoint) < Epsilon) {
HasConverged = 1;
this->initialF += MidPoint;
break;
}
REAL_T tmp1 = 0.0;
for (int a = 0; a < amax; a++) {
// variable length_at_catch = this->growth_model->Evaluate(this->ages[a].GetValue() + this->catch_fraction_of_year, this->sex);
REAL_T N_ = this->initial_equilibrium_numbers[a].GetValue();
tmp1 = tmp1 + this->weight_at_catch_time[a].GetValue()/*this->weight_at_catch_time[a].GetValue()*/ *
fleets[f]->season_area_selectivity[1][this->area->id]->Evaluate(this->ages[a]).GetValue() *
MidPoint * N_ *
(1.0 - std::exp(-this->natural_mortality_model->Evaluate(a).GetValue() - MidPoint)) /
(this->natural_mortality_model->Evaluate(a).GetValue() + MidPoint);
}
#warning switch to observed catch biomass
//data is in MT
REAL_T C_B = fleets[f]->catch_biomass_data->get(0, 0); //this->C_Biomass[y * this->seasons + s].GetValue();//observed catch biomass
tmp1 = tmp1 - C_B;
REAL_T tmp2 = 0.0;
for (int a = 0; a < amax; a++) {
REAL_T N_ = this->initial_equilibrium_numbers[a].GetValue();
tmp2 = tmp2 + this->weight_at_catch_time[a].GetValue()/*this->weight_at_catch_time[a].GetValue()*/ *
fleets[f]->season_area_selectivity[1][this->area->id]->Evaluate(this->ages[a]).GetValue() *
UpperBound * N_ *
(1.0 - std::exp(-this->natural_mortality_model->Evaluate(a).GetValue() - UpperBound)) /
(this->natural_mortality_model->Evaluate(a).GetValue() + UpperBound);
}
tmp2 = tmp2 - C_B;
if (tmp1 * tmp2 <= 0.0) {
LowerBound = MidPoint;
} else {
UpperBound = MidPoint;
}
}
}
}
variable::tape.recording = recording;
// }
}
/**
* Evaluates mortality for all ages in a year and season.
* @param year
* @param season
*/