comments and code clean-up

parent 0555f714
{
"_class": "Dream.Simulation",
"edges": {},
"general": {
"_class": "Dream.Configuration",
"numberOfReplications": "8",
"maxSimTime": "-1",
"trace": "Yes",
"confidenceLevel": "0.95"
},
"nodes": {
"Q0": {
"_class": "Dream.QueueManagedJob",
"name": "StartQueue",
"isDummy": "0",
"schedulingRule": "Priority",
"capacity": "-1",
"wip": [
{
"_class": "Dream.Order",
"name": "Order1",
"id": "O1",
"manager": "OP1",
"priority": "1",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"Q0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"CAD1","CAD2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
},
"setupTime": {
"setupDistribution": "Fixed",
"setupMean": "0.5"
}
}
],
"componentsList": [
{
"_class": "Dream.OrderComponent",
"id": "C1O1",
"name": "Component1 from Order1",
"componentType": "Basic",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.5"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.5"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.5"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.OrderComponent",
"id": "C2O1",
"name": "Component2 from Order1",
"componentType": "Secondary",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.6"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.4"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.6"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.Mould",
"id": "M1O1",
"name": "Mould1 from Order1",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"MA1","MA2","MA3"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1"
}
},
{
"stepNumber": "1",
"stationIdsList": [
"QIM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"IM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.5"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"E1"
]
}
]
}
]
},
{
"_class": "Dream.Order",
"name": "Order2",
"id": "O2",
"manager": "OP2",
"priority": "2",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"Q0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"CAD1","CAD2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime": {
"setupDistribution": "Fixed",
"setupMean": "0.7"
}
}
],
"componentsList": [
{
"_class": "Dream.OrderComponent",
"id": "C1O2",
"name": "Component1 from Order2",
"componentType": "Basic",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.3"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "1.2"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.9"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.OrderComponent",
"id": "C2O2",
"name": "Component2 from Order2",
"componentType": "Secondary",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.8"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.2"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.Mould",
"id": "M1O2",
"name": "Mould1 from Order2",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"MA1","MA2","MA3"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stepNumber": "1",
"stationIdsList": [
"QIM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"IM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.7"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"E1"
]
}
]
}
]
},
{
"_class": "Dream.Order",
"name": "Order3",
"id": "O3",
"manager": "OP3",
"priority": "2",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"Q0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"CAD1","CAD2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime": {
"setupDistribution": "Fixed",
"setupMean": "0.7"
}
}
],
"componentsList": [
{
"_class": "Dream.OrderComponent",
"id": "C1O3",
"name": "Component1 from Order3",
"componentType": "Basic",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.3"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "1.2"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.9"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.OrderComponent",
"id": "C2O3",
"name": "Component2 from Order3",
"componentType": "Secondary",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.8"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.2"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.Mould",
"id": "M1O3",
"name": "Mould1 from Order3",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"MA1","MA2","MA3"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stepNumber": "1",
"stationIdsList": [
"QIM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"IM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.7"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"E1"
]
}
]
}
]
},
{
"_class": "Dream.Order",
"name": "Order4",
"id": "O4",
"manager": "OP1",
"priority": "2",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"Q0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"CAD1","CAD2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime": {
"setupDistribution": "Fixed",
"setupMean": "0.7"
}
}
],
"componentsList": [
{
"_class": "Dream.OrderComponent",
"id": "C1O4",
"name": "Component1 from Order4",
"componentType": "Basic",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.3"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "3"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "1.2"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.9"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.OrderComponent",
"id": "C2O4",
"name": "Component2 from Order4",
"componentType": "Secondary",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.8"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.2"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.OrderComponent",
"id": "C3O4",
"name": "Component3 from Order4",
"componentType": "Secondary",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"OD0"
]
},
{
"stepNumber": "1",
"stationIdsList": [
"QCAM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"CAM1","CAM2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.8"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.2"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"QMILL"
]
},
{
"stepNumber": "4",
"stationIdsList": [
"MILL1","MILL2"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "5",
"stationIdsList": [
"QEDM"
]
},
{
"stepNumber": "6",
"stationIdsList": [
"EDM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "1.4"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.3"
}
},
{
"stepNumber": "7",
"stationIdsList": [
"AB1"
]
},
{
"stepNumber": "8",
"stationIdsList": [
"MA1","MA2","MA3"
]
}
]
},
{
"_class": "Dream.Mould",
"id": "M1O4",
"name": "Mould1 from Order4",
"route": [
{
"stepNumber": "0",
"stationIdsList": [
"MA1","MA2","MA3"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "2"
}
},
{
"stepNumber": "1",
"stationIdsList": [
"QIM"
]
},
{
"stepNumber": "2",
"stationIdsList": [
"IM"
],
"processingTime": {
"distributionType": "Fixed",
"mean": "0.7"
},
"setupTime":{
"setupDistribution": "Fixed",
"setupMean": "0.1"
}
},
{
"stepNumber": "3",
"stationIdsList": [
"E1"
]
}
]
}
]
}
]
},
"CAD1": {
"_class": "Dream.MachineManagedJob",
"name": "CAD Design 1",
"operationType": "MT-Load-Setup-Processing"
},
"CAD2": {
"_class": "Dream.MachineManagedJob",
"name": "CAD Design 2",
"operationType": "MT-Load-Setup-Processing"
},
"OD0": {
"_class": "Dream.OrderDecomposition",
"name": "Order Decomposition"
},
"QCAM": {
"_class": "Dream.ConditionalBuffer",
"name": "Queue CAM",
"isDummy": "0",
"schedulingRule": "Priority",
"capacity": "-1"
},
"CAM1": {
"_class": "Dream.MachineManagedJob",
"name": "CAM Design 1",
"operationType": "MT-Load-Setup-Processing"
},
"CAM2": {
"_class": "Dream.MachineManagedJob",
"name": "CAM Design 2",
"operationType": "MT-Load-Setup-Processing"
},
"QMILL": {
"_class": "Dream.QueueManagedJob",
"name": "Queue Milling",
"isDummy": "0",
"schedulingRule": "Priority",
"capacity": "-1"
},
"MILL1": {
"_class": "Dream.MachineManagedJob",
"name": "Milling 1",
"operationType": "MT-Load-Setup-Processing"
},
"MILL2": {
"_class": "Dream.MachineManagedJob",
"name": "Milling 2",
"operationType": "MT-Load-Setup-Processing"
},
"QEDM": {
"_class": "Dream.QueueManagedJob",
"name": "Queue EDM",
"isDummy": "0",
"schedulingRule": "Priority",
"capacity": "-1"
},
"EDM": {
"_class": "Dream.MachineManagedJob",
"name": "EDM",
"operationType": "MT-Load-Setup-Processing"
},
"AB1": {
"_class": "Dream.MouldAssemblyBuffer",
"id": "AB1",
"name": "Assembly Buffer",
"schedulingRule": "Priority",
"isDummy": "0",
"capacity": "-1"
},
"MA1": {
"_class": "Dream.MouldAssembly",
"id": "MA1",
"name": "Assembly 1",
"operationType": "MT-Load-Setup-Processing"
},
"MA2": {
"_class": "Dream.MouldAssembly",
"id": "MA2",
"name": "Assembly 2",
"operationType": "MT-Load-Setup-Processing"
},
"MA3": {
"_class": "Dream.MouldAssembly",
"id": "MA3",
"name": "Assembly 3",
"operationType": "MT-Load-Setup-Processing"
},
"QIM": {
"_class": "Dream.QueueManagedJob",
"name": "Queue Mould Injection",
"isDummy": "0",
"schedulingRule": "Priority",
"capacity": "-1"
},
"IM": {
"_class": "Dream.MachineManagedJob",
"name": "Mould Injection",
"operationType": "MT-Load-Setup-Processing"
},
"E1": {
"_class": "Dream.ExitJobShop",
"name": "Exit"
},
"OP1": {
"_class": "Dream.OperatorManagedJob",
"capacity": "1",
"name": "Operator1",
"schedulingRule": "Priority"
},
"OP2": {
"_class": "Dream.OperatorManagedJob",
"capacity": "1",
"name": "Operator2",
"schedulingRule": "Priority"
},
"OP3": {
"_class": "Dream.OperatorManagedJob",
"capacity": "1",
"name": "Operator3",
"schedulingRule": "Priority"
}
}
}
\ No newline at end of file
......@@ -40,11 +40,6 @@ class Operator(Repairman): # XXX isn't it the other way around ?
self.type="Operator"
self.activeCallersList=[] # the list of object that request the operator
self.schedulingRule=schedulingRule #the scheduling rule that the Queue follows
# #=======================================================================
# # TESTING
# print now(), self.id, 'schedulingRule'
# print self.schedulingRule
# #=======================================================================
self.multipleCriterionList=[] #list with the criteria used to sort the Entities in the Queue
SRlist = [schedulingRule]
if schedulingRule.startswith("MC"): # if the first criterion is MC aka multiple criteria
......
......@@ -89,66 +89,57 @@ class Router(ObjectInterruption):
#===================================================================
# # TESTING
# print ' the called operators are ', [str(operator.id) for operator in self.calledOperators]
# print ' from callers ', [[str(x.id) for x in operator.activeCallersList] for operator in self.calledOperators]
# print ' for entity ', [[str(x.giver.getActiveObjectQueue()[0].id)for x in operator.activeCallersList] for operator in self.calledOperators]
# print ' (calledOperators, activeCallers, callerEntities): ', [(str(operator.id),\
# [str(x.id) for x in operator.activeCallersList],\
# [str(x.giver.getActiveObjectQueue()[0].id)for x in operator.activeCallersList])\
# for operator in self.calledOperators]
#===================================================================
# find the operators that can start working now even if they are not called
self.findCandidateOperators()
#===================================================================
# # TESTING
# print ' {} the candidateOperators ',
# print [str(op.id) for op in self.candidateOperators]
#===================================================================
# sort the pendingEntities list
self.sortPendingEntities()
#===================================================================
# # TESTING
# if G.pendingEntities:
# print ' {} the pending entities that can proceed are: ',
# print ' {} the pending entities that can proceed are: ',
# print [str(entity.id) for entity in G.pendingEntities if entity.canProceed]
# if self.candidateOperators:
# print ' {} the candidate operators are: ',
# print [str(candidate.id) for candidate in self.candidateOperators]
#===================================================================
# find the operators candidateEntities
self.findCandidateEntities()
# find the entity that will occupy the resource, and the station that will receive it (if any available)
self.findCandidateReceivers()
#===================================================================
# # TESTING
# print ' after findReceivers',
# print ' {} candidate entities for each candidateOperator ',
# print [(str(operator.id),[str(candidateEntity.id) for candidateEntity in operator.candidateEntities],)\
# for operator in self.candidateOperators]
# print 'after find receivers'
# print [str(op.id) for op in self.candidateOperators if op.candidateEntity.candidateReceiver]
# print [(op.id, op.candidateEntity.id, op.candidateEntity.candidateReceiver.id)\
# for op in self.candidateOperators if op.candidateEntity.candidateReceiver]
#===================================================================
# sort the givers for the operators that will process the entities
self.sortGiverQueue()
# find the entity that will occupy the resource, and the station that will receive it (if any available)
self.findCandidateReceivers()
#===================================================================
# # TESTING
# print 'after sortGiverQueue'
# print [str(op.id) for op in self.candidateOperators if op.candidateEntity.candidateReceiver]
# print [(op.id, op.candidateEntity.id, op.candidateEntity.candidateReceiver.id)\
# print ' {} (candidateOperator, candidateEntity, candidateReceiver) ',
# print [(str(op.id), str(op.candidateEntity.id), str(op.candidateEntity.candidateReceiver.id))\
# for op in self.candidateOperators if op.candidateEntity.candidateReceiver]
#===================================================================
# sort the givers for the operators that will process the entities
self.sortGiverQueue()
# for all the operators that are requested
for operator in self.calledOperators:
priorityObject=None
#===============================================================
# # TESTING
# print ' calledOperator prioritising',operator.id
# if operator.candidateEntity:
# if operator.candidateEntity.candidateReceiver:
# print ' its candidateReceiver',operator.candidateEntity.candidateReceiver.id
# print ' its activeCallers',[str(x.id) for x in operator.activeCallersList]
#===============================================================
# check if the candidateReceivers are inPositionToGet and if they are already called
try:
......@@ -156,23 +147,19 @@ class Router(ObjectInterruption):
and operator.candidateEntity.candidateReceiver in self.pendingObjects )
except:
receiverIsActive=True
#===============================================================
# # TESTING
# print ' calledOperator', operator.id,
# print 'will receive?',operator.checkIfResourceIsAvailable() and receiverIsActive
#===============================================================
# check if the candidateOperators are available, if the are requested and reside in the pendingObjects list
if operator.checkIfResourceIsAvailable() and \
receiverIsActive:
#===========================================================
# # TESTING
# print now(), 'the active callers of', operator.objName, 'before sorting are ',
# print [str(caller.id) for caller in operator.activeCallersList]
#===========================================================
# sort the activeCallersList of the operator
operator.sortEntities()
#===========================================================
# # TESTING
# print now(), 'the active callers of', operator.objName, 'after sorting are ',
# print [str(caller.id) for caller in operator.activeCallersList]
#===========================================================
# find the activeCaller that has priority
priorityObject=next(x for x in operator.activeCallersList if x in self.pendingObjects)
......@@ -186,10 +173,6 @@ class Router(ObjectInterruption):
# assign an operator to the priorityObject
operator.operatorAssignedTo=priorityObject
#=======================================================
# # TESTING
# print now(), operator.objName, 'got assigned to', priorityObject.id
#=======================================================
# and let it proceed withGetEntity
priorityObject.canProceedWithGetEntity=True
......@@ -399,16 +382,7 @@ class Router(ObjectInterruption):
self.candidateOperators.sort(key=lambda x: x.totalWorkingTime)
if operatorsWithOneOption:
self.candidateOperators.sort(key=lambda x: x in operatorsWithOneOption, reverse=True) # sort according to the number of options
#===================================================================
# # TESTING
# if self.candidateOperators:
# print ' findEntities',
# print [(str(operator.id),[str(candidateEntity.id) for candidateEntity in operator.candidateEntities])\
# for operator in self.candidateOperators]
#===================================================================
#=======================================================================
# Find candidate entities and their receivers
# TODO: if there is a critical entity, its manager should be served first
......@@ -416,61 +390,71 @@ class Router(ObjectInterruption):
#=======================================================================
def findCandidateReceivers(self):
# initialise local variables occupiedReceivers and entitiesWithOccupiedReceivers
occupiedReceivers=[] # occupied candidateReceivers of a candidateEntity
entitiesWithOccupiedReceivers=[] # list of entities that have no available receivers
occupiedReceivers=[] # occupied candidateReceivers of a candidateEntity
entitiesWithOccupiedReceivers=[] # list of entities that have no available receivers
# finally we have to sort before giving the entities to the operators
# If there is an entity which must have priority then it should be assigned first
def findCandidateEntity():
return next(x for x in operator.candidateEntities if not x in entitiesWithOccupiedReceivers)
def findCandidateReceiver():
# initiate the local list variable available receivers
availableReceivers=[x for x in operator.candidateEntity.candidateReceivers\
if not x in occupiedReceivers]
# and pick the object that is waiting for the most time
if availableReceivers:
# TODO: must find the receiver that waits the most
maxTimeWaiting=0
for object in availableReceivers:
timeWaiting=now()-object.timeLastEntityLeft
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
maxTimeWaiting=timeWaiting
availableReceiver=object
# operator.candidateEntity.candidateReceiver=availableReceiver
occupiedReceivers.append(availableReceiver)
# if there is no available receiver add the entity to the entitiesWithOccupiedReceivers list
else:
entitiesWithOccupiedReceivers.append(operator.candidateEntity)
availableReceiver=None
# operator.candidateEntity.candidateReceiver=None
return availableReceiver
for operator in [x for x in self.candidateOperators if x.candidateEntities]:
operator.candidateEntity=operator.candidateEntities[0]
#===================================================================
# TESTING
# print ' first assignment of candidateEntity'
# print [(str(x.id), str(x.candidateEntity.id)) for x in self.candidateOperators if x.candidateEntity]
#===================================================================
# TODO: sorting again after choosing candidateEntity
self.sortOperators()
# for the candidateOperators that do have candidateEntities pick a candidateEntity
for operator in [x for x in self.candidateOperators if x.candidateEntities]:
# find the first available entity that has no occupied receivers
availableEntity=next(x for x in operator.candidateEntities if not x in entitiesWithOccupiedReceivers)
if availableEntity:
operator.candidateEntity=availableEntity
# initiate the local list variable available receivers
availableReceivers=[x for x in operator.candidateEntity.candidateReceivers\
if not x in occupiedReceivers]
# and pick the object that is waiting for the most time
if availableReceivers:
# TODO: must find the receiver that waits the most
maxTimeWaiting=0
for object in availableReceivers:
timeWaiting=now()-object.timeLastEntityLeft
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
maxTimeWaiting=timeWaiting
availableReceiver=object
operator.candidateEntity.candidateReceiver=availableReceiver
occupiedReceivers.append(availableReceiver)
# if there is no available receiver add the entity to the entitiesWithOccupiedReceivers list
else:
entitiesWithOccupiedReceivers.append(availableEntity)
operator.candidateEntity.candidateReceiver=None
# # TODO: sorting again after choosing candidateEntity
# self.sortOperators()
#===================================================================
# # TESTING
# print ' findReceivers',
# print [(str(operator.id),[str(candidateEntity.id) for candidateEntity in operator.candidateEntities])\
# for operator in self.candidateOperators]
#===================================================================
# availableEntity=next(x for x in operator.candidateEntities if not x in entitiesWithOccupiedReceivers)
operator.candidateEntity=findCandidateEntity()
if operator.candidateEntity:
operator.candidateEntity.candidateReceiver=findCandidateReceiver()
# # initiate the local list variable available receivers
# availableReceivers=[x for x in operator.candidateEntity.candidateReceivers\
# if not x in occupiedReceivers]
# # and pick the object that is waiting for the most time
# if availableReceivers:
# # TODO: must find the receiver that waits the most
# maxTimeWaiting=0
# for object in availableReceivers:
# timeWaiting=now()-object.timeLastEntityLeft
# if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
# maxTimeWaiting=timeWaiting
# availableReceiver=object
#
# operator.candidateEntity.candidateReceiver=availableReceiver
# occupiedReceivers.append(availableReceiver)
# # if there is no available receiver add the entity to the entitiesWithOccupiedReceivers list
# else:
# entitiesWithOccupiedReceivers.append(availableEntity)
# operator.candidateEntity.candidateReceiver=None
#=======================================================================
# Sort Givers
......
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