Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- import random
- import sys
- import os
- #dir = sys.argv[]
- explist = [(5,),(10,),(20,),(30,),(60,),(120,),(180,), (240,), (300,), (600,), (1200,), (650,), (965,), (656,), (730,), (67,), (242,), (316,), (478,), (429,), (337,)]
- options = [(3,5),(5,15), (3,30), (60,180), (180,300), (3,300)]#[(3,5), (5,15), (3,30), (60,180), (180,300), (3,300)]
- permopts = [0.1,0.2,0.3,0.4,0.5]
- #desc = 'singleint_3-5_noise_50_perm'+'/'
- #os.makedirs(os.getcwd()+"/"+desc)
- for zed in explist:
- for opt in options:
- for popt in permopts:
- #desc = 'singleint_'+str(opt[0])+'-'+str(opt[1])+'_noise_'+'no_perm/'
- desc = 'singleint_'+str(opt[0])+'-'+str(opt[1])+'_noise_'+str(float(popt)*100)+'_perm/'
- try:
- os.makedirs(os.getcwd()+"/"+desc)
- except:
- pass;
- ## Parameters
- intervals = zed #(120)
- length = 10800
- number_of_lists = 1000
- random1 = opt[0]
- random2 = opt[1]
- perm = popt
- ## Create interval list
- def Create_Intervals(intervals, length):
- global intlist
- intlist =[]
- for interval in intervals:
- intl = [interval]
- while intl[-1] < length:
- intl.append(intl[-1]+interval)
- intlist.extend(intl)
- #print intlist
- Create_Intervals(intervals, length)
- def Add_Permutation(no_of_perms,perm):
- global intlist
- distorted = random.sample(intlist, no_of_perms)
- perm_list = range(-perm,perm+1)
- perm_list.remove(0)
- for n, i in enumerate(intlist):
- for x in distorted:
- if i == x:
- intlist[n] = x+int(random.sample(perm_list,1)[0])
- #print intlist[n]
- Add_Permutation(int(len(intlist)*perm), 1) ## Using percentage of intlist
- def Create_Lists(number_of_lists, length, random1, random2 ):
- global intlist
- global dictt
- dictt = {}
- for e in range(0,number_of_lists):
- a = 0
- while a < length:
- #for x in range(0,int(50/3)):
- r = randint(random1,random2)
- a+=r
- if e in dictt:
- dictt[e].append(a)
- else:
- dictt[e] = [a]
- #print dictt[e]
- #print intlist
- #for x in intlist:
- #if x not in dictt[e]:
- #print x, dictt[e]
- #dictt[e].append(x)
- #dictt[e].sort()
- Create_Lists(number_of_lists, length, random1, random2)
- ##join intervals and random
- def intervalsandrand():
- global dictt
- for n in intlist:
- for k,v in dictt.items():
- if n not in v:
- dictt[k].append(n)
- dictt[k].sort()
- intervalsandrand()
- ##only intervals
- def onlyintervals():
- global dictt
- dictt = {}
- for e in range(0,number_of_lists):
- for n in intlist:
- if e in dictt:
- dictt[e].append(n)
- else:
- dictt[e] = [n]
- dictt[e].sort()
- #onlyintervals()
- ##Write to file
- for k,v in dictt.items():
- for i in v:
- f = open(os.getcwd()+"/"+desc+str(intervals)+","+str(length)+","+str(k)+","+str(random1)+","+str(random2), "a+")
- f.write(str(i)+",")
- f.close()
- #print i,",",
- #print str(i)+',',
- #print ""
- #for x in dictt[e]:
- #print str(x)+',',
- #print dictt
- '''
- 1000 lists for each scenario
- Generate 3 hours of traffic - 10,800
- Scenarios
- - Done Repeat regular intervals - 5, 10, 20, 30, 60, 120, 180, 240, 300, 600, 1200, 650, 965, 656, 730, 67, 242, 316, 478, 429, 337
- Repeat with multiple intervals
- 2 intervals
- 1. 180,1200
- 2. 965, 730
- 3. 10, 30
- 4. 965, 5
- 5. 60, 120
- 6. 242, 180
- 7. 478, 67
- 8. 1200, 30
- 9. 30, 300
- 10. 316, 300
- 3 intervals
- 1. 5, 20, 600
- 2. 656, 240, 67
- 3. 337, 300, 240
- 4. 10, 600, 240
- 5. 429, 600, 730
- 6. 478, 60, 650
- 7. 67, 478, 1200
- 8. 965, 20, 67
- 9. 67, 300, 240
- 10. 242, 20, 316
- 4 intervals
- 1. 1200, 120, 730, 20
- 2. 1200, 965, 300, 30
- 3. 30, 600, 67, 730
- 4. 60, 429, 67, 337
- 5. 67, 5, 730, 600
- 6. 5, 478, 965, 656
- 7. 300, 650, 120, 20
- 8. 20, 337, 10, 67
- 9. 965, 242, 337, 67
- 10. 337, 20, 120, 300
- 5 intervals
- 1. 30, 5, 600, 180, 120
- 2. 120, 478, 600, 60, 730
- 3. 120, 20, 300, 180, 10
- 4. 656, 5, 10, 180, 30
- 5. 300, 730, 650, 20, 180
- 6. 5, 656, 965, 300, 1200
- 7. 10, 600, 429, 60, 300
- 8. 67, 300, 337, 650, 5
- 9. 180, 478, 337, 120, 965
- 10. 10, 478, 656, 316, 730
- 10 intervals
- 180, 650, 656, 300, 67, 1200, 242, 5, 730, 10
- 316, 20, 650, 1200, 67, 120, 5, 300, 965, 240
- 10, 240, 67, 429, 120, 300, 30, 5, 316, 965
- 20, 650, 10, 337, 60, 429, 242, 300, 120, 5
- 429, 337, 180, 60, 240, 5, 650, 316, 242, 120
- 30, 10, 180, 316, 650, 300, 600, 656, 337, 120
- 60, 120, 20, 730, 656, 429, 10, 600, 650, 478
- 730, 10, 67, 650, 478, 300, 1200, 30, 316, 240
- 337, 650, 240, 1200, 180, 300, 20, 730, 60, 30
- 60, 10, 240, 730, 5, 316, 337, 478, 67, 600
- 20 intervals
- 5, 600, 20, 120, 650, 656, 965, 478, 30, 429, 10, 60, 337, 730, 1200, 180, 300, 67, 316, 240
- 429, 730, 67, 180, 20, 30, 60, 1200, 316, 337, 656, 478, 5, 650, 600, 242, 965, 10, 120, 240
- 965, 5, 1200, 429, 600, 650, 60, 478, 337, 180, 30, 242, 300, 20, 67, 10, 656, 730, 120, 316
- 656, 478, 300, 1200, 730, 60, 316, 242, 20, 180, 429, 5, 240, 120, 10, 650, 600, 30, 337, 67
- 337, 478, 300, 1200, 965, 30, 20, 10, 650, 600, 5, 656, 242, 316, 67, 120, 730, 429, 60, 240
- 600, 965, 337, 120, 429, 316, 300, 5, 10, 1200, 730, 240, 20, 478, 180, 242, 656, 60, 67, 30
- 650, 316, 300, 429, 656, 67, 337, 5, 1200, 20, 180, 240, 730, 600, 242, 30, 60, 10, 965, 478
- 650, 242, 965, 337, 429, 240, 60, 316, 180, 300, 5, 600, 478, 656, 730, 120, 20, 30, 10, 1200
- 300, 5, 120, 600, 337, 240, 10, 20, 656, 965, 180, 730, 67, 650, 60, 429, 478, 30, 1200, 316
- 337, 1200, 600, 656, 429, 965, 30, 242, 300, 10, 316, 478, 730, 60, 240, 20, 67, 650, 180, 5
- 1st set - regular intervals without noise-
- 2nd set - regular intervals with noise spaced between 3 and 5 seconds
- 3rd set - regular intervals with noise spaced between 5 and 15 seconds
- 4th set - regular intervals with noise spaced between 3 and 30 seconds
- 5th set - regular intervals with noise spaced between 1 and 3 minutes
- 6th set - regular intervals with noise spaced between 3 and 5 minutes
- 7th set - regular intervals with noise spaced between .3 and 5 minutes
- random intervals
- - Repeat with multiple intervals
- Add permutations
- 1. Mild -Not frequent - (Distort 10% of the traffic with +/- 1)
- 20%
- 2. Mild - Frequent - (Distort 30% of the traffic with +/- 1)
- 2. Frequent distortions- 40 %
- 3. Aggressive distortions - 50 %
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement