• Create Account

# Algorithm Rewrite Bug?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

### #1Eralp  Members   -  Reputation: 140

Like
0Likes
Like

Posted 09 January 2013 - 10:41 AM

I am reading the paper "An enhanced recursive frequency splitting broadcasting algorithm for near video-on-demand services" written by Yu-Wei Chen.

There is something which confused me. Here is the algorithm explained as in the paper. And following is the algorithm I wrote in Python. The thing is my algorithm outputs different integers than it is given in the paper as a table. I highly doubt that there is an error or bug in a scientific paper but I can't seem to find the reason. I wanted to get a second opinion before contacting the author.

import math

c = 2
k = 3

subChannelCount = int(math.floor(math.sqrt(c)))
POOL = []

class SlotSequence:
ChannelNumber = 0
p = 0
q = 0

for i in range(k):
for subChannel in range(subChannelCount):
SS = SlotSequence()
SS.ChannelNumber = i
SS.p = subChannel
SS.q = subChannelCount
POOL.append(SS)

j = c

while(len(POOL) > 0):
minMod = 1000000000
minModIndex = -1
for idx,SS in enumerate(POOL):
if SS.q <= j:
if (j % SS.q) < minMod:
minMod = j % SS.q
minModIndex = idx

SS = POOL.pop(minModIndex)
alpha = int(math.floor(j/SS.q))

for x in range(1,alpha):
splitSS = SlotSequence()
splitSS.ChannelNumber = SS.ChannelNumber
splitSS.p = SS.p+x*SS.q
splitSS.q = alpha*SS.q
POOL.append(splitSS)
j = j + 1

print j-c 

Edited by Eralp, 09 January 2013 - 10:42 AM.