Commit 957b9edd authored by Georgios Dagkakis's avatar Georgios Dagkakis

BatchScrapMachine to read in the same fashion

parent fc01c77b
......@@ -43,28 +43,50 @@ class BatchScrapMachine(Machine):
# calls the Machine constructor, but also reads attributes for
# scraping distribution
# =======================================================================
def __init__(self, id, name, capacity=1, \
def __init__(self, id='', name='', capacity=1, \
processingTime=None,
failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None',\
scrapDistribution='Fixed',scrMean=1,scrStdev=0,scrMin=0,scrMax=10):
if not processingTime:
processingTime = {'distribution': 'Fixed',
'mean': 1}
# initialize using the default method of the object
Machine.__init__(self,id=id,name=name,\
capacity=capacity,\
processingTime=processingTime,
failureDistribution=failureDistribution,MTTF=MTTF,MTTR=MTTR,\
availability=availability,
repairman=repairman)
scrapDistribution='Fixed',scrMean=1,scrStdev=0,scrMin=0,scrMax=10,
inputsDict={}):
# if input is given in a dictionary
if inputsDict:
Machine.__init__(self,inputsDict=inputsDict)
# else read the separate ones
else:
if not processingTime:
processingTime = {'distribution': 'Fixed',
'mean': 1}
# initialize using the default method of the object
Machine.__init__(self,id=id,name=name,\
capacity=capacity,\
processingTime=processingTime,
failureDistribution=failureDistribution,MTTF=MTTF,MTTR=MTTR,\
availability=availability,
repairman=repairman)
self.scrapDistType=scrapDistribution #the distribution that the failure follows
# set the attributes of the scrap quantity distribution
self.scrapRng=RandomNumberGenerator(self, self.scrapDistType)
self.scrapRng.mean=scrMean
self.scrapRng.stdev=scrStdev
self.scrapRng.min=scrMin
self.scrapRng.max=scrMax
self.scrapDistType=scrapDistribution #the distribution that the failure follows
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
Machine.parseInputs(self, inputsDict)
# set the attributes of the scrap quantity distribution
scrapQuantity=inputsDict.get('scrapQuantity', {})
self.scrapDistType=scrapQuantity.get('distributionType', 'Fixed')
self.scrapRng=RandomNumberGenerator(self, self.scrapDistType)
self.scrapRng.mean=scrMean
self.scrapRng.stdev=scrStdev
self.scrapRng.min=scrMin
self.scrapRng.max=scrMax
self.scrapRng.mean=float(scrapQuantity.get('mean') or 0)
self.scrapRng.stdev=float(scrapQuantity.get('stdev') or 0)
self.scrapRng.min=float(scrapQuantity.get('min') or 0)
self.scrapRng.max=float(scrapQuantity.get('max') or self.scrapRng.mean+5*self.scrapRng.stdev)
from Globals import G
G.BatchScrapMachineList.append(self)
# =======================================================================
# removes an Entity from the Object the Entity to be removed is passed
......@@ -74,7 +96,7 @@ class BatchScrapMachine(Machine):
# =======================================================================
def removeEntity(self, entity=None):
activeEntity = Machine.removeEntity(self, entity)
scrapQuantity=self.scrapRng.generateNumber()
scrapQuantity=self.scrapRng.generateNumber()
activeEntity.numberOfUnits-=int(scrapQuantity) # the scrapQuantity should be integer at whatever case
if activeEntity.numberOfUnits<0:
activeEntity.numberOfUnits==0
......
......@@ -291,89 +291,40 @@ def createObjects():
G.SourceList.append(S)
G.ObjList.append(S)
elif objClass=='Dream.Machine':
elif objClass in ['Dream.Machine']:
M=Machine(inputsDict=element)
M.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the machine
elif objClass=='Dream.BatchScrapMachine':
# id=element.get('id', 'not found')
# name=element.get('name', 'not found')
# processingTime=element.get('processingTime',{})
# canDeliverOnInterruption=bool(element.get('canDeliverOnInterruption') or 0)
# scrapQuantity=element.get('scrapQuantity', {})
# scrapDistributionType=scrapQuantity.get('distributionType', 'not found')
# scrMean=float(scrapQuantity.get('mean') or 0)
# scrStdev=float(scrapQuantity.get('stdev') or 0)
# scrMin=float(scrapQuantity.get('min') or 0)
# scrMax=float(scrapQuantity.get('max') or scrMean+5*scrStdev)
# failures=element.get('failures', {})
# failureDistribution=failures.get('failureDistribution', 'not found')
# MTTF=float(failures.get('MTTF') or 0)
# MTTR=float(failures.get('MTTR') or 0)
# availability=float(failures.get('availability') or 0)
# # type of operation and related times
# operationType=element.get('operationType','not found')
# setupTime = element.get('setupTime', None)
# loadTime = element.get('loadTime', None)
# preemption=element.get('preemption',{})
# isPreemptive=resetOnPreemption=False
# if len(preemption)>0:
# isPreemptive=bool(int(preemption.get('isPreemptive') or 0))
# resetOnPreemption=bool(int(preemption.get('resetOnPreemption', 0)))
#
# if len(G.OperatorPoolsList)>0:
# for operatorPool in G.OperatorPoolsList: # find the operatorPool assigned to the machine
# if(id in operatorPool.coreObjectIds): # and add it to the machine's operatorPool
# machineOperatorPoolList=operatorPool # there must only one operator pool assigned to the machine,
# # otherwise only one of them will be taken into account
# else:
# machineOperatorPoolList=[] # if there is no operatorPool assigned to the machine
# else: # then machineOperatorPoolList/operatorPool is a list
# machineOperatorPoolList=[] # if there are no operatorsPool created then the
# # then machineOperatorPoolList/operatorPool is a list
# if (type(machineOperatorPoolList) is list): # if the machineOperatorPoolList is a list
# # find the operators assigned to it and add them to the list
# for operator in G.OperatorsList: # check which operator in the G.OperatorsList
# if(id in operator.coreObjectIds): # (if any) is assigned to operate
# machineOperatorPoolList.append(operator) # the machine with ID equal to id
# # if there is no operator assigned then the list will be empty
# r='None'
# for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
# if(id in repairman.coreObjectIds): # (if any) is assigned to repair
# r=repairman # the machine with ID equal to id
# M=Machine(id, name, 1, processingTime, failureDistribution=failureDistribution,
# MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r,
# operatorPool=machineOperatorPoolList, operationType=operationType,
# setupTime=setupTime,
# loadTime=loadTime,
# repairman=r, isPreemptive=isPreemptive, resetOnPreemption=resetOnPreemption,
# canDeliverOnInterruption=canDeliverOnInterruption)
M=Machine(inputsDict=element)
#
# M=BatchScrapMachine(id, name, 1, processingTime, failureDistribution=failureDistribution,
# MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
# scrMean=scrMean,
# scrStdev=scrStdev,scrMin=scrMin,scrMax=scrMax)
# M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
# G.MachineList.append(M) # add machine to global MachineList
# G.BatchScrapMachineList.append(M)
# G.ObjList.append(M) # add machine to ObjList
M=BatchScrapMachine(inputsDict=element)
M.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the machine
G.MachineList.append(M) # add machine to global MachineList
if M.operatorPool!="None":
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
G.ObjList.append(M) # add machine to ObjList
elif objClass=='Dream.BatchScrapMachine':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
processingTime=element.get('processingTime',{})
scrapQuantity=element.get('scrapQuantity', {})
scrapDistributionType=scrapQuantity.get('distributionType', 'not found')
scrMean=float(scrapQuantity.get('mean') or 0)
scrStdev=float(scrapQuantity.get('stdev') or 0)
scrMin=float(scrapQuantity.get('min') or 0)
scrMax=float(scrapQuantity.get('max') or scrMean+5*scrStdev)
failures=element.get('failures', {})
failureDistribution=failures.get('failureDistribution', 'not found')
MTTF=float(failures.get('MTTF') or 0)
MTTR=float(failures.get('MTTR') or 0)
availability=float(failures.get('availability') or 0)
r='None'
for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
if(id in repairman.coreObjectIds): # (if any) is assigned to repair
r=repairman # the machine with ID equal to id
M=BatchScrapMachine(id, name, 1, processingTime, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
scrMean=scrMean,
scrStdev=scrStdev,scrMin=scrMin,scrMax=scrMax)
M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
G.MachineList.append(M) # add machine to global MachineList
G.BatchScrapMachineList.append(M)
G.ObjList.append(M) # add machine to ObjList
elif objClass=='Dream.M3':
id=element.get('id', 'not found')
......
......@@ -126,8 +126,10 @@ class Machine(CoreObject):
self.assignedOperator=True
# flag notifying the the station can deliver entities that ended their processing while interrupted
self.canDeliverOnInterruption=canDeliverOnInterruption
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
from Globals import G
id = inputsDict.get('id')
......@@ -221,7 +223,13 @@ class Machine(CoreObject):
for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
if(self.id in repairman.coreObjectIds): # (if any) is assigned to repair
self.repairman=repairman # the machine with ID equal to id
G.MachineList.append(self) # add machine to global MachineList
if self.operatorPool!="None":
G.OperatedMachineList.append(self) # add the machine to the operatedMachines List
G.ObjList.append(self) # add machine to ObjList
# =======================================================================
# initialize the machine
# =======================================================================
......
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