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

    Stream X=i=1mXi, distance metric d(·,·), parameter ε(0,1), window size wZ+, size constraints k1,,km (k=i=1mki)

  • Output:

    A set SW s.t. |SXi|=ki for i[m]

  • Stream processing

  • 1:

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

  • 2:

    for all λΛ,μU do

  • 3:

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

  • 4:

        for all i[m] do

  • 5:

            Initialize Aλ,μ(i),Aλ,μ(i),Bλ,μ(i),Bλ,μ(i)=

  • 6:

    for all xX do

  • 7:

        Run Lines 5–16 of Algorithm 5 to update Aλ,μ, Aλ,μ, Bλ,μ, and Bλ,μ w.r.t. x

  • 8:

        if m=2c(x)=i and ‘SWFDM1’ is used then

  • 9:

            Run Lines 5–16 of Algorithm 5 to update to update Aλ,μ(i), Aλ,μ(i), Bλ,μ(i), and Bλ,μ(i) w.r.t. x under size constraint ki

  • 10:

        else if c(x)=i and ‘SWFDM2’ is used then

  • 11:

            Run Lines 5–16 of Algorithm 5 to update to update Aλ,μ(i), Aλ,μ(i), Bλ,μ(i), and Bλ,μ(i) w.r.t. x under size constraint k

  • Post-processing

  • 12:

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

  • 13:

    for allλΛ and μU do

  • 14:

        if Aλ,μW then

  • 15:

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

  • 16:

        else if Bλ,μW then

  • 17:

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

  • 18:

        if m=2 and ‘SWFDM1’ is used then

  • 19:

            if |Sλ,μ|=k|Sλ,μXi|<ki then

  • 20:

               if Aλ,μ(i)W then

  • 21:

                   Sλ,μ(i)ALG(ki,Aλ,μ(i)Bλ,μ(i))

  • 22:

               else if Bλ,μ(i)W then

  • 23:

                   Sλ,μ(i)ALG(ki,(WAλ,μ(i))Bλ,μ(i))

  • 24:

               Run Lines 10–15 of Algorithm 2 using Sλ,μ and Sλ,μ(i) as input to find a fair solution Sλ,μ

  • 25:

        else ifSWFDM2’ is used then

  • 26:

            for i[m] do

  • 17:

               if Aλ,μ(i)W then

  • 28:

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

  • 29:

               else if Bλ,μ(i)W then

  • 30:

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

  • 31:

            Run Lines 10–17 (with d(x,y)<ξμm+1 in Line 13) of Algorithm 3 using Sλ,μ and Sall=i=1mSλ,μ(i)Sλ,μ as input to find a fair solution Sλ,μ

  • 32:

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