DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
nodedata.h
Go to the documentation of this file.
1 /* --------------------------------------------------------------------------
2  * DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
3  * AND EFFORT DISPLACEMENT
4  * Copyright (c) 2012, 2013, 2014 Francois Bastardie <fba@aqua.dtu.dk>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  * --------------------------------------------------------------------------
20  */
21 #ifndef NODEDATA_H
22 #define NODEDATA_H
23 
24 #include <Node.h>
25 
26 #include <QList>
27 #include <QVector>
28 
29 #include <boost/optional.hpp>
30 
31 #include <memory>
32 
33 namespace types {
34 struct NodesPopData;
35 struct NodesBenthosData;
36 }
37 
38 class DisplaceModel;
39 
43 class NodeData : public std::enable_shared_from_this<NodeData>
44 {
45 public:
46  struct Edge {
47  Edge()
48  : source(), target(), weight(0.0) {
49  }
50 
51  Edge(std::shared_ptr<NodeData> src, std::shared_ptr<NodeData> nd, double wt)
52  : source(src), target(nd), weight(wt) {
53  }
54 
55  std::weak_ptr<NodeData> source;
56  std::weak_ptr<NodeData> target;
57  double weight;
58  bool highlighted = false;
59  };
60 
61  typedef QVector<std::shared_ptr<Edge>> AdiacencyList;
62 
63  std::shared_ptr<Node> mNode; /* This is crap. But we have no other choice */
64 
65  explicit NodeData(std::shared_ptr<Node> nd, DisplaceModel *model);
66  virtual ~NodeData();
67 
68  /* Proxy functions to avoid changing too much code */
69  types::NodeId get_idx_node() const { return mNode->get_idx_node(); }
70  int get_marine_landscape() const { return mNode->get_marine_landscape(); }
71  vector<int> get_ff_names_on_node() const { return mNode->get_ff_names_on_node(); }
72  double get_wind() const { return mNode->get_wind(); }
73  double get_sst() const { return mNode->get_sst(); }
74  double get_salinity() const { return mNode->get_salinity(); }
75  double get_Nitrogen() const { return mNode->get_Nitrogen(); }
76  double get_Phosphorus() const { return mNode->get_Phosphorus(); }
77  double get_Oxygen() const { return mNode->get_Oxygen(); }
78  double get_DissolvedCarbon() const { return mNode->get_DissolvedCarbon(); }
79  double get_bathymetry() const { return mNode->get_bathymetry(); }
80  double get_shippingdensity() const { return mNode->get_shippingdensity(); }
81  double get_siltfraction() const { return mNode->get_siltfraction(); }
82  double get_init_benthos_biomass() const { return mNode->get_init_benthos_biomass(); }
83  vector<double> get_benthos_biomass_per_funcgr() const { return mNode->get_benthos_biomass_per_funcgr(); }
84  double get_init_benthos_number() const { return mNode->get_init_benthos_number(); }
85  vector<double> get_benthos_number_per_funcgr() const { return mNode->get_benthos_number_per_funcgr(); }
86  double get_init_benthos_meanweight() const { return mNode->get_init_benthos_meanweight(); }
87  vector<double> get_benthos_meanweight_per_funcgr() const { return mNode->get_benthos_meanweight_per_funcgr(); }
88  void setMarineLandscape(int id) { mNode->setMarineLandscape(id); }
89  void setWind(double w) { mNode->setWind(w); }
90  void setSST(double t) { mNode->setSST(t); }
91  void setSalinity(double s) { mNode->setSalinity(s); }
92  void setNitrogen(double n) { mNode->setNitrogen(n); }
93  void setPhosphorus(double p) { mNode->setPhosphorus(p); }
94  void setOxygen(double o) { mNode->setOxygen(o); }
95  void setDissolvedCarbon(double dc) { mNode->setDissolvedCarbon(dc); }
96  void setBathymetry(double b) { mNode->setBathymetry(b); }
97  void setShippingdensity(double val) { mNode->setShippingdensity(val); }
98  void setSiltfraction(double val) { mNode->setSiltfraction(val); }
99  void setBenthosBiomass(double val) { mNode->setBenthosBiomass(val); }
100  void setBenthosNumber(double val) { mNode->setBenthosNumber(val); }
101  void setBenthosMeanweight(double val) { mNode->setBenthosMeanweight(val); }
102 
103 
104  int get_code_area() const { return mNode->get_code_area(); }
105  void setCodeArea(int id) { mNode->setCodeArea(id); }
106 
107  virtual string get_name() const { return mNode->get_name(); }
108  double get_x() const { return mNode->get_x(); }
109  double get_y() const { return mNode->get_y(); }
110  int get_harbour() const { return mNode->get_harbour(); }
111  bool get_is_harbour() const { return mNode->get_is_harbour(); }
112  int get_cumftime() const { return mNode->get_cumftime(); }
113  void set_cumftime(int i) { mNode->set_cumftime(i); }
114  double get_cumsweptarea() const { return mNode->get_cumsweptarea(); }
115  void set_cumsweptarea(int i) { mNode->set_cumsweptarea(i); }
116  double get_cumsubsurfacesweptarea() const { return mNode->get_cumsubsurfacesweptarea(); }
117  void set_cumsubsurfacesweptarea(int i) { mNode->set_cumsubsurfacesweptarea(i); }
118  double get_cumcatches() const { return mNode->get_cumcatches(); }
119  double get_cumcatches_with_threshold() const { return mNode->get_cumcatches_with_threshold(); }
120  double get_cumdiscards() const { return mNode->get_cumdiscards(); }
121  double get_cumdiscardsratio() const { return mNode->get_cumdiscardsratio(); }
122  double get_nbchoked() const { return mNode->get_nbchoked(); }
123  void set_cumcatches(double v) { mNode->set_cumcatches(v); }
124  void set_cumcatches_with_threshold(int v) { mNode->set_cumcatches_with_threshold(v); }
125  void set_cumdiscards(double v) { mNode->set_cumdiscards(v); }
126  void set_cumdiscardsratio(double v) { mNode->set_cumdiscardsratio(v); }
127  void set_nbchoked(double v) { mNode->set_nbchoked(v); }
128 
129  void set_totNs_per_pop (int pop, int v){ mNode->set_totNs_per_pop(pop, v); }
130  void set_totWs_per_pop(int pop, int v){ mNode->set_totWs_per_pop(pop, v); }
131  void set_cumcatches_per_pop(int pop, int v){ mNode->set_cumcatches_per_pop(pop, v); }
132  void set_cumdiscards_per_pop(int pop, int v){ mNode->set_cumdiscards_per_pop(pop, v); }
133  void set_impact_per_pop(int pop, int v){ mNode->set_impact_per_pop(pop, v); }
134 
135 
136  vector<double> get_tariffs() const { return mNode->get_tariffs(); }
137  void set_tariffs(vector<double> tariffs) { mNode->set_tariffs(tariffs); }
138  const vector<types::NodeId> &get_usual_fgrounds() { return mNode->get_usual_fgrounds(); }
139  void set_usual_fgrounds(vector<types::NodeId> usual_fgrounds) { mNode->set_usual_fgrounds(usual_fgrounds); }
140  const vector<double> &get_freq_usual_fgrounds() { return mNode->get_freq_usual_fgrounds(); }
141  void set_freq_usual_fgrounds(vector<double> freq_usual_fgrounds) { mNode->set_freq_usual_fgrounds(freq_usual_fgrounds); }
142  int evaluateAreaType() { return mNode->evaluateAreaType(); }
143 
144 
145  /* Extending functions */
146 
147  DisplaceModel *getModel() const { return mModel; }
148 
149  int getPopCount() const;
150  int getBenthosPopCount() const;
151  [[deprecated]]
152  void setPop(int pop, double v);
153  [[deprecated]]
154  void setPopTot(double tot);
155  [[deprecated]]
156  void setPop(QList<double> v, double tot);
157  boost::optional<double> getPop(int pop) const ;
158  boost::optional<double> getPopTot () const;
159 
160  [[deprecated]]
161  void setPopW(int pop, double val);
162  [[deprecated]]
163  void setPopWTot(double tot);
164  [[deprecated]]
165  void setPopW(QList<double> v, double tot);
166  boost::optional<double> getPopW(int pop) const ;
167  double getPopWTot () const;
168 
169  [[deprecated]]
170  void setImpact(int pop, double impact);
171  boost::optional<double> getImpact(int pop) const;
172 
173  [[deprecated]]
174  void setCumcatchesPerPop(int pop, double cumcatchesperpop);
175  boost::optional<double> getCumcatchesPerPop(int pop);
176 
177  [[deprecated]]
178  void setCumdiscardsPerPop(int pop, double cumdiscardsperpop);
179  double getCumdiscardsPerPop(int pop);
180 
181  [[deprecated]] void setBenthosBiomass(int func, double benthosbiomass);
182  double getBenthosBiomass(int func) const;
183  [[deprecated]] void setBenthosNumber(int func, double benthosnumber);
184  double getBenthosNumber(int func) const;
185  [[deprecated]] void setBenthosMeanweight(int func, double benthosmeanweight);
186  double getBenthosMeanweight(int func) const ;
187  [[deprecated]] void setBenthosBiomassOverK(int func, double benthosbiomassoverK);
188  double getBenthosBiomassOverK(int func) const ;
189  [[deprecated]] void setBenthosNumberOverK(int func, double benthosnumberoverK);
190  double getBenthosNumberOverK(int func) const;
191 
192  void setFishfarmFishMeanWeight(int farmid, double meanw_kg);
193  double getFishfarmFishMeanWeight(int farm) const {
194  return mFishfarmMeanweight[farm];
195  }
196 
197  void setFishfarmFishHarvestedKg(int farmid, double fish_harvested_kg);
198  double getFishfarmFishHarvestedKg(int farm) const {
199  return mFishfarmFishHarvestedKg[farm];
200  }
201 
202  void setFishfarmEggsHarvestedKg(int farmid, double eggs_harvested_kg);
203  double getFishfarmEggsHarvestedKg(int farm) const {
204  return mFishfarmEggsHarvestedKg[farm];
205  }
206 
207  void setFishfarmAnnualProfit(int farmid, double fishfarm_annualprofit);
208  double getFishfarmAnnualProfit(int farm) const {
209  return mFishfarmAnnualProfit[farm];
210  }
211 
212  void setFishfarmNetDischargeN(int farmid, double fishfarm_netdischargeN);
213  double getFishfarmNetDischargeN(int farm) const {
214  return mFishfarmNetDischargeN[farm];
215  }
216 
217  void setFishfarmNetDischargeP(int farmid, double fishfarm_netdischargeP);
218  double getFishfarmNetDischargeP(int farm) const {
219  return mFishfarmNetDischargeP[farm];
220  }
221 
222  void setFishfarmCumulNetDischargeN(int farmid, double fishfarm_cumulnetdischargeN);
223  double getFishfarmCumulNetDischargeN(int farm) const {
224  return mFishfarmCumulNetDischargeN[farm];
225  }
226 
227  void setFishfarmCumulNetDischargeP(int farmid, double fishfarm_cumulnetdischargeP);
228  double getFishfarmCumulNetDischargeP(int farm) const {
229  return mFishfarmCumulNetDischargeP[farm];
230  }
231 
232  int getHarbourId() const;
233  void setHarbourId(int value);
234 
235  /* Adiacency functions */
236  int appendAdiancency(std::shared_ptr<NodeData> target, double weight);
237  void removeAdiacencyByIdx(int idx);
238  void removeAdiacencyByTarget(std::shared_ptr<NodeData> target);
239  void removeAllAdiacencies();
240  int getAdiacencyCount() const;
241  std::shared_ptr<Edge> getAdiacencyByIdx(int idx) const;
242  double getAdiacencyWeight(int idx) const;
243  void setAdiacencyWeight (int idx, double w);
244  void setAreaType (int value);
245 
246  bool isDeleted() const;
247  void setDeleted(bool value = true);
248 
249  void setRelevant(bool relevant = true) { mRelevant = relevant; }
250  bool isRelevant() const { return mRelevant; }
251 
252 private:
253  DisplaceModel *mModel;
254  bool mDeleted;
255  bool mRelevant;
256  int mHarbourId;
257 
258  double *mFishfarmMeanweight;
259  double *mFishfarmFishHarvestedKg;
260  double *mFishfarmEggsHarvestedKg;
261  double *mFishfarmAnnualProfit;
262  double *mFishfarmNetDischargeN;
263  double *mFishfarmNetDischargeP;
264  double *mFishfarmCumulNetDischargeN;
265  double *mFishfarmCumulNetDischargeP;
266 
267  std::shared_ptr<types::NodesPopData> getNodesData() const;
268  std::shared_ptr<types::NodesBenthosData> getBenthosData() const;
269 
270  int areaType;
271 
272  AdiacencyList mAdiacency;
273 };
274 
275 #endif // NODEDATA_H
void setFishfarmNetDischargeN(int farmid, double fishfarm_netdischargeN)
Definition: nodedata.cpp:276
void setBenthosBiomassOverK(int func, double benthosbiomassoverK)
Definition: nodedata.cpp:203
double getBenthosBiomassOverK(int func) const
Definition: nodedata.cpp:238
double getBenthosNumberOverK(int func) const
Definition: nodedata.cpp:247
void set_cumdiscardsratio(double v)
Definition: nodedata.h:126
boost::optional< double > getImpact(int pop) const
Definition: nodedata.cpp:138
boost::optional< double > getPop(int pop) const
Definition: nodedata.cpp:111
double get_sst() const
Definition: nodedata.h:73
void setFishfarmEggsHarvestedKg(int farmid, double eggs_harvested_kg)
Definition: nodedata.cpp:266
void set_cumdiscards(double v)
Definition: nodedata.h:125
double weight
Definition: nodedata.h:57
boost::optional< double > getPopTot() const
Definition: nodedata.cpp:120
QVector< std::shared_ptr< Edge > > AdiacencyList
Definition: nodedata.h:61
void set_totNs_per_pop(int pop, int v)
Definition: nodedata.h:129
double get_init_benthos_meanweight() const
Definition: nodedata.h:86
void setShippingdensity(double val)
Definition: nodedata.h:97
void setFishfarmNetDischargeP(int farmid, double fishfarm_netdischargeP)
Definition: nodedata.cpp:281
void setDissolvedCarbon(double dc)
Definition: nodedata.h:95
double get_salinity() const
Definition: nodedata.h:74
vector< double > get_tariffs() const
Definition: nodedata.h:136
double get_cumdiscardsratio() const
Definition: nodedata.h:121
double get_cumcatches_with_threshold() const
Definition: nodedata.h:119
int evaluateAreaType()
Definition: nodedata.h:142
bool isDeleted() const
Definition: nodedata.cpp:364
void setFishfarmCumulNetDischargeN(int farmid, double fishfarm_cumulnetdischargeN)
Definition: nodedata.cpp:286
void set_cumsweptarea(int i)
Definition: nodedata.h:115
double getFishfarmFishHarvestedKg(int farm) const
Definition: nodedata.h:198
void setCumcatchesPerPop(int pop, double cumcatchesperpop)
Definition: nodedata.cpp:183
double get_Nitrogen() const
Definition: nodedata.h:75
Edge(std::shared_ptr< NodeData > src, std::shared_ptr< NodeData > nd, double wt)
Definition: nodedata.h:51
double get_nbchoked() const
Definition: nodedata.h:122
int getAdiacencyCount() const
Definition: nodedata.cpp:344
void set_cumcatches_per_pop(int pop, int v)
Definition: nodedata.h:131
Definition: idtypes.h:52
int get_cumftime() const
Definition: nodedata.h:112
NodeData(std::shared_ptr< Node > nd, DisplaceModel *model)
Definition: nodedata.cpp:26
void setOxygen(double o)
Definition: nodedata.h:94
double getAdiacencyWeight(int idx) const
Definition: nodedata.cpp:354
double get_cumsweptarea() const
Definition: nodedata.h:114
double getFishfarmCumulNetDischargeN(int farm) const
Definition: nodedata.h:223
void setAreaType(int value)
Definition: nodedata.cpp:306
double getBenthosNumber(int func) const
Definition: nodedata.cpp:220
void setBenthosBiomass(double val)
Definition: nodedata.h:99
int getHarbourId() const
Definition: nodedata.cpp:296
void set_nbchoked(double v)
Definition: nodedata.h:127
int appendAdiancency(std::shared_ptr< NodeData > target, double weight)
NodeData::appendAdiancency.
Definition: nodedata.cpp:317
std::weak_ptr< NodeData > source
Definition: nodedata.h:55
double getFishfarmAnnualProfit(int farm) const
Definition: nodedata.h:208
double getCumdiscardsPerPop(int pop)
void setDeleted(bool value=true)
Definition: nodedata.cpp:369
boost::optional< double > getPopW(int pop) const
Definition: nodedata.cpp:169
void set_cumcatches(double v)
Definition: nodedata.h:123
double get_cumsubsurfacesweptarea() const
Definition: nodedata.h:116
double get_cumcatches() const
Definition: nodedata.h:118
int get_harbour() const
Definition: nodedata.h:110
void set_freq_usual_fgrounds(vector< double > freq_usual_fgrounds)
Definition: nodedata.h:141
double get_cumdiscards() const
Definition: nodedata.h:120
int get_marine_landscape() const
Definition: nodedata.h:70
void setSalinity(double s)
Definition: nodedata.h:91
vector< double > get_benthos_biomass_per_funcgr() const
Definition: nodedata.h:83
virtual ~NodeData()
void setBenthosNumberOverK(int func, double benthosnumberoverK)
Definition: nodedata.cpp:207
double get_DissolvedCarbon() const
Definition: nodedata.h:78
void setHarbourId(int value)
Definition: nodedata.cpp:301
Definition: idtypes.h:9
void setBenthosMeanweight(double val)
Definition: nodedata.h:101
boost::optional< double > getCumcatchesPerPop(int pop)
Definition: nodedata.cpp:147
void setPopW(int pop, double val)
Definition: nodedata.cpp:157
virtual string get_name() const
Definition: nodedata.h:107
double get_init_benthos_number() const
Definition: nodedata.h:84
void removeAdiacencyByTarget(std::shared_ptr< NodeData > target)
Definition: nodedata.cpp:328
void setPopTot(double tot)
Definition: nodedata.cpp:103
types::NodeId get_idx_node() const
Definition: nodedata.h:69
Definition: displacemodel.h:71
void set_cumcatches_with_threshold(int v)
Definition: nodedata.h:124
double get_y() const
Definition: nodedata.h:109
vector< double > get_benthos_number_per_funcgr() const
Definition: nodedata.h:85
std::weak_ptr< NodeData > target
Definition: nodedata.h:56
double get_siltfraction() const
Definition: nodedata.h:81
double getFishfarmNetDischargeN(int farm) const
Definition: nodedata.h:213
Edge()
Definition: nodedata.h:47
void setPop(int pop, double v)
Definition: nodedata.cpp:99
void setFishfarmCumulNetDischargeP(int farmid, double fishfarm_cumulnetdischargeP)
Definition: nodedata.cpp:291
bool highlighted
Definition: nodedata.h:58
double get_x() const
Definition: nodedata.h:108
Definition: graphbuilder.h:68
void setSST(double t)
Definition: nodedata.h:90
std::pair< box, unsigned > value
Definition: diffusion.cpp:30
an extension class for Node
Definition: nodedata.h:43
int getPopCount() const
Definition: nodedata.cpp:88
double get_shippingdensity() const
Definition: nodedata.h:80
void removeAllAdiacencies()
Definition: nodedata.cpp:339
void setFishfarmFishMeanWeight(int farmid, double meanw_kg)
Definition: nodedata.cpp:256
void setCodeArea(int id)
Definition: nodedata.h:105
double getBenthosMeanweight(int func) const
Definition: nodedata.cpp:229
vector< double > get_benthos_meanweight_per_funcgr() const
Definition: nodedata.h:87
void set_cumdiscards_per_pop(int pop, int v)
Definition: nodedata.h:132
bool get_is_harbour() const
Definition: nodedata.h:111
void setPopWTot(double tot)
Definition: nodedata.cpp:161
void setSiltfraction(double val)
Definition: nodedata.h:98
int getBenthosPopCount() const
Definition: nodedata.cpp:93
void setCumdiscardsPerPop(int pop, double cumdiscardsperpop)
Definition: nodedata.cpp:187
void setFishfarmAnnualProfit(int farmid, double fishfarm_annualprofit)
Definition: nodedata.cpp:271
double getFishfarmFishMeanWeight(int farm) const
Definition: nodedata.h:193
Definition: nodedata.h:46
const vector< double > & get_freq_usual_fgrounds()
Definition: nodedata.h:140
void set_totWs_per_pop(int pop, int v)
Definition: nodedata.h:130
void setMarineLandscape(int id)
Definition: nodedata.h:88
void setFishfarmFishHarvestedKg(int farmid, double fish_harvested_kg)
Definition: nodedata.cpp:261
double getPopWTot() const
Definition: nodedata.cpp:129
const vector< types::NodeId > & get_usual_fgrounds()
Definition: nodedata.h:138
void setPhosphorus(double p)
Definition: nodedata.h:93
void set_usual_fgrounds(vector< types::NodeId > usual_fgrounds)
Definition: nodedata.h:139
double getFishfarmNetDischargeP(int farm) const
Definition: nodedata.h:218
double get_Phosphorus() const
Definition: nodedata.h:76
std::shared_ptr< Edge > getAdiacencyByIdx(int idx) const
Definition: nodedata.cpp:349
double getBenthosBiomass(int func) const
Definition: nodedata.cpp:211
void set_cumsubsurfacesweptarea(int i)
Definition: nodedata.h:117
void setWind(double w)
Definition: nodedata.h:89
void set_cumftime(int i)
Definition: nodedata.h:113
double getFishfarmEggsHarvestedKg(int farm) const
Definition: nodedata.h:203
vector< int > get_ff_names_on_node() const
Definition: nodedata.h:71
bool isRelevant() const
Definition: nodedata.h:250
double getFishfarmCumulNetDischargeP(int farm) const
Definition: nodedata.h:228
void setBenthosNumber(double val)
Definition: nodedata.h:100
void setRelevant(bool relevant=true)
Definition: nodedata.h:249
void setNitrogen(double n)
Definition: nodedata.h:92
void setImpact(int pop, double impact)
Definition: nodedata.cpp:178
double get_bathymetry() const
Definition: nodedata.h:79
double get_wind() const
Definition: nodedata.h:72
void removeAdiacencyByIdx(int idx)
Definition: nodedata.cpp:323
double get_Oxygen() const
Definition: nodedata.h:77
std::shared_ptr< Node > mNode
Definition: nodedata.h:63
void setAdiacencyWeight(int idx, double w)
Definition: nodedata.cpp:359
double get_init_benthos_biomass() const
Definition: nodedata.h:82
DisplaceModel * getModel() const
Definition: nodedata.h:147
void set_tariffs(vector< double > tariffs)
Definition: nodedata.h:137
void set_impact_per_pop(int pop, int v)
Definition: nodedata.h:133
void setBathymetry(double b)
Definition: nodedata.h:96
int get_code_area() const
Definition: nodedata.h:104