Permalink
Browse files

irr

  • Loading branch information...
1 parent 0649ff4 commit ecdaca407e5355f8885ec2f849c1d4f9d40260f1 @lalithsuresh committed Dec 18, 2010
Showing with 117 additions and 11 deletions.
  1. +1 −0 Scenario.py
  2. +5 −0 Scheduler.py
  3. +103 −0 SchedulingAlgos.py
  4. +2 −5 input
  5. +6 −6 scheduler.conf
View
@@ -10,6 +10,7 @@
algorithms_map = {'random':random_schedule,
'round_robin':round_robin,
'lpt': longest_processing_time_first,
+ 'irr': irr,
'ESBOT': ESBOT}
class CloudSimScenario:
View
@@ -288,6 +288,11 @@ def destroyMachine(self, machine):
self.destroyedMachines.append(machine)
def createMachine(self, started=False, shutdown=3550):
+
+ # this is a hack -- lalith
+ if (shutdown == 3550):
+ shutdown = self.scenario.sim_time
+
shutdown += int(now())
print "[%d] Creating machine %d. Shutdown time: %d" % (now(), self.genId, shutdown)
View
@@ -25,6 +25,109 @@ def round_robin(workerList, tasks, scheduler):
return allocations
+def return_next (s, listofworkers):
+
+ start = s
+ while (start == listofworkers[0]):
+ listofworkers = [listofworkers.pop()] + listofworkers
+
+ return listofworkers
+
+submittedList = []
+lastMachineP = None
+def irr(workerList, tasks, scheduler):
+ global currentMachine
+ global lastMachineP
+
+ flag = 0
+ weights = []
+ i = 0
+ for each in scheduler.avgRtPerWorker.values():
+ weights.append (each[0] - scheduler.avgRT[0])
+ if (each[0] < 200):
+ flag = 1
+ i += 1
+
+ usingWeights = 0
+ if (len(weights) == len(workerList)):
+ usingWeights = 1
+ minWeight = min (weights)
+ if (minWeight < 0):
+ minWeight = -minWeight
+ if (minWeight == 0.0):
+ minWeight = 1.0
+ normalisedList = map(lambda x : x + 2*minWeight, weights) # add 1 so that all weights are non-zero
+ minWeight = min(normalisedList)
+ normalisedList = map (lambda x : x/minWeight, normalisedList)
+ s = sum (normalisedList)
+ normalisedList = map (lambda x : s/x, normalisedList)
+
+ x = normalisedList[0]
+ allSame = 1
+ for each in normalisedList[1:]:
+ if (x != each):
+ allSame = 0
+ break
+
+ if (allSame == 1):
+ normalisedList = map (lambda x : 1.0, normalisedList)
+
+ orphanJobs = get_non_allocated_jobs(tasks)
+ allocations = []
+
+ if (orphanJobs == 0):
+ return []
+
+ newList = workerList [0:]
+
+ if (usingWeights == 1):
+ zz = []
+ i = 0
+ for each in newList:
+ zz = [each] * int(normalisedList[i]) + zz
+ i += 1
+ newList = zz
+
+ if (flag == 0):
+ newList = [scheduler.createMachine(), scheduler.createMachine()] * (int(sum(normalisedList)/2)) + newList
+
+ last = None
+
+ reqLen = 0
+
+ for each in scheduler.avgRtPerWorker.values():
+ if (each[0] > 0.0):
+ reqLen += 1
+
+ l = newList[0:]
+ x = []
+ last = l[0]
+ while (l != []):
+ if(last.id == l[-1].id):
+ l = [l.pop()] + l
+ else:
+ last = l.pop()
+ x.append (last)
+
+ if (map(lambda x:x.id,l) == [l[0].id] * len(l)):
+ x = x + l
+ break
+
+ newList = x
+
+ for job in orphanJobs:
+ newList = [newList.pop()] + newList
+ machine = newList[0]
+
+ if (machine.id not in submittedList):
+ allocations.append([machine, job])
+ submittedList.append (machine.id)
+ elif (reqLen == len(scheduler.avgRtPerWorker)):
+ allocations.append([machine, job])
+
+ return allocations
+
+
idsSubmitted = []
done = 0
ESList = []
View
@@ -1,5 +1,2 @@
-S, 1, 100, 1, 0, 1000, 1000, 512, 512
-S, 2, 200, 5, 0, 4000, 5000, 512, 2000
-S, 3, 500, 2, 3, 4000, 5000, 100, 900
-S, 4, 500, 2, 3, 4000, 5000, 100, 900
-S, 5, 500, 2, 3, 4000, 5000, 100, 900
+W, 1, 100, 1, 0, 1000, 1000, 512, 512
+W, 101, 200, 5, 0, 4000, 5000, 512, 2000
View
@@ -1,7 +1,7 @@
#Single task or web mode (W or S)
-S
+W
#Scheduling interval (0.01 - 1 seconds)
-0.1
+1
#Worker node speed (200 - 400 instructions/second)
300
#Worker node memory size (2 - 8 GB)
@@ -15,18 +15,18 @@ S
#Worker node scheduler notification time (1-5 instructions)
2
#Worker node cost (euros/hour);
-0.5
+1.0
#Number of worker nodes at startup. This parameter will be zero in the provided test files but may be modified by the students
10
#Size of the sliding window for the output running average [in seconds]
300
#Polling interval for the output time series [in seconds]
-10
+1
#Percentage of waste, amount of wasted money in the final cost that is acceptable to the client.
-50
+10
#Simulation time
10000
#Scheduling algorithm (either random or round_robin)
-random
+irr
#Random seed
3557

0 comments on commit ecdaca4

Please sign in to comment.