Skip to main content
. 2023 Jul 14;25(7):1066. doi: 10.3390/e25071066
Algorithm 5 SWDM
  • Input:

    Stream X, distance metric d(·,·), window size wZ+, parameter ε(0,1), solution size kZ+

  • Output:

    A set SW with |S|=k

  • 1:

    Λ,U={dmin(1ε)j:jZ0+(1ε)jdmindmax}

  • 2:

    for allλΛ and μU do

  • 3:

        Initialize Aλ,μ,Aλ,μ= and Bλ,μ,Bλ,μ=

  • 4:

    for all xX do

  • 5:

        for all λΛ do

  • 6:

            for all μU do

  • 7:

               if |Bλ,μ|<k and d(x,Bλ,μ)μ then

  • 8:

                   Bλ,μBλ,μ{x}, Bλ,μ[x]x

  • 9:

               else if d(x,Bλ,μ)<μ then

  • 10:

                   yarg minyBλ,μd(x,y), Bλ,μ[y]x

  • 11:

               if Aλ,μ and d(x,Aλ,μ)<μ then

  • 12:

                   yarg minyAλ,μd(x,y), Aλ,μ[y]x

  • 13:

            if maxμU:|Bλ,μ|=kdiv(Bλ,μ)>λ then

  • 14:

               Remove x from each Bλ,μ,Bλ,μ

  • 15:

               Aλ,μ,Aλ,μBλ,μ,Bλ,μ for each μU

  • 16:

               Bλ,μ,Bλ,μ{x} for each μU

  • Post-processing

  • 17:

    W{xX:max{1,|X|w+1}t(x)|X|}

  • 18:

    for allλΛ and μU do

  • 19:

        if Aλ,μW then

  • 20:

            Sλ,μALG(k,Aλ,μBλ,μ)

  • 21:

        else if Bλ,μW then

  • 22:

            Sλ,μALG(k,(WAλ,μ)Bλ,μ)

  • 23:

    return Sarg maxλΛ,μU:|Sλ,μ|=kdiv(Sλ,μ)