Commit b5814f12 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

Exit object updated to count takt time

parent ea1511f7
......@@ -55,7 +55,10 @@ class Exit(Process):
self.downTimeInCurrentEntity=0 #holds the total time that the object was down while holding current entity
self.timeLastEntityLeft=0 #holds the last time that an entity left the object
self.processingTimeOfCurrentEntity=0 #holds the total processing time that the current entity required
self.processingTimeOfCurrentEntity=0 #holds the total processing time that the current entity required
self.totalTaktTime=0 #the total time between to consecutive exits
self.TaktTime=[] #list that holds the avg time between to consecutive exits
self.waitToDispose=False #shows if the object waits to dispose an entity
......@@ -65,6 +68,8 @@ class Exit(Process):
#and one predecessor requests it
self.getEntity()
self.numOfExits+=1 #increase the exits by one
self.totalTaktTime+=now()-self.timeLastEntityLeft #add the takt time
self.timeLastEntityLeft=now() #update the time that the last entity left from the Exit
#sets the routing in element for the Exit
def defineRouting(self, p):
......@@ -88,13 +93,6 @@ class Exit(Process):
#gets an entity from the predecessor
def getEntity(self):
'''
#A=self.previous[0].Res.activeQ[0]
name=self.previous[0].Res.activeQ[0].name #get the name of the entity for the trace
self.totalLifespan+=now()-self.previous[0].Res.activeQ[0].startTime #Add the entity's lifespan to the total one.
self.previous[0].removeEntity() #remove the entity from the previous object
#del A
'''
name=self.previous[self.predecessorIndex].Res.activeQ[0].name #get the name of the entity for the trace
self.totalLifespan+=now()-self.previous[self.predecessorIndex].Res.activeQ[0].startTime #Add the entity's lifespan to the total one.
self.previous[self.predecessorIndex].removeEntity() #remove the entity from the previous object
......@@ -108,6 +106,10 @@ class Exit(Process):
self.Lifespan.append(((self.totalLifespan)/self.numOfExits)/G.Base)
except ZeroDivisionError:
self.Lifespan.append(0)
try:
self.TaktTime.append(((self.totalTaktTime)/self.numOfExits)/G.Base)
except ZeroDivisionError:
self.TaktTime.append(0)
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | "generated")
......@@ -133,8 +135,17 @@ class Exit(Process):
G.outputSheet.write(G.outputIndex,1,self.numOfExits)
G.outputIndex+=1
G.outputSheet.write(G.outputIndex,0, "The average lifespan of an entity that exited from "+ self.objName +" is:")
G.outputSheet.write(G.outputIndex,1,((self.totalLifespan)/self.numOfExits)/G.Base)
try:
G.outputSheet.write(G.outputIndex,1,((self.totalLifespan)/self.numOfExits)/G.Base)
except ZeroDivisionError:
G.outputSheet.write(G.outputIndex,1,0)
G.outputIndex+=1
G.outputSheet.write(G.outputIndex,0, "The average tatk time in "+ self.objName +" is:")
try:
G.outputSheet.write(G.outputIndex,1,((self.totalTaktTime)/self.numOfExits)/G.Base)
except ZeroDivisionError:
G.outputSheet.write(G.outputIndex,1,0)
G.outputIndex+=1
else: #if we had multiple replications we output confidence intervals to excel
#for some outputs the results may be the same for each run (eg model is stochastic but failures fixed
#so failurePortion will be exactly the same in each run). That will give 0 variability and errors.
......@@ -160,9 +171,19 @@ class Exit(Process):
G.outputSheet.write(G.outputIndex,2,self.Lifespan[0])
G.outputSheet.write(G.outputIndex,3,self.Lifespan[0])
G.outputIndex+=1
G.outputSheet.write(G.outputIndex,0, "CI "+str(G.confidenceLevel*100)+"% for the avg takt time in "+ self.objName + " is:")
if self.checkIfArrayHasDifValues(self.TaktTime):
G.outputSheet.write(G.outputIndex,1,stat.bayes_mvs(self.TaktTime, G.confidenceLevel)[0][1][0])
G.outputSheet.write(G.outputIndex,2,stat.bayes_mvs(self.TaktTime, G.confidenceLevel)[0][0])
G.outputSheet.write(G.outputIndex,3,stat.bayes_mvs(self.TaktTime, G.confidenceLevel)[0][1][1])
else:
G.outputSheet.write(G.outputIndex,1,self.TaktTime[0])
G.outputSheet.write(G.outputIndex,2,self.TaktTime[0])
G.outputSheet.write(G.outputIndex,3,self.TaktTime[0])
G.outputIndex+=1
G.outputIndex+=1
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def checkIfArrayHasDifValues(self, array):
......
......@@ -60,7 +60,7 @@
{"_class": "Dream.Queue",
"id": "DummyQ",
"name": "DummyQ",
"isDummy": "True",
"isDummy": "1",
"capacity": "1",
"predecessorList": ["S1"],
"successorList": ["M1"]
......@@ -68,7 +68,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M1"],
"successorList": ["M2"]
......
......@@ -60,7 +60,7 @@
{"_class": "Dream.Queue",
"id": "DummyQ",
"name": "DummyQ",
"isDummy": "True",
"isDummy": "1",
"capacity": "1",
"predecessorList": ["S1"],
"successorList": ["M1"]
......
......@@ -60,7 +60,7 @@
{"_class": "Dream.Queue",
"id": "DummyQ",
"name": "DummyQ",
"isDummy": "True",
"isDummy": "1",
"capacity": "1",
"predecessorList": ["S1"],
"successorList": ["M2"]
......@@ -68,7 +68,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M2"],
"successorList": ["M1"]
......
......@@ -77,7 +77,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M1"],
"successorList": ["M2"]
......
......@@ -73,7 +73,7 @@
{"_class": "Dream.Queue",
"id": "DummyQ",
"name": "DummyQ",
"isDummy": "True",
"isDummy": "1",
"capacity": "1",
"predecessorList": ["S1"],
"successorList": ["M1"]
......@@ -81,7 +81,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M1"],
"successorList": ["M2"]
......
......@@ -79,7 +79,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M1", "M2"],
"successorList": ["M3"]
......
......@@ -97,7 +97,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M1", "M2","M3"],
"successorList": ["M4"]
......
......@@ -86,7 +86,7 @@
{"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["M1","M2"],
"successorList": ["M3","M4"]
......
......@@ -79,7 +79,7 @@
"_class": "Dream.Queue",
"id": "DummyQ",
"name": "DummyQ",
"isDummy": "True",
"isDummy": "1",
"capacity": "1",
"predecessorList": ["S1"],
"successorList": ["Q1"]
......@@ -88,7 +88,7 @@
"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["DummyQ"],
"successorList": ["M1","M2"]
......
......@@ -93,7 +93,7 @@
"_class": "Dream.Queue",
"id": "DummyQ",
"name": "DummyQ",
"isDummy": "True",
"isDummy": "1",
"capacity": "1",
"predecessorList": ["S1"],
"successorList": ["Q1"]
......@@ -102,7 +102,7 @@
"_class": "Dream.Queue",
"id": "Q1",
"name": "Q1",
"isDummy": "False",
"isDummy": "0",
"capacity": "1",
"predecessorList": ["DummyQ"],
"successorList": ["M1","M2"]
......
......@@ -123,7 +123,7 @@ def createObjects():
successorList=coreObject[i].get('successorList', 'not found')
predecessorList=coreObject[i].get('predecessorList', 'not found')
capacity=int(coreObject[i].get('capacity', '1'))
isDummy=bool(coreObject[i].get('isDummy', 'False'))
isDummy=bool(int(coreObject[i].get('isDummy', '0')))
Q=Queue(id, name, capacity, isDummy)
Q.previousIds=predecessorList
Q.nextIds=successorList
......@@ -298,5 +298,5 @@ def main():
G.outputFile.save("output.xls")
print "execution time="+str(time.time()-start)
if __name__ == '__main__': main()
\ No newline at end of file
......@@ -75,6 +75,7 @@ class Source(Process):
#entity=Entity("Ent"+str(i))
entity=self.item(self.item.type+"_"+self.objName+"_"+str(i)) #create the Entity object and assign its name
entity.creationTime=now() #assign the current simulation time as the Entity's creation time
entity.startTime=now() #assign the current simulation time as the Entity's start time
self.outputTrace(self.item.type+"_"+self.objName+"_"+str(i)) #output the trace
self.Res.activeQ.append(entity) #append the entity to the resource
i+=1
......@@ -88,6 +89,7 @@ class Source(Process):
#entity=Entity("Ent"+str(i)) #create the Entity object and assign its name
entity=self.item(self.item.type+str(i)) #create the Entity object and assign its name
entity.creationTime=now() #assign the current simulation time as the Entity's creation time
entity.startTime=now() #assign the current simulation time as the Entity's start time
self.outputTrace(self.item.type+str(i)) #output the trace
i+=1
self.Res.activeQ.append(entity) #append the entity to the resource
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment