DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
myutils.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-2019 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 __MYUTILS_H
22 #define __MYUTILS_H (1)
23 
24 #include <commons_global.h>
25 #include <sparsepp/spp.h>
26 
27 #include <vesselcalendar.h>
28 #include <idtypes.h>
29 #include <utils/MultifieldReader.h>
30 
31 #include<vector>
32 #include<deque>
33 #include<map>
34 #include <list>
35 #include <set>
36 #include<string>
37 #include <iostream>
38 #include <iomanip>
39 #include <sstream>
40 #include <fstream>
41 
42 #include <algorithm>
43 #include <numeric>
44 #include <cmath>
45 #include <math.h>
46 
47 #include <cstddef>
48 #include <pathshop.h>
49 
50 #include <numeric>
51 
52 using namespace std;
53 
54 //---------------------------------------//
55 // general util.
56 //---------------------------------------//
57 
58 
59 template<double f(double, double, double)>
60 double simpson(double a, double b, int n, double S1, double S2){
61  double h=(b-a)/n;
62  double sum=f(a, S1, S2)*0.5;
63  for (int i=1; i<n; i++) sum+=f(a+i*h, S1, S2);
64  sum+= f(b, S1, S2)*0.5;
65 
66  double summid=0.0;
67  for(int i=1; i<=n; i++) summid+=f(a+ (i-0.5)*h, S1, S2);
68 
69  return (sum + 2*summid)*h/3.0;
70 }
71 
72 
73 
74 template <typename T>
75 vector<size_t> sort_indexes_ascending(const vector<T> &v) {
76 
77  // initialize original index locations
78  vector<size_t> idx(v.size());
79  iota(idx.begin(), idx.end(), 0);
80 
81  // sort indexes based on comparing values in v
82  sort(idx.begin(), idx.end(),
83  [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});
84 
85  return idx;
86 }
87 // usage:
88 //for (auto i: sort_indexes(v)) {
89 // cout << v[i] << endl;
90 //}
91 template <typename T>
92 vector<size_t> sort_indexes_descending(const vector<T> &v) {
93 
94  // initialize original index locations
95  vector<size_t> idx(v.size());
96  ::iota(idx.begin(), idx.end(), 0);
97 
98  // sort indexes based on comparing values in v
99  sort(idx.begin(), idx.end(),
100  [&v](size_t i1, size_t i2) {return v[i1] > v[i2];});
101 
102  return idx;
103 }
104 
105 
106 
107 
108 double COMMONSSHARED_EXPORT trapezoidal(double a, double b, vector <double> sel);
109 double COMMONSSHARED_EXPORT myintegrand(double x, double S1, double S2);
110 
111 template <typename T>
112 void remove_dups(vector<T>& seq)
113 {
114  sort( seq.begin(), seq.end() ) ;
115  seq.erase( unique( seq.begin(), seq.end() ), seq.end() ) ;
116 }
117 
118 void COMMONSSHARED_EXPORT remove_dups(vector<int>& seq);
119 multimap<int,int> COMMONSSHARED_EXPORT remove_dups(multimap<int,int>& original_map); // keep the first pair of all keys
120 
121 // to keep the first element of all the keys only:
122 template<typename K, typename V>
123 multimap<K,V> remove_dups(multimap<K,V>& original_map)
124 {
125  multimap<K,V> new_map;
126 
127  while (original_map.size() > 0)
128  {
129  auto element = *(original_map.begin());
130  new_map.insert(make_pair(element.first,element.second));
131  original_map.erase(element.first);
132  }
133  return(new_map);
134 }
135 
136 
137 // remove key-value duplicates
138 multimap<int,int>::const_iterator COMMONSSHARED_EXPORT find_pair(const multimap<int,int>& map, const pair<int, int>& pair);
139 bool COMMONSSHARED_EXPORT insert_if_not_present(multimap<int,int>& map, const pair<int, int>& pair);
140 // to remove key-value duplicates:
141 template <typename K, typename V>
142 typename multimap<K,V>::const_iterator find_pair(const multimap<K,V>& map, const pair<K, V>& pair)
143 {
144  auto range = map.equal_range(pair.first);
145  for (auto p = range.first; p != range.second; ++p)
146  if (p->second == pair.second)
147  return p;
148  return map.end();
149 }
150 
151 template <typename K, typename V>
152 bool insert_if_not_present(multimap<K,V>& map, const pair<K,V>& pair)
153 {
154  if (find_pair(map, pair) == map.end()) {
155  map.insert(pair);
156  return true;
157  }
158  return false;
159 }
160 
161 //void print( vector <string> & v );
162 //void print_d( vector <double> & v );
163 
165 {
166  enum empties_t { empties_ok, no_empties };
167 };
168 
169 template <typename Container>
170 Container& split(
171  Container& result,
172  const typename Container::value_type& s,
173  const typename Container::value_type& delimiters,
175 {
176  result.clear();
177  size_t current;
178  size_t next = -1;
179  do
180  {
181  if (empties == splitX::no_empties)
182  {
183  next = s.find_first_not_of( delimiters, next + 1 );
184  if (next == Container::value_type::npos) break;
185  next -= 1;
186  }
187  current = next + 1;
188  next = s.find( delimiters, current );
189  result.push_back( s.substr( current, next - current ) );
190  }
191  while (next != Container::value_type::npos);
192  return result;
193 }
194 
195 
196 
197 
198 //---------------------------------------//
199 // graph related (Dijkstra, etc.)
200 //---------------------------------------//
201 
202 //simple graph type definition headers>>
204 typedef int weight_t; // 'integer' instead of 'double' to speedup c++
205 
207 {
210  edge(vertex_t arg_target, weight_t arg_weight)
211  : target(arg_target), weight(arg_weight) { }
212 };
213 
214 typedef std::map<vertex_t, std::list<edge> > adjacency_map_t;
215 
218  spp::sparse_hash_map<vertex_t, weight_t>& min_distance,
219  spp::sparse_hash_map<vertex_t, vertex_t>& previous,
220  std::vector<types::NodeId> relevant_nodes);
221 
222 std::list<vertex_t> COMMONSSHARED_EXPORT DijkstraGetShortestPathTo(vertex_t target, spp::sparse_hash_map<vertex_t, vertex_t> &previous);
223 std::list<types::NodeId> COMMONSSHARED_EXPORT DijkstraGetShortestPathTo(types::NodeId target, const PathShop &pathshop);
224 
226  spp::sparse_hash_map<vertex_t, vertex_t>& previous,
227  std::vector<types::NodeId> &relevant_nodes,
228  spp::sparse_hash_map<vertex_t, weight_t>& min_distance,
229  string namesimu,
230  string a_graph_name,
231  string inputfolder);
232 
233 void COMMONSSHARED_EXPORT closeSomeNodes(std::vector<int>& nodes_to_be_closed, adjacency_map_t& adjacency_map);
234 
235 vector<double> COMMONSSHARED_EXPORT compute_distance_fgrounds(const vector<types::NodeId> &relevant_nodes,
236  const std::vector<PathShop> &pathshops,
237  types::NodeId from,
238  vector<types::NodeId> grounds);
239 
240 
241 //---------------------------------------//
242 // data input
243 //---------------------------------------//
244 
245 bool COMMONSSHARED_EXPORT fill_from_coord (istream& in, vector<double>& graph_coord_x,
246  vector<double> & graph_coord_y,
247  vector<int>& graph_coord_harbour, int nrow);
248 bool COMMONSSHARED_EXPORT fill_from_graph (istream& in, vector<int>& graph_idx_dep,
249  vector<int> & graph_idx_arr,
250  vector<int>& graph_dist_km, int nrow);
251 bool COMMONSSHARED_EXPORT fill_from_code_area (istream& in, vector<int>& graph_point_code_area,
252  int nrow);
253 bool COMMONSSHARED_EXPORT fill_from_code_marine_landscape (istream& in, vector<int>& graph_point_code_landscape,
254  int nrow);
255 bool COMMONSSHARED_EXPORT fill_from_wind (istream& in, vector<double>& graph_point_wind,
256  int nrow);
257 bool COMMONSSHARED_EXPORT fill_from_sst (istream& in, vector<double>& graph_point_sst,
258  int nrow);
259 bool COMMONSSHARED_EXPORT fill_from_salinity (istream& in, vector<double>& graph_point_salinity,
260  int nrow);
261 bool COMMONSSHARED_EXPORT fill_from_Nitrogen (istream& in, vector<double>& graph_point_Nitrogen,
262  int nrow);
263 bool COMMONSSHARED_EXPORT fill_from_Phosphorus (istream& in, vector<double>& graph_point_Phosphorus,
264  int nrow);
265 bool COMMONSSHARED_EXPORT fill_from_Oxygen (istream& in, vector<double>& graph_point_Oxygen,
266  int nrow);
267 bool COMMONSSHARED_EXPORT fill_from_DissolvedCarbon (istream& in, vector<double>& graph_point_DissolvedCarbon,
268  int nrow);
269 bool COMMONSSHARED_EXPORT fill_from_bathymetry (istream& in, vector<double>& graph_point_bathymetry,
270  int nrow);
271 bool COMMONSSHARED_EXPORT fill_from_shippingdensity (istream& in, vector<double>& graph_point_shippingdensity,
272  int nrow);
273 
274 bool COMMONSSHARED_EXPORT fill_from_siltfraction (istream& in, vector<double>& graph_point_siltfraction,
275  int nrow);
276 
277 bool COMMONSSHARED_EXPORT fill_from_benthos_biomass (istream& in, vector<double>& graph_point_benthos_biomass,
278  int nrow);
279 bool COMMONSSHARED_EXPORT fill_from_benthos_number (istream& in, vector<double>& graph_point_benthos_number,
280  int nrow);
281 bool COMMONSSHARED_EXPORT fill_in_growth_transition (istream& in, vector< vector<double> >& growth_transition);
282 bool COMMONSSHARED_EXPORT fill_in_species_interactions_mortality_proportion_matrix (istream& in, vector< vector<double> >& species_interactions_mortality_proportion_matrix);
283 bool COMMONSSHARED_EXPORT fill_in_preferences_for_species_matrix (istream& in, vector< vector<double> >& preferences_for_species_matrix);
284 bool COMMONSSHARED_EXPORT fill_in_selectivity_per_stock(istream& in, vector< vector<double> >& growth_transition);
285 bool COMMONSSHARED_EXPORT fill_in_percent_szgroup_per_age_matrix (istream& in, vector< vector<double> >& percent_szgroup_per_age_matrix);
286 bool COMMONSSHARED_EXPORT fill_in_percent_age_per_szgroup_matrix (istream& in, vector< vector<double> >& percent_age_per_szgroup_matrix);
287 bool COMMONSSHARED_EXPORT fill_in_param_sr (istream& in, vector<double>& param_sr);
288 bool COMMONSSHARED_EXPORT fill_in_initial_tac (istream& in, vector<double>& initial_tac);
289 bool COMMONSSHARED_EXPORT fill_in_fbar_ages_min_max (istream& in, vector<double>& fbar_ages_min_max);
290 bool COMMONSSHARED_EXPORT fill_from_metier_specifications (istream& in, multimap<string, double>& infos);
291 bool COMMONSSHARED_EXPORT fill_from_vessels_specifications(istream& in, vector<string>& names,
292  vector<int>& vid_is_actives,
293  vector<int>& vid_is_part_of_ref_fleets,
294  vector<double>& speeds,
295  vector<double>& fuelcons,
296  vector<double>& lengths,
297  vector<double>& vKWs,
298  vector<double>& carrycapacities,
299  vector<double>& tankcapacities,
300  vector<double>& nbfpingspertrips,
301  vector<double>& resttime_par1s,
302  vector<double>& resttime_par2s,
303  vector<double>& av_trip_duration,
304  vector<double>& mult_fuelcons_when_steaming,
305  vector<double>& mult_fuelcons_when_fishing,
306  vector<double>& mult_fuelcons_when_returning,
307  vector<double>& mult_fuelcons_when_inactive,
308  vector<int>& firm_ids,
309  vector<VesselCalendar> &calendars);
310 
312  vector<double>& this_vessel_nb_crews,
313  vector<double>& annual_other_incomes,
314  vector<double>& landing_costs_percents,
315  vector<double>& crewshare_and_unpaid_labour_costs_percents,
316  vector<double>& other_variable_costs_per_unit_efforts,
317  vector<double>& annual_insurance_costs_per_crews,
318  vector<double>& standard_labour_hour_opportunity_costss,
319  vector<double>& standard_annual_full_time_employement_hourss,
320  vector<double>& other_annual_fixed_costss,
321  vector<double>& vessel_values,
322  vector<double>& annual_depreciation_rates,
323  vector<double>& opportunity_interest_rates,
324  vector<double>& annual_discount_rates);
325 
326 bool COMMONSSHARED_EXPORT fill_from_ships_specifications (istream& in, vector<string>& names, vector<double> &imos,
327  vector<double> &yearbuilds, vector<string> &flags,
328  vector<string> &types, vector<double> &typecodes,
329  vector<double> &loas, vector<double> &KWs, vector<double> &breadths,
330  vector<double> &grosstonnages,
331  vector<double> &nbunits,
332  vector<double> &fueluse,
333  vector<double> &NOxEmission_gperKWh,
334  vector<double> &SOxEmission_percentpertotalfuelmass,
335  vector<double> &GHGEmission,
336  vector<double> &PMEmission,
337  vector<double>& vmaxs,
338  vector<double>& vcruises,
339  vector<double>& lane_ids);
341  vector<int> & fishfarms_ids,
342  vector<string> & fishfarms_names,
343  vector<int> & idx_nodes,
344  vector<int> & is_actives,
345  vector<double> &sizes,
346  vector<double> & longs,
347  vector<double> & lats,
348  vector<double>& mean_SSTs,
349  vector<double>& mean_salinities,
350  vector<double>& mean_windspeeds,
351  vector<double>& mean_currentspeeds,
352  vector<double>& max_depths,
353  vector<double>& diss_O2_mg_per_ls,
354  vector<double>& Linf_mms,
355  vector<double>& K_ys,
356  vector<double>& t0_ys,
357  vector<double>& fulton_condition_factors,
358  vector<string>& meanw_growth_model_types,
359  vector<int>& start_day_growings,
360  vector<int>& end_day_harvests,
361  vector<int> & nbyears_for_growths,
362  vector<int>& nb_days_fallowing_periods,
363  vector<int>& nb_fish_at_starts,
364  vector<double>& meanw_at_starts,
365  vector<double>& price_per_kg_at_starts,
366  vector<double>& target_meanw_at_harvests,
367  vector<int>& nb_fish_at_harvests,
368  vector<double>& meanw_at_harvests,
369  vector<double>& prop_harvest_kg_solds,
370  vector<double>& kg_eggs_per_kgs,
371  vector<double>& price_eggs_per_kgs,
372  vector<double>& N_in_fish_kg_3pers,
373  vector<double>& P_in_fish_kg_0_5pers,
374  vector<string>& feed_types,
375  vector<double>& feed_price_per_kgs,
376  vector<double>& total_feed_kg,
377  vector<double>& prop_N_in_feeds,
378  vector<double>& prop_P_in_feeds,
379  vector<double>& total_feed_N_kgs,
380  vector<double>& total_feed_P_kgs,
381  vector<string>& feed_type_vets,
382  vector<double>& feed_vet_price_per_kgs,
383  vector<double>& total_feed_vet_kgs,
384  vector<double>& prop_N_in_feed_vets,
385  vector<double>& prop_P_in_feed_vets,
386  vector<double>& total_feed_vet_N_kgs,
387  vector<double>& total_feed_vet_P_kgs,
388  vector<double>& annual_discharge_N_kgs,
389  vector<double>& annual_discharge_P_kgs,
390  vector<double>& annual_discharge_C_kgs,
391  vector<double>& annual_discharge_heavymetals_kgs,
392  vector<double>& annual_discharge_medecine_kgs,
393  vector<double>& net_harvest_kg_per_sqkm_ys,
394  vector<double>& market_price_sold_fishs,
395  vector<double>& operating_cost_per_days,
396  vector<double>& annual_profits
397  );
398 bool fill_from_firms_specifications(istream& in,
399  vector<int> & firm_ids,
400  vector<string> & firm_names,
401  vector<int> & nb_vessels,
402  vector<double> & longs,
403  vector<double> & lats
404  );
405 
406 bool COMMONSSHARED_EXPORT fill_from_avai_nodes_with_pop (istream& in, map<int, double>& avai);
407 bool COMMONSSHARED_EXPORT fill_from_avai_szgroup_nodes_with_pop (istream& in, multimap<types::NodeId, double> &avai);
408 bool COMMONSSHARED_EXPORT fill_field_of_coeff_diffusion_this_pop(istream& in, multimap<types::NodeId, double> &coeffs);
409 bool COMMONSSHARED_EXPORT fill_from_oth_land (istream& in, map<types::NodeId, double> &oth_land);
410 bool COMMONSSHARED_EXPORT fill_from_overall_migration_fluxes (istream& in, multimap<int, double> &overall_migration_fluxes);
411 bool COMMONSSHARED_EXPORT fill_from_relative_stability(istream& in, map<string, double>& relative_stability);
412 bool COMMONSSHARED_EXPORT fill_from_nodes_in_polygons (istream& in, multimap<int, int>& nodes_in_polygons);
413 
414 bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_s_i(istream& in, multimap<string, int>& infos);
415 bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_s_d(istream& in, multimap<string, double>& infos);
416 
417 
418 template <typename K, typename V>
419 bool fill_multimap_from_specifications (istream& in, multimap<K, V>& infos)
420 {
421  std::string dummystring;
422  getline (in, dummystring); // eat the heading
423 
425  try {
426  return reader.importFromStream<std::tuple<K,V>>(in, " ", [&infos](std::tuple<K, V> v) {
427  infos.insert(std::make_pair(std::get<0>(v), std::get<1>(v)));
428  });
429  } catch (runtime_error &) {
430  return false;
431  }
432 }
433 
434 bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_i_s(istream& in, multimap<int, string>& infos);
435 bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_i_d(istream& in, multimap<int, double>& infos);
436 bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_i_i(istream& in, multimap<int, int>& infos);
437 bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_i(istream& in, map<int, int>& a_map);
438 bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_s(istream& in, map<int, string>& a_map);
439 bool COMMONSSHARED_EXPORT fill_map_from_specifications_s_d(istream& in, map<string, double>& a_map);
440 
441 template <typename DTYPE>
442 void fill_map_from_specifications (istream &in, map<int,DTYPE> &map) {
443  string line;
444  while(!getline(in, line).eof())
445  {
446  int key;
447  in >> key;
448  double val;
449  in >> val;
450  map.insert(make_pair(key,val));
451  }
452 }
453 
454 template <typename K, typename V>
455 std::vector<V> find_entries(const std::multimap<K,V> &infos, K val) {
456  auto upper = infos.upper_bound(val);
457  vector<V> result;
458 
459  for(auto pos= infos.lower_bound(val); pos!=upper; pos++) {
460  result.push_back(pos->second);
461  }
462 
463  return(result);
464 }
465 
466 vector<double> COMMONSSHARED_EXPORT find_entries_s_d (multimap<string, double>& infos, string str);
467 vector<int> COMMONSSHARED_EXPORT find_entries_s_i (multimap<string, int>& infos, string vid);
468 vector<double> COMMONSSHARED_EXPORT find_entries_i_d (const multimap<int, double> &infos, int intg);
469 vector<int> COMMONSSHARED_EXPORT find_entries_i_i (const multimap<int, int> &infos, int intg);
470 vector<string> COMMONSSHARED_EXPORT find_entries_i_s (multimap<int, string>& infos, int intg);
471 void COMMONSSHARED_EXPORT set_entries_d (multimap<int, double>& infos, int itr, vector<double> newval);
472 
473 template <typename T, size_t N> T* end(T (&pArray)[N]);
474 
475 vector<double> COMMONSSHARED_EXPORT scale_a_vector_to_1(vector<double> a_vector);
476 
477 bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_i(istream& in, map<int, int>& infos, string namefolderinput);
478 bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_s(istream& in, map<int, string>& infos, string namefolderinput);
479 bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_d(istream& in, map<int, double>& infos, string namefolderinput);
480 
481 // generator
482 //int my_rand(int a, int b)
483 //{
484 // return a+ rand() % (b-a+1);
485 //}
486 
487 double COMMONSSHARED_EXPORT decode_the_tree(string& tree, vector<string>& direction,
488  map<string, int>& external_states, map<string, int>& internal_states);
489 #endif
void COMMONSSHARED_EXPORT set_entries_d(multimap< int, double > &infos, int itr, vector< double > newval)
Definition: myutils.cpp:2088
vector< size_t > sort_indexes_ascending(const vector< T > &v)
Definition: myutils.h:75
bool COMMONSSHARED_EXPORT fill_from_DissolvedCarbon(istream &in, vector< double > &graph_point_DissolvedCarbon, int nrow)
Definition: myutils.cpp:673
bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_s(istream &in, map< int, string > &a_map)
Definition: myutils.cpp:1783
bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_i(istream &in, map< int, int > &a_map)
Definition: myutils.cpp:1763
empties_t
Definition: myutils.h:166
bool COMMONSSHARED_EXPORT fill_from_nodes_in_polygons(istream &in, multimap< int, int > &nodes_in_polygons)
Definition: myutils.cpp:1803
bool COMMONSSHARED_EXPORT fill_from_shippingdensity(istream &in, vector< double > &graph_point_shippingdensity, int nrow)
Definition: myutils.cpp:739
CGAL::Exact_predicates_inexact_constructions_kernel K
Definition: graphbuilder_shp.cpp:42
bool COMMONSSHARED_EXPORT fill_in_initial_tac(istream &in, vector< double > &initial_tac)
Definition: myutils.cpp:1102
vector< size_t > sort_indexes_descending(const vector< T > &v)
Definition: myutils.h:92
bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_s_d(istream &in, multimap< string, double > &infos)
Definition: myutils.cpp:1863
int weight_t
Definition: myutils.h:204
bool COMMONSSHARED_EXPORT fill_from_oth_land(istream &in, map< types::NodeId, double > &oth_land)
Definition: myutils.cpp:1723
types::NodeId::type vertex_t
Definition: myutils.h:203
string inputfolder
Definition: main.cpp:429
double COMMONSSHARED_EXPORT trapezoidal(double a, double b, vector< double > sel)
Definition: myutils.cpp:40
bool COMMONSSHARED_EXPORT fill_from_overall_migration_fluxes(istream &in, multimap< int, double > &overall_migration_fluxes)
Definition: myutils.cpp:1743
Definition: pathshop.h:12
Definition: myutils.h:206
T * end(T(&pArray)[N])
Definition: myutils.cpp:49
vector< int > COMMONSSHARED_EXPORT find_entries_i_i(const multimap< int, int > &infos, int intg)
Definition: myutils.cpp:2054
bool COMMONSSHARED_EXPORT fill_in_fbar_ages_min_max(istream &in, vector< double > &fbar_ages_min_max)
Definition: myutils.cpp:1126
bool COMMONSSHARED_EXPORT fill_from_bathymetry(istream &in, vector< double > &graph_point_bathymetry, int nrow)
Definition: myutils.cpp:706
bool COMMONSSHARED_EXPORT fill_from_coord(istream &in, vector< double > &graph_coord_x, vector< double > &graph_coord_y, vector< int > &graph_coord_harbour, int nrow)
Definition: myutils.cpp:324
bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_s_i(istream &in, multimap< string, int > &infos)
Definition: myutils.cpp:1825
vector< int > COMMONSSHARED_EXPORT find_entries_s_i(multimap< string, int > &infos, string vid)
Definition: myutils.cpp:2020
vector< string > COMMONSSHARED_EXPORT find_entries_i_s(multimap< int, string > &infos, int intg)
Definition: myutils.cpp:2071
string namefolderinput
Definition: main.cpp:427
void COMMONSSHARED_EXPORT closeSomeNodes(std::vector< int > &nodes_to_be_closed, adjacency_map_t &adjacency_map)
Definition: myutils.cpp:296
Definition: myutils.h:166
bool COMMONSSHARED_EXPORT fill_from_metier_specifications(istream &in, multimap< string, double > &infos)
Definition: myutils.cpp:1162
bool COMMONSSHARED_EXPORT fill_from_Phosphorus(istream &in, vector< double > &graph_point_Phosphorus, int nrow)
Definition: myutils.cpp:607
bool COMMONSSHARED_EXPORT fill_from_salinity(istream &in, vector< double > &graph_point_salinity, int nrow)
Definition: myutils.cpp:541
void fill_map_from_specifications(istream &in, map< int, DTYPE > &map)
Definition: myutils.h:442
Definition: pathshop.cpp:8
bool COMMONSSHARED_EXPORT fill_from_avai_nodes_with_pop(istream &in, map< int, double > &avai)
Definition: myutils.cpp:1671
std::vector< V > find_entries(const std::multimap< K, V > &infos, K val)
Definition: myutils.h:455
Definition: idtypes.h:52
vector< PathShop > pathshops
Definition: main.cpp:280
bool COMMONSSHARED_EXPORT fill_map_from_specifications_i_d(istream &in, map< int, double > &infos, string namefolderinput)
Definition: myutils.cpp:1944
bool COMMONSSHARED_EXPORT fill_in_percent_age_per_szgroup_matrix(istream &in, vector< vector< double > > &percent_age_per_szgroup_matrix)
Definition: myutils.cpp:905
bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_i_d(istream &in, multimap< int, double > &infos)
fill in the vessel attributes into a multimap <integer, double>. First line is an heading.
Definition: myutils.cpp:1844
bool COMMONSSHARED_EXPORT fill_from_ships_specifications(istream &in, vector< string > &names, vector< double > &imos, vector< double > &yearbuilds, vector< string > &flags, vector< string > &types, vector< double > &typecodes, vector< double > &loas, vector< double > &KWs, vector< double > &breadths, vector< double > &grosstonnages, vector< double > &nbunits, vector< double > &fueluse, vector< double > &NOxEmission_gperKWh, vector< double > &SOxEmission_percentpertotalfuelmass, vector< double > &GHGEmission, vector< double > &PMEmission, vector< double > &vmaxs, vector< double > &vcruises, vector< double > &lane_ids)
Definition: myutils.cpp:1330
adjacency_map_t adjacency_map
Definition: main.cpp:253
bool COMMONSSHARED_EXPORT fill_in_percent_szgroup_per_age_matrix(istream &in, vector< vector< double > > &percent_szgroup_per_age_matrix)
Definition: myutils.cpp:875
bool COMMONSSHARED_EXPORT fill_from_relative_stability(istream &in, map< string, double > &relative_stability)
Definition: myutils.cpp:1753
double simpson(double a, double b, int n, double S1, double S2)
Definition: myutils.h:60
std::list< vertex_t > COMMONSSHARED_EXPORT DijkstraGetShortestPathTo(vertex_t target, spp::sparse_hash_map< vertex_t, vertex_t > &previous)
Definition: myutils.cpp:166
bool COMMONSSHARED_EXPORT fill_map_from_specifications_s_d(istream &in, map< string, double > &a_map)
Definition: myutils.cpp:1986
Container & split(Container &result, const typename Container::value_type &s, const typename Container::value_type &delimiters, splitX::empties_t empties=splitX::empties_ok)
Definition: myutils.h:170
multimap< int, int >::const_iterator COMMONSSHARED_EXPORT find_pair(const multimap< int, int > &map, const pair< int, int > &pair)
Definition: idtypes.h:9
bool COMMONSSHARED_EXPORT fill_from_wind(istream &in, vector< double > &graph_point_wind, int nrow)
Definition: myutils.cpp:477
vector< double > COMMONSSHARED_EXPORT scale_a_vector_to_1(vector< double > a_vector)
Definition: myutils.cpp:2151
Definition: myutils.h:166
bool COMMONSSHARED_EXPORT fill_in_param_sr(istream &in, vector< double > &param_sr)
Definition: myutils.cpp:1064
double COMMONSSHARED_EXPORT decode_the_tree(string &tree, vector< string > &direction, map< string, int > &external_states, map< string, int > &internal_states)
Definition: myutils.cpp:2184
std::map< vertex_t, std::list< edge > > adjacency_map_t
Definition: myutils.h:214
void remove_dups(vector< T > &seq)
Definition: myutils.h:112
bool COMMONSSHARED_EXPORT fill_in_species_interactions_mortality_proportion_matrix(istream &in, vector< vector< double > > &species_interactions_mortality_proportion_matrix)
Definition: myutils.cpp:1000
vertex_t target
Definition: myutils.h:208
bool COMMONSSHARED_EXPORT fill_from_code_marine_landscape(istream &in, vector< int > &graph_point_code_landscape, int nrow)
Definition: myutils.cpp:445
bool COMMONSSHARED_EXPORT fill_from_benthos_number(istream &in, vector< double > &graph_point_benthos_number, int nrow)
Definition: myutils.cpp:838
bool COMMONSSHARED_EXPORT fill_field_of_coeff_diffusion_this_pop(istream &in, multimap< types::NodeId, double > &coeffs)
Definition: myutils.cpp:1701
uint16_t type
Definition: idtypes.h:16
weight_t weight
Definition: myutils.h:209
bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_i_s(istream &in, multimap< int, string > &infos)
Definition: myutils.cpp:1883
bool COMMONSSHARED_EXPORT fill_from_vessels_economic_specifications(istream &in, vector< double > &this_vessel_nb_crews, vector< double > &annual_other_incomes, vector< double > &landing_costs_percents, vector< double > &crewshare_and_unpaid_labour_costs_percents, vector< double > &other_variable_costs_per_unit_efforts, vector< double > &annual_insurance_costs_per_crews, vector< double > &standard_labour_hour_opportunity_costss, vector< double > &standard_annual_full_time_employement_hourss, vector< double > &other_annual_fixed_costss, vector< double > &vessel_values, vector< double > &annual_depreciation_rates, vector< double > &opportunity_interest_rates, vector< double > &annual_discount_rates)
Definition: myutils.cpp:1267
bool COMMONSSHARED_EXPORT fill_from_avai_szgroup_nodes_with_pop(istream &in, multimap< types::NodeId, double > &avai)
Definition: myutils.cpp:1692
vector< types::NodeId > relevant_nodes
Definition: main.cpp:255
multimap< int, int > nodes_in_polygons
Definition: main.cpp:256
bool COMMONSSHARED_EXPORT fill_from_benthos_biomass(istream &in, vector< double > &graph_point_benthos_biomass, int nrow)
Definition: myutils.cpp:806
void COMMONSSHARED_EXPORT DijkstraComputePaths(vertex_t source, adjacency_map_t &adjacency_map, spp::sparse_hash_map< vertex_t, weight_t > &min_distance, spp::sparse_hash_map< vertex_t, vertex_t > &previous, std::vector< types::NodeId > relevant_nodes)
Definition: myutils.cpp:96
bool COMMONSSHARED_EXPORT fill_in_selectivity_per_stock(istream &in, vector< vector< double > > &growth_transition)
Definition: myutils.cpp:1033
bool COMMONSSHARED_EXPORT fill_from_sst(istream &in, vector< double > &graph_point_sst, int nrow)
Definition: myutils.cpp:509
vector< double > COMMONSSHARED_EXPORT find_entries_s_d(multimap< string, double > &infos, string str)
Definition: myutils.cpp:2003
types::NodeId::type vertex_t
Definition: AStarShortestPathFinder.h:17
bool fill_from_firms_specifications(istream &in, vector< int > &firm_ids, vector< string > &firm_names, vector< int > &nb_vessels, vector< double > &longs, vector< double > &lats)
Definition: myutils.cpp:1420
bool COMMONSSHARED_EXPORT fill_from_vessels_specifications(istream &in, vector< string > &names, vector< int > &vid_is_actives, vector< int > &vid_is_part_of_ref_fleets, vector< double > &speeds, vector< double > &fuelcons, vector< double > &lengths, vector< double > &vKWs, vector< double > &carrycapacities, vector< double > &tankcapacities, vector< double > &nbfpingspertrips, vector< double > &resttime_par1s, vector< double > &resttime_par2s, vector< double > &av_trip_duration, vector< double > &mult_fuelcons_when_steaming, vector< double > &mult_fuelcons_when_fishing, vector< double > &mult_fuelcons_when_returning, vector< double > &mult_fuelcons_when_inactive, vector< int > &firm_ids, vector< VesselCalendar > &calendars)
Definition: myutils.cpp:1183
vector< double > COMMONSSHARED_EXPORT find_entries_i_d(const multimap< int, double > &infos, int intg)
Definition: myutils.cpp:2037
bool COMMONSSHARED_EXPORT insert_if_not_present(multimap< int, int > &map, const pair< int, int > &pair)
bool COMMONSSHARED_EXPORT fill_multimap_from_specifications_i_i(istream &in, multimap< int, int > &infos)
Definition: myutils.cpp:1903
string namesimu
Definition: main.cpp:430
Definition: MultifieldReader.h:22
vector< double > COMMONSSHARED_EXPORT compute_distance_fgrounds(const vector< types::NodeId > &relevant_nodes, const std::vector< PathShop > &pathshops, types::NodeId from, vector< types::NodeId > grounds)
Definition: myutils.cpp:2109
bool COMMONSSHARED_EXPORT fill_from_code_area(istream &in, vector< int > &graph_point_code_area, int nrow)
Definition: myutils.cpp:410
Definition: myutils.h:164
bool COMMONSSHARED_EXPORT fill_in_preferences_for_species_matrix(istream &in, vector< vector< double > > &preferences_for_species_matrix)
Definition: myutils.cpp:967
edge(vertex_t arg_target, weight_t arg_weight)
Definition: myutils.h:210
void COMMONSSHARED_EXPORT SimplifyThePreviousMap(int source, spp::sparse_hash_map< vertex_t, vertex_t > &previous, std::vector< types::NodeId > &relevant_nodes, spp::sparse_hash_map< vertex_t, weight_t > &min_distance, string namesimu, string a_graph_name, string inputfolder)
Definition: myutils.cpp:206
bool fill_multimap_from_specifications(istream &in, multimap< K, V > &infos)
Definition: myutils.h:419
bool COMMONSSHARED_EXPORT fill_from_Nitrogen(istream &in, vector< double > &graph_point_Nitrogen, int nrow)
Definition: myutils.cpp:574
bool COMMONSSHARED_EXPORT fill_from_Oxygen(istream &in, vector< double > &graph_point_Oxygen, int nrow)
Definition: myutils.cpp:640
bool COMMONSSHARED_EXPORT fill_from_graph(istream &in, vector< int > &graph_idx_dep, vector< int > &graph_idx_arr, vector< int > &graph_dist_km, int nrow)
Definition: myutils.cpp:369
bool COMMONSSHARED_EXPORT fill_in_growth_transition(istream &in, vector< vector< double > > &growth_transition)
Definition: myutils.cpp:935
bool COMMONSSHARED_EXPORT fill_from_fishfarms_specifications(istream &in, vector< int > &fishfarms_ids, vector< string > &fishfarms_names, vector< int > &idx_nodes, vector< int > &is_actives, vector< double > &sizes, vector< double > &longs, vector< double > &lats, vector< double > &mean_SSTs, vector< double > &mean_salinities, vector< double > &mean_windspeeds, vector< double > &mean_currentspeeds, vector< double > &max_depths, vector< double > &diss_O2_mg_per_ls, vector< double > &Linf_mms, vector< double > &K_ys, vector< double > &t0_ys, vector< double > &fulton_condition_factors, vector< string > &meanw_growth_model_types, vector< int > &start_day_growings, vector< int > &end_day_harvests, vector< int > &nbyears_for_growths, vector< int > &nb_days_fallowing_periods, vector< int > &nb_fish_at_starts, vector< double > &meanw_at_starts, vector< double > &price_per_kg_at_starts, vector< double > &target_meanw_at_harvests, vector< int > &nb_fish_at_harvests, vector< double > &meanw_at_harvests, vector< double > &prop_harvest_kg_solds, vector< double > &kg_eggs_per_kgs, vector< double > &price_eggs_per_kgs, vector< double > &N_in_fish_kg_3pers, vector< double > &P_in_fish_kg_0_5pers, vector< string > &feed_types, vector< double > &feed_price_per_kgs, vector< double > &total_feed_kg, vector< double > &prop_N_in_feeds, vector< double > &prop_P_in_feeds, vector< double > &total_feed_N_kgs, vector< double > &total_feed_P_kgs, vector< string > &feed_type_vets, vector< double > &feed_vet_price_per_kgs, vector< double > &total_feed_vet_kgs, vector< double > &prop_N_in_feed_vets, vector< double > &prop_P_in_feed_vets, vector< double > &total_feed_vet_N_kgs, vector< double > &total_feed_vet_P_kgs, vector< double > &annual_discharge_N_kgs, vector< double > &annual_discharge_P_kgs, vector< double > &annual_discharge_C_kgs, vector< double > &annual_discharge_heavymetals_kgs, vector< double > &annual_discharge_medecine_kgs, vector< double > &net_harvest_kg_per_sqkm_ys, vector< double > &market_price_sold_fishs, vector< double > &operating_cost_per_days, vector< double > &annual_profits)
Definition: myutils.cpp:1467
double COMMONSSHARED_EXPORT myintegrand(double x, double S1, double S2)
Definition: myutils.cpp:35
bool COMMONSSHARED_EXPORT fill_from_siltfraction(istream &in, vector< double > &graph_point_siltfraction, int nrow)
Definition: myutils.cpp:771
#define COMMONSSHARED_EXPORT
Definition: commons_global.h:23