下面是一個算法的糧食。它當然不會被刷新或測試,並且可能不完整。我只是把它放在這裏作爲一個可能的出發點。
看來最具挑戰性的問題是運行算法在數十億行所需的時間,通過內存限制可能緊隨其後。
我也相信參與解決這一問題的根本任務,以「比較一組號碼與另一個」單操作可定位一組共享。
因此,我可能會建議以下(粗糙)的辦法,以應對既時間,和內存:
(1) Consolidate multiple sets into a single, larger set.
即,連續服用100套(在你的榜樣,23, 67, 34, 23, 54
, 23, 54
,78, 96, 23
,並將下面的97套),並簡單地一起將它們合併成一個單一的組(忽略重複)。
(2) Give each *consolidated* set from (1) a label (or index),
and then map this set (by its label) to the original sets that compose it.
這樣,你就能檢索(查找)原單獨設置23, 67, 34, 23, 54
等
(3) The data is now denormalized - there are a much smaller number of sets, and each set is much larger.
現在,算法移動到一個新的階段。
(4) Develop an algorithm to look for matching sequences between any two of these larger sets.
會有很多誤報;但是,希望數據的性質是,誤報不會「毀掉」這種方法所獲得的效率。
我不提供一個算法來在這裏執行2個獨立的集合之間的匹配;我假設你可以自己想出一個(對這兩套進行排序等)。
(5) For every possible matching sequence found in (4), iterate through the individual sets that compose
the two larger sets being compared, weeding out false positives.
我懷疑上述步驟可以顯着優化,但這是基本思路。
此時,您將擁有構成兩個較大集合的所有原始集合之間的所有匹配序列進行比較。
(6) Execute steps (4) and (5) for every pair of large sets constructed in (2).
現在,您將擁有所有匹配的序列 - 帶有重複項。
(7) Remove duplicates from the set of matching sequences.
只是一個想法。
我認爲通常解決這個問題*(即對序列大小,行數,可用內存或執行分析所需的時間沒有限制)可能沒有用處。問題可能沒有*通用*解決方案,效率高(我不確定)。這可能是一個例子,它可以爲你提供更廣泛的內容來解決問題*的最相關的子集,從而犧牲理想的解決方案,但是總能讓人滿意。 –
順序關聯分析 –