Commit 8f437377 authored by Georgios Dagkakis's avatar Georgios Dagkakis

start using ** attr

parent 430b6d15
...@@ -78,6 +78,8 @@ class Assembly(CoreObject): ...@@ -78,6 +78,8 @@ class Assembly(CoreObject):
# when the entities have to be loaded to operatedMachines # when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time # then the giverObjects have to be blocked for the time
# that the machine is being loaded # that the machine is being loaded
from Globals import G
G.AssemblyList.append(self)
# ======================================================================= # =======================================================================
# parses inputs if they are given in a dictionary # parses inputs if they are given in a dictionary
......
...@@ -34,7 +34,7 @@ import simpy ...@@ -34,7 +34,7 @@ import simpy
class CoreObject(object): class CoreObject(object):
class_name = 'Dream.CoreObject' class_name = 'Dream.CoreObject'
def __init__(self, id='', name='', inputsDict={}, **kw): def __init__(self, id, name, inputsDict={}, **kw):
self.id = id self.id = id
self.objName = name self.objName = name
# lists that hold the previous and next objects in the flow # lists that hold the previous and next objects in the flow
...@@ -68,15 +68,6 @@ class CoreObject(object): ...@@ -68,15 +68,6 @@ class CoreObject(object):
self.station_col_inds=[] self.station_col_inds=[]
self.op_col_indx=None self.op_col_indx=None
# if there is input in a dictionary parse from it # if there is input in a dictionary parse from it
if inputsDict:
self.parseInputs(inputsDict)
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
self.id = inputsDict.get('id')
self.objName = inputsDict.get('name')
from Globals import G from Globals import G
G.ObjList.append(self) # add object to ObjList G.ObjList.append(self) # add object to ObjList
......
...@@ -45,16 +45,7 @@ class Exit(CoreObject): ...@@ -45,16 +45,7 @@ class Exit(CoreObject):
self.Lifespan=[] self.Lifespan=[]
self.TaktTime=[] self.TaktTime=[]
# if input is given in a dictionary # if input is given in a dictionary
if inputsDict:
CoreObject.__init__(self, inputsDict=inputsDict)
else:
CoreObject.__init__(self, id, name) CoreObject.__init__(self, id, name)
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
CoreObject.parseInputs(self, inputsDict)
from Globals import G from Globals import G
G.ExitList.append(self) G.ExitList.append(self)
......
...@@ -278,12 +278,6 @@ def createObjects(): ...@@ -278,12 +278,6 @@ def createObjects():
element.pop(k, None) element.pop(k, None)
objClass = element.pop('_class') objClass = element.pop('_class')
if objClass=='Dream.Source':
S=Source(**element)
S.nextIds=getSuccessorList(element['id'])
G.SourceList.append(S)
G.ObjList.append(S)
if objClass=='Dream.BatchSource': if objClass=='Dream.BatchSource':
S = BatchSource(**element) S = BatchSource(**element)
S.nextIds=getSuccessorList(element['id']) S.nextIds=getSuccessorList(element['id'])
...@@ -294,14 +288,21 @@ def createObjects(): ...@@ -294,14 +288,21 @@ def createObjects():
elif objClass in ['Dream.Machine', 'Dream.BatchScrapMachine', 'Dream.M3', 'Dream.MachineJobShop', elif objClass in ['Dream.Machine', 'Dream.BatchScrapMachine', 'Dream.M3', 'Dream.MachineJobShop',
'Dream.MachineManagedJob', 'Dream.MouldAssembly', 'Dream.Exit', 'Dream.ExitJobShop', 'Dream.MachineManagedJob', 'Dream.MouldAssembly', 'Dream.Exit', 'Dream.ExitJobShop',
'Dream.Queue', 'Dream.RoutingQueue', 'Dream.QueueJobShop', 'Dream.QueueManagedJob', 'Dream.Queue', 'Dream.RoutingQueue', 'Dream.QueueJobShop', 'Dream.QueueManagedJob',
'Dream.Assembly', 'Dream.Dismantle']: 'Dream.Assembly', 'Dream.Dismantle', 'Dream.Source']:
inputDict=dict(element)
if 'wip' in inputDict:
del inputDict['wip']
if 'failures' in inputDict:
del inputDict['failures']
if 'shift' in inputDict:
del inputDict['shift']
objectType=Globals.getClassFromName(objClass) objectType=Globals.getClassFromName(objClass)
coreObject=objectType(inputsDict=element) coreObject=objectType(**inputDict)
# get the successorList for the 'Parts' # get the successorList for the 'Parts'
coreObject.nextPartIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Part') coreObject.nextPartIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Part')
# get the successorList for the 'Frames' # get the successorList for the 'Frames'
coreObject.nextFrameIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Frame') coreObject.nextFrameIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Frame')
coreObject.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the machine coreObject.nextIds=getSuccessorList(element['id']) # update the nextIDs list of the object
elif objClass=='Dream.Conveyer': elif objClass=='Dream.Conveyer':
id=element.get('id', 'not found') id=element.get('id', 'not found')
......
...@@ -49,18 +49,13 @@ class Machine(CoreObject): ...@@ -49,18 +49,13 @@ class Machine(CoreObject):
# ======================================================================= # =======================================================================
# initialise the id the capacity, of the resource and the distribution # initialise the id the capacity, of the resource and the distribution
# ======================================================================= # =======================================================================
def __init__(self, id='', name='', capacity=1, processingTime=None, def __init__(self, id, name, capacity=1, processingTime=None,
failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None',\ repairman='None',\
operatorPool='None',operationType='None',\ operatorPool='None',operationType='None',\
setupTime=None, loadTime=None, setupTime=None, loadTime=None,
isPreemptive=False, resetOnPreemption=False, isPreemptive=False, resetOnPreemption=False,
canDeliverOnInterruption=False, inputsDict={}, failures=None): canDeliverOnInterruption=False, inputsDict={}, failures=None):
self.type="Machine" #String that shows the type of object self.type="Machine" #String that shows the type of object
# if input is given in a dictionary
if inputsDict:
CoreObject.__init__(self, inputsDict=inputsDict)
# else read the separate ones
else:
CoreObject.__init__(self, id, name) CoreObject.__init__(self, id, name)
if not processingTime: if not processingTime:
processingTime = { 'distributionType': 'Fixed', processingTime = { 'distributionType': 'Fixed',
...@@ -85,15 +80,10 @@ class Machine(CoreObject): ...@@ -85,15 +80,10 @@ class Machine(CoreObject):
# holds the capacity of the machine # holds the capacity of the machine
self.capacity=capacity self.capacity=capacity
# define the distribution types of the processing and failure times respectively
self.failureDistType=failureDistribution #the distribution that the failure follows
# sets the repairman resource of the Machine # sets the repairman resource of the Machine
self.repairman=repairman self.repairman=repairman
# Sets the attributes of the processing (and failure) time(s) # Sets the attributes of the processing (and failure) time(s)
self.rng=RandomNumberGenerator(self, **processingTime) self.rng=RandomNumberGenerator(self, **processingTime)
self.MTTF=MTTF
self.MTTR=MTTR
self.availability=availability
# check whether the operators are provided with a skills set # check whether the operators are provided with a skills set
self.dedicatedOperator=self.checkForDedicatedOperators() self.dedicatedOperator=self.checkForDedicatedOperators()
# create an operatorPool if needed # create an operatorPool if needed
...@@ -128,106 +118,16 @@ class Machine(CoreObject): ...@@ -128,106 +118,16 @@ class Machine(CoreObject):
self.assignedOperator=True self.assignedOperator=True
# flag notifying the the station can deliver entities that ended their processing while interrupted # flag notifying the the station can deliver entities that ended their processing while interrupted
self.canDeliverOnInterruption=canDeliverOnInterruption self.canDeliverOnInterruption=canDeliverOnInterruption
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
CoreObject.parseInputs(self, inputsDict)
from Globals import G from Globals import G
processingTime=inputsDict.get('processingTime',{})
if not processingTime:
processingTime = { 'distributionType': 'Fixed',
'mean': 1, }
if processingTime['distributionType'] == 'Normal' and\
processingTime.get('max', None) is None:
processingTime['max'] = float(processingTime['mean']) + 5 * float(processingTime['stdev'])
setupTime=inputsDict.get('setupTime',{})
if not setupTime:
setupTime = { 'distributionType': 'Fixed',
'mean': 1, }
if setupTime['distributionType'] == 'Normal' and\
setupTime.get('max', None) is None:
setupTime['max'] = float(setupTime['mean']) + 5 * float(setupTime['stdev'])
loadTime=inputsDict.get('loadTime',{})
if not loadTime:
loadTime = { 'distributionType': 'Fixed',
'mean': 1, }
if loadTime['distributionType'] == 'Normal' and\
loadTime.get('max', None) is None:
loadTime['max'] = float(loadTime['mean']) + 5 * float(loadTime['stdev'])
# holds the capacity of the machine
self.capacity=inputsDict.get('capacity',1)
# define the distribution types of the processing and failure times respectively
self.rng=RandomNumberGenerator(self, **processingTime)
# check whether the operators are provided with a skills set
self.dedicatedOperator=self.checkForDedicatedOperators()
if len(G.OperatorPoolsList)>0:
for operatorPool in G.OperatorPoolsList: # find the operatorPool assigned to the machine
if(self.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(self.id in operator.coreObjectIds): # (if any) is assigned to operate
machineOperatorPoolList.append(operator) # the machine with ID equal to id
self.operatorPool=machineOperatorPoolList
# create an operatorPool if needed
self.createOperatorPool(self.operatorPool)
# holds the Operator currently processing the Machine
self.currentOperator=None
# define if load/setup/removal/processing are performed by the operator
self.operationType=inputsDict.get('operationType', 'None')
# boolean to check whether the machine is being operated
self.toBeOperated = False
# define the load times
self.loadRng = RandomNumberGenerator(self, **loadTime)
# variable that informs on the need for setup
self.setUp=True
# define the setup times
self.stpRng = RandomNumberGenerator(self, **setupTime)
# examine if there are multiple operation types performed by the operator
# there can be Setup/Processing operationType
# or the combination of both (MT-Load-Setup-Processing)
self.multOperationTypeList=[]
if self.operationType.startswith("MT"):
OTlist = self.operationType.split('-')
self.operationType=OTlist.pop(0)
self.multOperationTypeList = OTlist
else:
self.multOperationTypeList.append(self.operationType)
# flags used for preemption purposes
preemption=inputsDict.get('preemption',{})
self.isPreemptive=False
self.resetOnPreemption=False
if len(preemption)>0:
self.isPreemptive=bool(int(preemption.get('isPreemptive') or 0))
self.resetOnPreemption=bool(int(preemption.get('resetOnPreemption', 0)))
# flag notifying that there is operator assigned to the actievObject
self.assignedOperator=True
# flag notifying the the station can deliver entities that ended their processing while interrupted
self.canDeliverOnInterruption=bool(inputsDict.get('canDeliverOnInterruption') or 0)
self.repairman='None' self.repairman='None'
for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
if(self.id in repairman.coreObjectIds): # (if any) is assigned to repair if(self.id in repairman.coreObjectIds): # (if any) is assigned to repair
self.repairman=repairman # the machine with ID equal to id self.repairman=repairman # the machine with ID equal to id
G.MachineList.append(self) # add machine to global MachineList G.MachineList.append(self) # add machine to global MachineList
if self.operatorPool!="None": if self.operatorPool!="None":
G.OperatedMachineList.append(self) # add the machine to the operatedMachines List G.OperatedMachineList.append(self) # add the machine to the operatedMachines List
# ======================================================================= # =======================================================================
# initialize the machine # initialize the machine
# ======================================================================= # =======================================================================
......
...@@ -39,9 +39,6 @@ class Queue(CoreObject): ...@@ -39,9 +39,6 @@ class Queue(CoreObject):
#=========================================================================== #===========================================================================
def __init__(self, id='', name='', capacity=1, isDummy=False, schedulingRule="FIFO", level=None, gatherWipStat=False, inputsDict={}): def __init__(self, id='', name='', capacity=1, isDummy=False, schedulingRule="FIFO", level=None, gatherWipStat=False, inputsDict={}):
self.type="Queue" # String that shows the type of object self.type="Queue" # String that shows the type of object
if inputsDict:
CoreObject.__init__(self,inputsDict=inputsDict)
else:
CoreObject.__init__(self, id, name) CoreObject.__init__(self, id, name)
# used for the routing of the entities # used for the routing of the entities
# holds the capacity of the Queue # holds the capacity of the Queue
...@@ -52,7 +49,7 @@ class Queue(CoreObject): ...@@ -52,7 +49,7 @@ class Queue(CoreObject):
# No failures are considered for the Queue # No failures are considered for the Queue
self.isDummy=isDummy #Boolean that shows if it is the dummy first Queue self.isDummy=bool(int(isDummy)) #Boolean that shows if it is the dummy first Queue
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [schedulingRule] SRlist = [schedulingRule]
...@@ -73,43 +70,8 @@ class Queue(CoreObject): ...@@ -73,43 +70,8 @@ class Queue(CoreObject):
if level: if level:
assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue" assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue"
self.level=level self.level=level
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, inputsDict):
CoreObject.parseInputs(self, inputsDict)
from Globals import G from Globals import G
G.QueueList.append(self) G.QueueList.append(self)
# holds the capacity of the Queue
capacity=int(inputsDict.get('capacity') or 1)
if capacity>0:
self.capacity=capacity
else:
self.capacity=float("inf")
self.isDummy=bool(int(inputsDict.get('isDummy') or 0)) #Boolean that shows if it is the dummy first Queue
self.schedulingRule=inputsDict.get('schedulingRule', 'FIFO') #the scheduling rule that the Queue follows
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [self.schedulingRule]
if self.schedulingRule.startswith("MC"): # if the first criterion is MC aka multiple criteria
SRlist = self.schedulingRule.split("-") # split the string of the criteria (delimiter -)
self.schedulingRule=SRlist.pop(0) # take the first criterion of the list
self.multipleCriterionList=SRlist # hold the criteria list in the property multipleCriterionList
for scheduling_rule in SRlist:
if scheduling_rule not in self.getSupportedSchedulingRules():
raise ValueError("Unknown scheduling rule %s for %s" %
(scheduling_rule, id))
self.gatherWipStat=bool(int(inputsDict.get('gatherWipStat', 0)))
# Will be populated by an event generator
self.wip_stat_list = []
level=int(inputsDict.get('level') or 1)
# trigger level for the reallocation of operators
if level:
assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue"
self.level=level
@staticmethod @staticmethod
def getSupportedSchedulingRules(): def getSupportedSchedulingRules():
......
...@@ -98,6 +98,8 @@ class Source(CoreObject): ...@@ -98,6 +98,8 @@ class Source(CoreObject):
self.item=Globals.getClassFromName(entity) #the type of object that the Source will generate self.item=Globals.getClassFromName(entity) #the type of object that the Source will generate
self.scheduledEntities=[] # list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter] self.scheduledEntities=[] # list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter]
from Globals import G
G.SourceList.append(self)
#=========================================================================== #===========================================================================
# The initialize method of the Source class # The initialize method of the Source class
......
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