Commit 0f9e90fc authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

LineGenerationJSON modified to incorporate operated...

LineGenerationJSON modified to incorporate operated MachinePreemptive/MouldAssembly objects. Machine also releases operators in case of preemption.
parent d15a0098
......@@ -317,7 +317,8 @@ def createObjects():
repairman=r)
M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
G.MachineList.append(M) # add machine to global MachineList
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
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':
......@@ -450,7 +451,8 @@ def createObjects():
M.nextIds=getSuccessorList(id)
G.MachineJobShopList.append(M)
G.MachineList.append(M)
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
if M.operatorPool!="None":
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
G.ObjList.append(M)
elif objClass=='Dream.MachinePreemptive':
......@@ -468,20 +470,59 @@ def createObjects():
MTTF=float(failures.get('MTTF', '0'))
MTTR=float(failures.get('MTTR', '0'))
availability=float(failures.get('availability', '0'))
resetOnPreemption=bool(int(element.get('resetOnPreemption', '0')))
# type of operation and related times
operationType=element.get('operationType','not found')
setupTime = element.get('setupTime',{})
setupDistribution = setupTime.get('setupDistribution','not found')
setupMean = float(setupTime.get('setupMean','0'))
setupStdev=float(setupTime.get('setupStdev', '0'))
setupMin=float(setupTime.get('setupMin', '0'))
setupMax=float(setupTime.get('setupMax', '0'))
loadTime = element.get('loadTime',{})
loadDistribution = loadTime.get('loadDistribution','not found')
loadMean = float(loadTime.get('loadMean','0'))
loadStdev = float(loadTime.get('loadStdev', '0'))
loadMin=float(loadTime.get('loadMin', '0'))
loadMax=float(loadTime.get('loadMax', '0'))
resetOnPreemption=bool(int(element.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
for repairman in G.RepairmanList:
if(id in repairman.coreObjectIds):
r=repairman
M=MachinePreemptive(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
mean=mean,stdev=stdev,min=min,max=max, resetOnPreemption=resetOnPreemption)
M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r,
mean=mean,stdev=stdev,min=min,max=max,
operatorPool=machineOperatorPoolList, operationType=operationType,
loadDistribution=loadDistribution, setupDistribution=setupDistribution,
setupMean=setupMean,setupStdev=setupStdev,setupMin=setupMin,setupMax=setupMax,
loadMean=loadMean,loadStdev=loadStdev,loadMin=loadMin,loadMax=loadMax,
repairman=r, resetOnPreemption=resetOnPreemption)
M.nextIds=getSuccessorList(id)
G.MachinePreemptiveList.append(M) # add machine to global MachinePreemptiveList
G.MachineList.append(M) # add machine to global MachineList
G.ObjList.append(M) # add machine to ObjList
G.MachineJobShopList.append(M)
G.MachineList.append(M)
if M.operatorPool!="None":
G.OperatedMachineList.append(M) # add the machine to the operatedMachines List
G.ObjList.append(M)
elif objClass=='Dream.Exit':
id=element.get('id', 'not found')
......@@ -766,21 +807,60 @@ def createObjects():
MTTF=float(failures.get('MTTF', '0'))
MTTR=float(failures.get('MTTR', '0'))
availability=float(failures.get('availability', '0'))
resetOnPreemption=bool(int(element.get('resetOnPreemption', '0')))
resetOnPreemption=bool(int(element.get('resetOnPreemption', '0')))
# type of operation and related times
operationType=element.get('operationType','not found')
setupTime = element.get('setupTime',{})
setupDistribution = setupTime.get('setupDistribution','not found')
setupMean = float(setupTime.get('setupMean','0'))
setupStdev=float(setupTime.get('setupStdev', '0'))
setupMin=float(setupTime.get('setupMin', '0'))
setupMax=float(setupTime.get('setupMax', '0'))
loadTime = element.get('loadTime',{})
loadDistribution = loadTime.get('loadDistribution','not found')
loadMean = float(loadTime.get('loadMean','0'))
loadStdev = float(loadTime.get('loadStdev', '0'))
loadMin=float(loadTime.get('loadMin', '0'))
loadMax=float(loadTime.get('loadMax', '0'))
resetOnPreemption=bool(int(element.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
for repairman in G.RepairmanList:
if(id in repairman.coreObjectIds):
r=repairman
MA=MouldAssembly(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
mean=mean,stdev=stdev,min=min,max=max, resetOnPreemption=resetOnPreemption)
MA.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r,
mean=mean,stdev=stdev,min=min,max=max,
operatorPool=machineOperatorPoolList, operationType=operationType,
loadDistribution=loadDistribution, setupDistribution=setupDistribution,
setupMean=setupMean,setupStdev=setupStdev,setupMin=setupMin,setupMax=setupMax,
loadMean=loadMean,loadStdev=loadStdev,loadMin=loadMin,loadMax=loadMax,
repairman=r, resetOnPreemption=resetOnPreemption)
MA.nextIds=getSuccessorList(id)
G.MachinePreemptiveList.append(MA) # add machine to global MachinePreemptiveList
G.MachineList.append(MA) # add machine to global MachineList
G.MachineJobShopList.append(MA)
G.MachineList.append(MA)
G.MouldAssemblyList.append(MA)
G.ObjList.append(MA) # add machine to ObjList
if MA.operatorPool!="None":
G.OperatedMachineList.append(MA) # add the machine to the operatedMachines List
G.ObjList.append(MA)
# -----------------------------------------------------------------------
# loop through all the nodes to
......
......@@ -342,6 +342,13 @@ class Machine(CoreObject):
if (len(self.getActiveObjectQueue())==0 and self.shouldPreempt):
self.shouldPreempt=False
self.totalWorkingTime+=now()-(self.timeLastEntityEntered)
# TODO: Should release operator here
# =============== release resource in case of preemption
if (self.operatorPool!='None')\
and any(type=="Processing" for type in self.multOperationTypeList)\
and not interruption:
self.releaseOperator()
yield waituntil,self,self.broker.brokerIsSet
continue
# output to trace that the processing in the Machine self.objName ended
......
......@@ -33,9 +33,16 @@ from SimPy.Simulation import reactivate, now
class MachinePreemptive(MachineJobShop):
def __init__(self, id, name, capacity=1, distribution='Fixed', mean=1, stdev=0, min=0, max=10,\
failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None', resetOnPreemption=True):
failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None',\
operatorPool='None',operationType='None',\
loadDistribution="No",loadMean=0, loadStdev=0, loadMin=0, loadMax=10,\
setupDistribution="No",setupMean=0, setupStdev=0, setupMin=0, setupMax=10,\
resetOnPreemption=True):
MachineJobShop.__init__(self, id, name, capacity, distribution, mean, stdev, min, max,\
failureDistribution, MTTF, MTTR, availability, repairman)
failureDistribution, MTTF, MTTR, availability, repairman,\
operatorPool,operationType,\
loadDistribution,loadMean, loadStdev, loadMin, loadMax,\
setupDistribution,setupMean, setupStdev, setupMin, setupMax)
self.resetOnPreemption=resetOnPreemption #flag that shows if the processing time should be reset or not
def getEntity(self):
......
......@@ -53,6 +53,7 @@ class OperatorPreemptive(Operator):
if len(activeResourceQueue)==0:
return True
# read the station currently operated by the operator
# TODO: the victim of the operator is the Broker of the Machine. Modify to preempt the machine and not the broker
victim=activeResourceQueue[0]
# read its activeQ
victimQueue=victim.getActiveObjectQueue()
......
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