Commit 9bf2a5a0 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

Topology37-results in agreement with Ulbranch results prior to the changes in...

Topology37-results in agreement with Ulbranch results prior to the changes in the entity-route definition. OrderDecomposition corrected
parent 230909cb
......@@ -94,17 +94,9 @@ class OrderDecomposition(CoreObject):
# dummy variables that help prioritize 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
# print 'time', now()
# for obj in activeObject.previous:
# print 'orderDecompose previous', obj.id, obj.objName
# loop through the possible givers to see which have to dispose and which is the one blocked for longer
for object in activeObject.previous:
# print 'object in previous', object.objName
# print 'has to dispose', object.haveToDispose(activeObject)
# if object.receiver!=None:
# print 'has receiver', object.receiver.objName
# else:
# print 'has no receiver'
if(object.haveToDispose(activeObject) and object.receiver==self):
isRequested=True # if the predecessor objects have entities to dispose of
if(object.downTimeInTryingToReleaseCurrentEntity>0):# and the predecessor has been down while trying to give away the Entity
......@@ -117,9 +109,7 @@ class OrderDecomposition(CoreObject):
activeObject.giver=object # the object to deliver the Entity to the activeObject is set to the ith member of the previous list
maxTimeWaiting=timeWaiting
# in the next loops, check the other predecessors in the previous list
# print 'orderDecompose giver:', activeObject.giver.objName , activeObject.giver.id
# print 'canAcceptAndIsRequested returns', activeObject.Up and isRequested
# print ''
return activeObject.Up and isRequested
# =======================================================================
......@@ -127,7 +117,9 @@ class OrderDecomposition(CoreObject):
# an entity to the following object
# =======================================================================
def haveToDispose(self, callerObject=None):
activeObject = self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
thecaller = callerObject
#if there is no Entity return False
if len(activeObjectQueue)==0:
return False
......@@ -136,11 +128,30 @@ class OrderDecomposition(CoreObject):
import Globals
# update the next list of the object
nextObjectIds=activeEntity.remainingRoute[0].get('stationIdsList',[])
nextObjects = []
for nextObjectId in nextObjectIds:
self.next.append(Globals.findObjectById(nextObjectId))
# self.next = Globals.findObjectById(activeEntity.remainingRoute[0].get('stationIdsList',[]))
nextObject = Globals.findObjectById(nextObjectId)
nextObjects.append(nextObject)
self.next=nextObjects
# find the suitable receiver
self.receiver = self.updateReceiverObject()
#if we have only one possible receiver just check if the Queue holds one or more entities
if(len(activeObject.next)==1 or callerObject==None):
activeObject.receiver=activeObject.next[0]
return len(activeObjectQueue)>0\
and thecaller==activeObject.receiver
#give the entity to the possible receiver that is waiting for the most time.
#plant does not do this in every occasion!
maxTimeWaiting=0
# loop through the object in the successor list
for object in activeObject.next:
if(object.canAccept()): # if the object can accept
timeWaiting=now()-object.timeLastEntityLeft # compare the time that it has been waiting
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):# with the others'
maxTimeWaiting=timeWaiting
self.receiver=object # and update the receiver to the index of this object
# self.receiver=Globals.findObjectById(activeEntity.remainingRoute[0][0]) #read the next station
#return True if the OrderDecomposition in the state of disposing and the caller is the receiver
return self.Up and (callerObject is self.receiver)
......@@ -195,14 +206,8 @@ class OrderDecomposition(CoreObject):
for routeentity in JSONRoute: # for each 'step' dictionary in the JSONRoute
stepNumber=int(routeentity.get('stepNumber', '0')) # get the stepNumber
routeentity.pop(str(stepNumber),None) # remove the stepNumber key
# nextId=routeentity.get('stationId', 'not found') # the stationId
# processingTime=routeentity['processingTime'] # and the 'processingTime' dictionary
# distributionType=processingTime.get('distributionType', 'not found')# and from that dictionary
# mean=float(processingTime.get('mean', 'not found')) # get the 'mean'
# route[stepNumber]=[nextId, mean] # finally add the 'nextId' and 'mean'
# # to the job route
route[stepNumber]=routeEntity
# routeentity.pop(str(stepNumber),None) # remove the stepNumber key
route[stepNumber]=routeentity
# keep a reference of all extra properties passed to the job
extraPropertyDict = {}
......@@ -228,7 +233,7 @@ class OrderDecomposition(CoreObject):
break
if exitId:
# route.append([exitId, 0])
route.append({'stationIdsList':str([exitId]),\
route.append({'stationIdsList':[str(exitId)],\
'processingTime':{}})
# initiate the OrderComponent
......@@ -241,6 +246,7 @@ class OrderDecomposition(CoreObject):
orderDate=self.orderToBeDecomposed.orderDate, \
extraPropertyDict=extraPropertyDict,\
isCritical=self.orderToBeDecomposed.isCritical)
# check the componentType of the component and accordingly add to the corresponding list of the parent order
if OC.componentType == 'Basic':
self.orderToBeDecomposed.basicComponentsList.append(OC)
......
......@@ -4,35 +4,43 @@
"extraPropertyDict": {
"route": [
{
"stationIdsList": [
"OD0"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"stationId": "OD0",
"stepNumber": "0"
},
{
"stationIdsList": [
"Q1"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"stationId": "Q1",
"stepNumber": "1"
},
{
"stationIdsList": [
"M1"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
},
"stationId": "M1",
"stepNumber": "2"
},
{
"stationIdsList": [
"E1"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"stationId": "E1",
"stepNumber": "3"
}
],
......@@ -70,35 +78,43 @@
"extraPropertyDict": {
"route": [
{
"stationIdsList": [
"OD0"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"stationId": "OD0",
"stepNumber": "0"
},
{
"stationIdsList": [
"Q2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"stationId": "Q2",
"stepNumber": "1"
},
{
"stationIdsList": [
"M2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
},
"stationId": "M2",
"stepNumber": "2"
},
{
"stationIdsList": [
"E1"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0"
},
"stationId": "E1",
"stepNumber": "3"
}
],
......
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