DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
timeseriesevaluator.h
Go to the documentation of this file.
1 #ifndef TIMESERIESEVALUATOR_H
2 #define TIMESERIESEVALUATOR_H
3 
4 #include <simulation.h>
5 #include <Vessel.h>
6 #include <dtree/stateevaluator.h>
7 #include <tseries/timeseries.h>
9 
10 #include <Node.h>
11 #include <Metier.h>
12 
13 namespace displace {
14 namespace dtree {
15 
16 template <displace::simulation::TimeSeriesManager::Variables Var>
18 {
19 public:
21 
22  double evaluate(int tstep, Vessel *v) const {
23  // NOTE: tstep must be converted to day!
24 
26  if (!ts) {
27  std::cerr << "** ERROR: Time Series not found for: " << Var << " " << 0 << " " << v->get_loc()->get_code_area();
28  exit (1);
29  }
30  return ts->evaluateThresholds((tstep / 24) % 365);
31  }
32 };
33 
34 template <>
36 {
37 public:
39 
40  double evaluate(int tstep, Vessel *v) const {
41  // NOTE: tstep must be converted to day!
42 
43  int adim =0;
44 
45  // find out the bunch of targeted stocks and decide from the currently more priced one among them
46  vector<int> trgts =v->get_metier()->get_metier_target_stocks();
47  vector <double> values;
48 
49  for (size_t i=0; i<trgts.size(); i++)
50  {
51  adim = trgts.at(i);
52  cout << v->get_name() << " look at the price of the target -> stock " << adim << endl;
54  values.push_back (a_ts->evaluateThresholds((tstep / 24) % 365));
55  }
56  return *(max_element(values.begin(), values.end()));
57  }
58 };
59 
60 
61 
62 }
63 }
64 
65 #endif // TIMESERIESEVALUATOR_H
Definition: timeseries.h:12
Definition: timeseriesmanager.h:17
std::string get_name() const
Definition: Vessel.cpp:429
Definition: timeseriesevaluator.h:17
Definition: decisiontreemanager.h:13
Metier * get_metier() const
Definition: Vessel.cpp:450
double evaluate(int tstep, Vessel *v) const
evaluate the state/variable, and returns the selected output, as double. Client can decide what to do...
Definition: timeseriesevaluator.h:40
int tstep
Definition: main.cpp:205
vector< int > get_metier_target_stocks()
Definition: Metier.cpp:192
double evaluate(int tstep, Vessel *v) const
evaluate the state/variable, and returns the selected output, as double. Client can decide what to do...
Definition: timeseriesevaluator.h:22
int evaluateThresholds(int idx)
Definition: timeseries.h:25
An abstract class to allow internal/External states to be evaluated.
Definition: stateevaluator.h:14
Definition: Vessel.h:51
Definition: commonstateevaluators.h:8
Node * get_loc() const
Definition: Vessel.cpp:444
TimeSeriesEvaluator()
Definition: timeseriesevaluator.h:20
int get_code_area() const
Definition: Node.cpp:246
static Simulation * instance()
Definition: simulation.cpp:49
TimeSeries * getTimeSeries(TimeSeriesManager::Variables var, int zone, int adim)
Definition: simulation.cpp:100