Skip to content

Commit c5e09f2

Browse files
committed
BI Q20: Add remark on determinism
1 parent 7d3e1a7 commit c5e09f2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

query-specifications/bi-read-19.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ description: |
99
The shortest path is computed on the *Person-knows-Person* graph based on the number of interactions,
1010
i.e. the number of direct reply *Comments* from one *Person* to *Messages* by the other *Person*.
1111
Only *knows* edges with at least one interaction between their endpoint *Persons* are considered.
12-
The weight of a *knows* edge is defined as $\max\lfloor 40 - \sqrt{\textit{numInteractions}}, 1 \rfloor$.
12+
The weight of a *knows* edge is defined as:
13+
$$\max(\mathrm{round}( 40 - \sqrt{\textit{numInteractions}} ), 1)$$
1314
1415
**Note:** Interactions are counted both ways, e.g. if Alice *knows* Bob, Alice writes 2 reply *Comments* to Bob's *Messages*
1516
and Bob writes 3 reply *Comments* to Alice's *Messages*, their total number of interactions is 5 and the weight of the knows edge is 0.2.
16-
17-
Due to the inaccuracies of floating point number representation when performing the square root, the comparisons to determine same length paths should be performed with a tolerance (details TBD).
17+
18+
**Remark:** Determinism is ensured by using square root followed by rounding.
19+
For all integers between 1 and 100000, the square root's fractional part is more than 10e-5 from 0.5, where the rounding could be non-determinstic based on floating point inaccuracies. As 10e-5 is significantly larger than the machine epsilon of IEEE 754 floats (both 32- and 64-bit), the floating point inaccuracies have no chance to affect the derived integer edge weights.
1820
parameters:
1921
- name: city1Id
2022
type: ID
@@ -42,3 +44,9 @@ choke_points: [3.3, 7.6, 7.7, 8.4, 8.6]
4244
relevance: |
4345
To find the weighted shortest paths efficiently, the system can use e.g. a bidirectional Dijkstra algorithm.
4446
As the edge weights do not depend on any parameter, systems can pre-compute them (if they do not interleave reads and writes).
47+
# import math
48+
# for i in range(1, 100000):
49+
# sq = math.sqrt(i)
50+
# diff = abs(abs(sq - math.floor(sq)) - 0.5)
51+
# if diff < 0.00001:
52+
# print(f"{i}: {diff:.8f}")

0 commit comments

Comments
 (0)