The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
topology.h
1 /*
2  * topology.h
3  *
4  * Created on: 02 lug 2018
5  * Author: andrea
6  */
7 
8 #ifndef __TOPOLOGY_H_
9 #define __TOPOLOGY_H_
10 
11 #include <lib/jsmn_helper.h>
12 #include <datatypes/bitmap.h>
13 
14 typedef struct _topology_t topology_t;
15 
17 extern struct _topology_global_t{
18  unsigned chkp_size;
19  unsigned directions;
20  unsigned edge;
21  unsigned lp_cnt;
23 } topology_global;
24 
25 // this initializes the topology environment
26 void topology_init(void);
27 
28 //used internally (also in abm_layer module) to schedule our reserved events TODO: move in a more system-like module
29 void UncheckedScheduleNewEvent(unsigned int gid_receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size);
30 
31 // if the model is using a topology this gets called instead of the plain ProcessEvent
32 void ProcessEventTopology(void);
33 
34 // STUFF FOR INTERNAL USE (in between topology sources)
35 unsigned size_checkpoint_probabilities (void);
36 unsigned size_checkpoint_costs (void);
37 unsigned size_checkpoint_obstacles (void);
38 
39 void * load_topology_file_probabilities(c_jsmntok_t *root_token, const char *json_base);
40 void * load_topology_file_costs (c_jsmntok_t *root_token, const char *json_base);
41 void * load_topology_file_obstacles (c_jsmntok_t *root_token, const char *json_base);
42 
43 topology_t * topology_probabilities_init (unsigned this_region_id, void *topology_data);
44 topology_t * topology_costs_init (unsigned this_region_id, void *topology_data);
45 topology_t * topology_obstacles_init (unsigned this_region_id, void *topology_data);
46 
47 double get_value_topology_probabilities(unsigned from, unsigned to);
48 double get_value_topology_costs (unsigned from, unsigned to);
49 double get_value_topology_obstacles (unsigned from, unsigned to);
50 
51 void set_value_topology_probabilities(unsigned from, unsigned to, double value);
52 void set_value_topology_costs (unsigned from, unsigned to, double value);
53 void set_value_topology_obstacles (unsigned from, unsigned to, double value);
54 
55 bool is_reachable_probabilities (unsigned to);
56 bool is_reachable_costs (unsigned to);
57 bool is_reachable_obstacles (unsigned to);
58 
59 void update_topology_probabilities (void);
60 void update_topology_costs (void);
61 void update_topology_obstacles (void);
62 
63 unsigned int find_receiver_probabilities (void);
64 unsigned int find_receiver_obstacles (void);
65 
66 double compute_min_tour_costs (unsigned int source, unsigned int dest, unsigned int result[RegionsCount()]);
67 double compute_min_tour_obstacles (unsigned int source, unsigned int dest, unsigned int result[RegionsCount()]);
68 
69 unsigned int find_receiver_toward_costs (unsigned int to);
70 unsigned int find_receiver_toward_obstacles (unsigned int to);
71 
72 
73 unsigned int get_raw_receiver (unsigned int from, direction_t direction);
74 // the dijkstra algorithm returns a spanning tree rooted at the source with information about the parent of
75 // each node: this method is needed to build the complete path of a node given such an array of previous hops
76 // it's here because it's needed by both COSTS and BINARY
77 unsigned build_path(unsigned lp_cnt, unsigned result[lp_cnt], const unsigned int previous[lp_cnt], unsigned source, unsigned dest);
78 
79 #endif /* __TOPOLOGY_H_ */
Definition: jsmn.h:43
enum _topology_geometry_t geometry
Definition: topology.h:22
unsigned chkp_size
Definition: topology.h:18
unsigned lp_cnt
Definition: topology.h:21
_topology_geometry_t
Definition: ROOT-Sim.h:88
double simtime_t
This defines the type with whom timestamps are represented.
Definition: ROOT-Sim.h:55
enum _direction_t direction_t
unsigned edge
Definition: topology.h:20
unsigned directions
Definition: topology.h:19
Bitmap data type.
this is used to store the common characteristics of the topology
Definition: topology.h:17
the customised struct for TOPOLOGY_OBSTACLES representation
Definition: costs.c:22