1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * geqo_random.h |
4 | * random number generator |
5 | * |
6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
7 | * Portions Copyright (c) 1994, Regents of the University of California |
8 | * |
9 | * src/include/optimizer/geqo_random.h |
10 | * |
11 | *------------------------------------------------------------------------- |
12 | */ |
13 | |
14 | /* contributed by: |
15 | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= |
16 | * Martin Utesch * Institute of Automatic Control * |
17 | = = University of Mining and Technology = |
18 | * utesch@aut.tu-freiberg.de * Freiberg, Germany * |
19 | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= |
20 | */ |
21 | |
22 | /* -- parts of this are adapted from D. Whitley's Genitor algorithm -- */ |
23 | |
24 | #ifndef GEQO_RANDOM_H |
25 | #define GEQO_RANDOM_H |
26 | |
27 | #include <math.h> |
28 | |
29 | #include "optimizer/geqo.h" |
30 | |
31 | |
32 | extern void geqo_set_seed(PlannerInfo *root, double seed); |
33 | |
34 | /* geqo_rand returns a random float value between 0 and 1 inclusive */ |
35 | extern double geqo_rand(PlannerInfo *root); |
36 | |
37 | /* geqo_randint returns integer value between lower and upper inclusive */ |
38 | #define geqo_randint(root, upper, lower) \ |
39 | ( (int) floor( geqo_rand(root)*(((upper)-(lower))+0.999999) ) + (lower) ) |
40 | |
41 | #endif /* GEQO_RANDOM_H */ |
42 | |