DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
timeseries.h
Go to the documentation of this file.
1 #ifndef TIMESERIES_H
2 #define TIMESERIES_H
3 
4 #include <commons_global.h>
5 #include <vector>
6 #include <cmath>
7 #include <iostream>
8 
9 namespace displace {
10 namespace simulation {
11 
13 {
14 public:
15  TimeSeries();
16 
17  double getThreshold(int idx) const {
18  return mThresholds.at(idx);
19  }
20 
21  double getValue (int idx) const {
22  return mData.at(idx);
23  }
24 
25  int evaluateThresholds (int idx) {
26  int i;
27  for (i = 0; i < (int)mThresholds.size(); ++i) {
28  //std::cout << "in evaluateThresholds(), current data is " << mData.at(idx) << ", compared to threshold " << i << ": " << mThresholds[i] << std::endl;
29  if (std::isnan(mThresholds[i]) || mData.at(idx) < mThresholds[i])
30  return i;
31  }
32  return i;
33  }
34 
35  void setThreshold (int idx, double value);
36  void appendValue (double value) {
37  mData.push_back(value);
38  }
39 
40 private:
41  std::vector<double> mThresholds;
42  std::vector<double> mData;
43 };
44 
45 
46 } }
47 
48 
49 #endif // TIMESERIES_H
Definition: timeseries.h:12
double getThreshold(int idx) const
Definition: timeseries.h:17
Definition: decisiontreemanager.h:13
int evaluateThresholds(int idx)
Definition: timeseries.h:25
std::pair< box, unsigned > value
Definition: diffusion.cpp:30
double getValue(int idx) const
Definition: timeseries.h:21
void appendValue(double value)
Definition: timeseries.h:36
#define COMMONSSHARED_EXPORT
Definition: commons_global.h:23