Example #1
0
 def __init__(self):
     Router.__init__(self)
     # boolean flag to check whether the Router should perform sorting on operators and on pendingEntities
     self.entitiesWithOccupiedReceivers=[]        # list of entities that have no available receivers
     self.conflictingEntities=[]                  # entities with conflictingReceivers
     self.conflictingOperators=[]                 # list with the operators that have candidateEntity with conflicting candidateReceivers
     self.occupiedReceivers=[]                    # occupied candidateReceivers of a candidateEntity
 def initialize(self):
     Router.initialize(self)        
     self.allocation=False
     self.waitEndProcess=False
     self.pendingQueues=[]
     self.pendingMachines=[]
     self.pendingObjects=[]
Example #3
0
 def initialize(self):
     Router.initialize(self)
     self.allocation = False
     self.waitEndProcess = False
     self.pendingQueues = []
     self.pendingMachines = []
     self.previousSolution = {}
 def initialize(self):
     Router.initialize(self)        
     self.allocation=False
     self.waitEndProcess=False
     self.pendingQueues=[]
     self.pendingMachines=[]
     self.previousSolution={}
     self.solutionList=[]
 def __init__(self,sorting=False, outputSolutions=True):
     Router.__init__(self)
     # Flag used to notify the need for re-allocation of skilled operators to operatorPools
     self.allocation=False
     # Flag used to notify the need to wait for endedLastProcessing signal
     waitEndProcess=False
     self.outputSolutions=outputSolutions
     self.id='SkilledRouter01'
Example #6
0
 def initialize(self):
     Router.initialize(self)
     # list that holds all the objects that can receive
     self.pendingObjects=[]
     self.entitiesWithOccupiedReceivers=[]
     self.conflictingEntities=[]                  # entities with conflictingReceivers
     self.conflictingOperators=[]                 # list with the operators that have candidateEntity with conflicting candidateReceivers
     self.occupiedReceivers=[]                    # occupied candidateReceivers of a candidateEntity
Example #7
0
 def exitActions(self):
     # reset the candidateEntities of the operators
     for operator in self.candidateOperators:
         operator.candidateEntity=None
     del self.pendingObjects[:]
     del self.conflictingOperators[:]
     del self.conflictingEntities[:]
     del self.occupiedReceivers[:]
     del self.entitiesWithOccupiedReceivers[:]
     Router.exitActions(self)
 def initialize(self):
     Router.initialize(self)
     # list that holds all the objects that can receive
     self.pendingObjects=[]
     self.calledOperator=[]
     # list of the operators that may handle a machine at the current simulation time
     self.candidateOperators=[]
     # list of criteria
     self.multipleCriterionList=[]
     # TODO: find out which must be the default for the scheduling Rule
     self.schedulingRule='WT'
Example #9
0
 def __init__(self,id='SkilledRouter01',name='SkilledRouter01',sorting=False,outputSolutions=True,
              weightFactors=[2, 1, 0, 2, 0, 1], tool={},checkCondition=False,**kw):
     Router.__init__(self)
     # Flag used to notify the need for re-allocation of skilled operators to operatorPools
     self.allocation=False
     # Flag used to notify the need to wait for endedLastProcessing signal
     waitEndProcess=False
     self.outputSolutions=outputSolutions
     self.id=id
     self.name=name
     self.weightFactors=weightFactors
     self.tool=tool
     self.checkCondition=checkCondition
Example #10
0
 def initialize(self):
     MachineJobShop.initialize(self)
     self.type="MachineManagedJob"
     #create an empty Operator Pool. This will be updated by canAcceptAndIsRequested
     id = self.id+'_OP'
     name=self.objName+'_operatorPool'
     self.operatorPool=OperatorPool(id, name, operatorsList=[])
     self.operatorPool.initialize()
     self.operatorPool.operators=[]
     #create a Broker
     self.broker = Broker(self)
     activate(self.broker,self.broker.run())
     #create a Router
     from Globals import G
     if len(G.RoutersList)==0:
         self.router=Router()
         activate(self.router,self.router.run())
         G.RoutersList.append(self.router)
     # otherwise set the already existing router as the machines Router
     else:
         self.router=G.RoutersList[0]
     # holds the Entity that is to be obtained and will be updated by canAcceptAndIsRequested
     self.entityToGet=None
 def exitActions(self):
     Router.exitActions(self)
     self.allocation=False
     self.waitEndProcess=False
Example #12
0
 def __init__(self,sorting=False):
     Router.__init__(self)
     self.multipleCriterionList=[]
     self.schedulingRule='WT'
     # boolean flag to check whether the Router should perform sorting on operators and on pendingEntities
     self.sorting=sorting
Example #13
0
 def exitActions(self):
     Router.exitActions(self)
     self.allocation=False
     self.waitEndProcess=False
Example #14
0
 def __init__(self,sorting=False):
     Router.__init__(self)
     # Flag used to notify the need for re-allocation of skilled operators to operatorPools
     self.allocation=False
     # Flag used to notify the need to wait for endedLastProcessing signal
     waitEndProcess=False
Example #15
0
 def __init__(self, sorting=False):
     Router.__init__(self)
     # Flag used to notify the need for re-allocation of skilled operators to operatorPools
     self.allocation = False
     # Flag used to notify the need to wait for endedLastProcessing signal
     waitEndProcess = False
Example #16
0
class MachineManagedJob(MachineJobShop):

    # =======================================================================
    # initialise the MachineManagedJob
    # =======================================================================
    def initialize(self):
        MachineJobShop.initialize(self)
        self.type="MachineManagedJob"
        #create an empty Operator Pool. This will be updated by canAcceptAndIsRequested
        id = self.id+'_OP'
        name=self.objName+'_operatorPool'
        self.operatorPool=OperatorPool(id, name, operatorsList=[])
        self.operatorPool.initialize()
        self.operatorPool.operators=[]
        #create a Broker
        self.broker = Broker(self)
        activate(self.broker,self.broker.run())
        #create a Router
        from Globals import G
        if len(G.RoutersList)==0:
            self.router=Router()
            activate(self.router,self.router.run())
            G.RoutersList.append(self.router)
        # otherwise set the already existing router as the machines Router
        else:
            self.router=G.RoutersList[0]
        # holds the Entity that is to be obtained and will be updated by canAcceptAndIsRequested
        self.entityToGet=None

        
    # =======================================================================
    # checks if the Queue can accept an entity       
    # it checks also the next station of the Entity 
    # and returns true only if the active object is the next station
    # ======================================================================= 
    def canAccept(self, callerObject=None):
        activeObject=self.getActiveObject()
        activeObjectQueue=activeObject.getActiveObjectQueue()
        thecaller=callerObject
        if (thecaller!=None):
            #check it the caller object holds an Entity that requests for current object
            if len(thecaller.getActiveObjectQueue())>0:
                # TODO: make sure that the first entity of the callerObject is to be disposed
                activeEntity=thecaller.getActiveObjectQueue()[0]
                # if the machine's Id is in the list of the entity's next stations
                if activeObject.id in activeEntity.remainingRoute[0].get('stationIdsList',[]):
                    #return according to the state of the Queue
                    return len(activeObject.getActiveObjectQueue())<activeObject.capacity\
                        and activeObject.Up
        return False

    # =======================================================================
    # checks if the Machine can accept an entity and there is an entity in 
    # some possible giver waiting for it
    # also updates the giver to the one that is to be taken
    # =======================================================================
    def canAcceptAndIsRequested(self):
        # get active and giver objects
        activeObject=self.getActiveObject()
        activeObjectQueue=self.getActiveObjectQueue()
        giverObject=self.getGiverObject()
    
        # dummy variables that help prioritise the objects requesting to give objects to the Machine (activeObject)
        isRequested=False                                           # is requested is dummyVariable checking if it is requested to accept an item
        maxTimeWaiting=0                                            # dummy variable counting the time a predecessor is blocked
        
        # loop through the possible givers to see which have to dispose and which is the one blocked for longer
        for object in activeObject.previous:
            if(object.haveToDispose(activeObject) and object.receiver==self):# and not object.exitIsAssigned()):
                isRequested=True                                    # if the possible giver has entities to dispose of
                if(object.downTimeInTryingToReleaseCurrentEntity>0):# and the possible giver has been down while trying to give away the Entity
                    timeWaiting=now()-object.timeLastFailureEnded   # the timeWaiting dummy variable counts the time end of the last failure of the giver object
                else:
                    timeWaiting=now()-object.timeLastEntityEnded    # in any other case, it holds the time since the end of the Entity processing
                
                #if more than one possible givers have to dispose take the part from the one that is blocked longer
                if(timeWaiting>=maxTimeWaiting): 
                    activeObject.giver=object                 # set the giver
                    maxTimeWaiting=timeWaiting    
        
        if (activeObject.operatorPool!='None' and (any(type=='Load' for type in activeObject.multOperationTypeList)\
                                                or any(type=='Setup' for type in activeObject.multOperationTypeList))):
            if isRequested:
                # TODO:  check whether this entity is the one to be hand in
                #     to be used in operatorPreemptive
                activeObject.requestingEntity=activeObject.giver.getActiveObjectQueue()[0]
                # TODO:  update the object requesting the operator
                activeObject.operatorPool.requestingObject=activeObject.giver
                # TODO:  update the last object calling the operatorPool
                activeObject.operatorPool.receivingObject=activeObject
                              
                if activeObject.Up and len(activeObjectQueue)<activeObject.capacity\
                    and self.checkOperator()\
                    and not activeObject.giver.exitIsAssigned():
                    activeObject.giver.assignExit()
                    # if the activeObject is not in manager's activeCallersList of the entityToGet
                    if self not in activeObject.giver.getActiveObjectQueue()[0].manager.activeCallersList:
                        # append it to the activeCallerList of the manager of the entity to be received
                        activeObject.giver.getActiveObjectQueue()[0].manager.activeCallersList.append(self)
                        # update entityToGet
                        self.entityToGet=activeObject.giver.getActiveObjectQueue()[0]
                    #make the operators List so that it holds only the manager of the current order
                    activeObject.operatorPool.operators=[activeObject.giver.getActiveObjectQueue()[0].manager]
#                     # set the variable operatorAssignedTo to activeObject, the operator is then blocked
#                     activeObject.operatorPool.operators[0].operatorAssignedTo=activeObject
#                     # TESTING
#                     print now(), activeObject.operatorPool.operators[0].objName, 'got assigned to', activeObject.id
                    # read the load time of the machine
                    self.readLoadTime()
                    return True
            else:
                return False
        else:
            # the operator doesn't have to be present for the loading of the machine as the load operation
            # is not assigned to operators
            if activeObject.Up and len(activeObjectQueue)<activeObject.capacity and isRequested:
                # update entityToGet
                self.entityToGet=self.giver.getActiveObjectQueue()[0]
            return activeObject.Up and len(activeObjectQueue)<activeObject.capacity and isRequested 

    # =======================================================================
    # to be called by canAcceptAndIsRequested and check for the operator
    # =======================================================================    
    def checkOperator(self):
        if self.giver.getActiveObjectQueue()[0].manager:
            manager=self.giver.getActiveObjectQueue()[0].manager
#             print ''
#             print 'Entity',self.giver.getActiveObjectQueue()[0].id
#             print 'manager',manager.id
            return manager.checkIfResourceIsAvailable()
        else:
            return True    
        
    # =======================================================================
    #             identifies the Entity to be obtained so that 
    #            getEntity gives it to removeEntity as argument
    # =======================================================================    
    def identifyEntityToGet(self):
        # ToDecide
        # maybe we should work this way in all CoreObjects???
        return self.entityToGet
    
    # =======================================================================
    # checks if the object is ready to receive an Entity
    # =======================================================================    
    def isReadyToGet(self):
        # check if the entity that is about to be obtained has a manager (this should be true for this object)
        if self.entityToGet.manager:
            manager=self.entityToGet.manager
            if len(manager.activeCallersList)>0:
                manager.sortEntities()      # sort the callers of the manager to be used for scheduling rules
                # return true if the manager is available
                return manager.checkIfResourceIsAvailable()
        else:
            return True
        

    # =======================================================================
    #                   prepare the machine to be released
    # =======================================================================
    def releaseOperator(self):
        self.outputTrace(self.currentOperator.objName, "released from "+ self.objName)
#         # TESTING
#         print now(), self.id, 'will release operator', self.operatorPool.operators[0].objName
        # set the flag operatorAssignedTo to None
        self.operatorPool.operators[0].operatorAssignedTo=None
        self.broker.invokeBroker()
        self.toBeOperated = False