forked from pholme/tsir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsir.h
56 lines (45 loc) · 1.6 KB
/
tsir.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// code for temporal network SIR by Petter Holme (2018)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#define NAVG 1000000 // number of runs for averages
#define NONE (UINT_MAX - 1)
#define END UINT_MAX // NONE and END are used in various ways, the only purpose of NONE < END is for the S(x) macro
#define S(x) (n[(x)].heap < END) // is x susceptible?
// auxiliary macro
#define SQ(x) ((x) * (x))
typedef struct GLOBALS {
// INPUT PARAMETERS
double a; // -1/nu where nu = recovery rate (input nu in units of duration, but internally in units of time steps)
unsigned short rnd2inx[0x10000]; // mapping 16-bit random number to index
// NETWORK SPECS
unsigned int n, dur;
// OTHER GLOBALS
unsigned int nheap, *heap;
// FOR RND
uint64_t state;
// OUTBREAK STATS
unsigned int ns, *s;
} GLOBALS;
typedef struct NODE {
unsigned int deg, *nb; // degree, neighbors
unsigned int *nc, **t; // ordered number of / list of contact times for bisection serach
unsigned int heap, time; // time is 1st the time of infection (for sorting the heap), then the time of recovery (to check if the node is I or R)
} NODE;
// heap.c
extern void up_heap (unsigned int);
extern void del_root ();
// misc.c
extern void read_data ();
extern unsigned int exptime ();
// pcg_rnd.c
extern uint16_t pcg_16 ();
extern uint32_t pcg_32 ();
extern uint32_t pcg_32_bounded (uint32_t);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -