-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCatch_at_Age.hpp
94 lines (74 loc) · 2.83 KB
/
Catch_at_Age.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
// Catch_at_Age.hpp
// Age Structured Assessment Modeling System (ASAMS)
#ifndef Catch_at_Age_h
#define Catch_at_Age_h
#include "Survey.hpp"
#include "Fleet.hpp"
#include "Population.hpp"
#include <vector>
#include <map>
#include <set>
namespace asams{
template <class T>
class catch_at_age:public model_base<T>{
public:
// vectors
std::set<fleet<T>*> fleet_list;
std::set<survey<T>*> survey_list;
std::map<int, std::vector<fleet<T>*> > fleets_m;
std::map<int, std::vector<survey<T>*> > surveys_m;
population<T>* population_m;
int nyears;
int nages;
void compute_derived_quantities() {
population_m->prepare();
typename std::set <fleet<T>*>::iterator fleet_iterator;
for(fleet_iterator = fleet_list.begin();
fleet_iterator != fleet_list.end(); ++fleet_iterator){
fleet_iterator->prepare();
}
typename std::set <survey<T>*>::iterator survey_iterator;
for(survey_iterator = survey_list.begin();
survey_iterator != survey_list.end(); ++survey_iterator){
survey_iterator->prepare();
}
population_m->calculate_initial_numbers_at_age();
for(int y=0;y<nyears;y++){
population_m->calculate_growth();
population_m->calculate_maturity(y);
population_m->calculate_mortality(y, fleets_m[y]);
population_m->calculate_numbers_at_age(y);
population_m->calculate_spawning_stock_biomass(y);
population_m->calculate_recruitment(y);
population_m->calculate_catch_at_age(y,fleets_m[y]);
population_m->calculate_survey_numbers_at_age(y,surveys_m[y]);
}
}
void calculate_catch_at_age(int year){
std::vector<fleet<T>*>& fleets = this->fleets_m[year];
for(int i = 0; i < fleets.size(); i++){
fleet<T> * F = fleets[i];
for(int j = 0; j < nages; j++){
}
}
}
void calculate_survey_numbers_at_age(int year, std::vector<survey<T>*>& surveys){
}
T likelihood(){ // objective function
T total_likelihood;
this->compute_derived_quantities();
typename std::set <fleet<T>*>::iterator fleet_iterator;
for(fleet_iterator = fleet_list.begin();
fleet_iterator != fleet_list.end(); ++fleet_iterator){
total_likelihood += fleet_iterator->likelihood();
}
typename std::set <survey<T>*>::iterator survey_iterator;
for(survey_iterator = survey_list.begin();
survey_iterator != survey_list.end(); ++survey_iterator){
total_likelihood += survey_iterator->likelihood();
}
return total_likelihood;
}
};
}
#endif /* Catch_at_Age_h */