Commit 1ac8f292 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Failures change in order to read in thenew fashion

parent b9fe9d6c
......@@ -33,13 +33,19 @@ from ObjectInterruption import ObjectInterruption
class Failure(ObjectInterruption):
def __init__(self, victim=None, distributionType='Fixed', MTTF=60, MTTR=5, availability=100, index=0, repairman=None):
def __init__(self, victim=None, distribution=None, index=0, repairman=None):
#Process.__init__(self)
ObjectInterruption.__init__(self,victim)
self.distType=distributionType # the distribution that the failure duration follows
self.MTTF=MTTF # the MTTF
self.MTTR=MTTR # the MTTR
self.availability=availability # the availability
if distribution:
self.distType=distribution.get('failureDistribution','No') # the distribution that the failure duration follows
self.MTTF=distribution.get('MTTF',60) # the MTTF
self.MTTR=distribution.get('MTTR',5) # the MTTR
self.availability=distribution.get('availability',100) # the availability
else:
self.distType='No'
self.MTTF=60
self.MTTR=5
self.availability=100
self.name="F"+str(index)
self.repairman=repairman # the resource that may be needed to fix the failure
# if now resource is needed this will be "None"
......@@ -56,13 +62,11 @@ class Failure(ObjectInterruption):
# beta=(sigma^2)/Mu
# alpha=Mu/beta
# --------------------------------------------------------------
self.AvailabilityMTTF=MTTR*(float(availability)/100)/(1-(float(availability)/100))
self.sigma=0.707106781185547*MTTR
self.theta=(pow(self.sigma,2))/float(MTTR)
self.AvailabilityMTTF=self.MTTR*(float(availability)/100)/(1-(float(availability)/100))
self.sigma=0.707106781185547*self.MTTR
self.theta=(pow(self.sigma,2))/float(self.MTTR)
self.beta=self.theta
self.alpha=(float(MTTR)/self.theta)
self.alpha=(float(self.MTTR)/self.theta)
self.rngTTF=RandomNumberGenerator(self, "Exp")
self.rngTTF.avg=self.AvailabilityMTTF
self.rngTTR=RandomNumberGenerator(self, "Erlang")
......@@ -73,9 +77,9 @@ class Failure(ObjectInterruption):
# if the distribution is fixed
# --------------------------------------------------------------
self.rngTTF=RandomNumberGenerator(self, self.distType)
self.rngTTF.mean=MTTF
self.rngTTF.mean=self.MTTF
self.rngTTR=RandomNumberGenerator(self, self.distType)
self.rngTTR.mean=MTTR
self.rngTTR.mean=self.MTTR
# =======================================================================
# The run method for the failure which has to served by a repairman
......
......@@ -46,7 +46,7 @@ class G:
ObjList=[] #a list that holds all the CoreObjects
EntityList=[] #a list that holds all the Entities
numberOfReplications=1 #the number of replications default=1
numberOfReplications=1 #the number of replications default=1git
confidenceLevel=0.9 #the confidence level default=90%
Base=1 #the Base time unit. Default =1 minute
maxSimTime=0 #the total simulation time
......
......@@ -1196,19 +1196,16 @@ def createObjectInterruptions():
SM=ScheduledMaintenance(victim=victim, start=start, duration=duration)
G.ObjectInterruptionList.append(SM)
G.ScheduledMaintenanceList.append(SM)
failure=element.get('failures', {})
failure=element.get('failures', None)
# if there are failures assigned
# initiate them
if len(failure):
if failure:
distributionType=failure.get('failureDistribution', 'No')
if distributionType=='No':
pass
else:
MTTF=float(failure.get('MTTF') or 0)
MTTR=float(failure.get('MTTR') or 0)
availability=float(failure.get('availability') or 0)
victim=Globals.findObjectById(element['id'])
F=Failure(victim, distributionType, MTTF, MTTR, availability, victim.id, victim.repairman)
F=Failure(victim, distribution=failure, repairman=victim.repairman)
G.ObjectInterruptionList.append(F)
G.FailureList.append(F)
# if there is a shift pattern defined
......
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