Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
ef7c769e
Commit
ef7c769e
authored
Mar 04, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correction so that G.Router is eliminated
parent
3a38d684
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
53 additions
and
57 deletions
+53
-57
dream/simulation/BatchReassembly.py
dream/simulation/BatchReassembly.py
+1
-1
dream/simulation/Exit.py
dream/simulation/Exit.py
+1
-1
dream/simulation/Globals.py
dream/simulation/Globals.py
+1
-4
dream/simulation/Job.py
dream/simulation/Job.py
+1
-1
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+4
-5
dream/simulation/Machine.py
dream/simulation/Machine.py
+16
-16
dream/simulation/MachineManagedJob.py
dream/simulation/MachineManagedJob.py
+3
-3
dream/simulation/ManPyObject.py
dream/simulation/ManPyObject.py
+10
-10
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+7
-7
dream/simulation/Operator.py
dream/simulation/Operator.py
+1
-1
dream/simulation/OperatorManagedJob.py
dream/simulation/OperatorManagedJob.py
+2
-2
dream/simulation/QueueManagedJob.py
dream/simulation/QueueManagedJob.py
+4
-4
dream/simulation/SkilledOperatorRouter.py
dream/simulation/SkilledOperatorRouter.py
+1
-1
dream/simulation/Source.py
dream/simulation/Source.py
+1
-1
No files found.
dream/simulation/BatchReassembly.py
View file @
ef7c769e
...
...
@@ -238,7 +238,7 @@ class BatchReassembly(CoreObject):
# if the activeEntity is in the pendingEntities list then place the subBatches there
if
activeObjectQueue
[
0
]
in
G
.
pendingEntities
:
G
.
pendingEntities
.
append
(
batchToBeReassembled
)
if
G
.
Router
:
if
G
.
Router
List
:
for
entity
in
activeObjectQueue
:
G
.
pendingEntities
.
remove
(
entity
)
...
...
dream/simulation/Exit.py
View file @
ef7c769e
...
...
@@ -108,7 +108,7 @@ class Exit(CoreObject):
# if the entity is in the G.pendingEntities list then remove it from there
from
Globals
import
G
# G.pendingEntities[:]=(entity for entity in G.pendingEntities if not entity is activeEntity)
if
G
.
Router
:
if
G
.
Router
List
:
if
activeEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
remove
(
activeEntity
)
# if activeEntity in G.EntityList:
...
...
dream/simulation/Globals.py
View file @
ef7c769e
...
...
@@ -76,10 +76,7 @@ class G:
outputJSONFile
=
None
numberOfEntities
=
0
#object that routes the operators in the model
Router
=
None
# define the lists of each object type
SourceList
=
[]
MachineList
=
[]
...
...
dream/simulation/Job.py
View file @
ef7c769e
...
...
@@ -295,7 +295,7 @@ class Job(Entity): # inherits from the Entity c
#===========================================================================
def
findCandidateReceiver
(
self
):
from
Globals
import
G
router
=
G
.
Router
router
=
G
.
Router
List
[
0
]
# initiate the local list variable available receivers
availableReceivers
=
[
x
for
x
in
self
.
candidateReceivers
\
if
not
x
in
router
.
occupiedReceivers
]
...
...
dream/simulation/LineGenerationJSON.py
View file @
ef7c769e
...
...
@@ -124,7 +124,6 @@ def createObjectResourcesAndCoreObjects():
G
.
OperatorManagedJobsList
=
[]
G
.
OperatorPoolsList
=
[]
G
.
BrokersList
=
[]
G
.
Router
=
None
G
.
OperatedMachineList
=
[]
G
.
BatchScrapMachineList
=
[]
G
.
OrderDecompositionList
=
[]
...
...
@@ -592,6 +591,7 @@ def main(argv=[], input_data=None):
#create an empty list to store all the objects in
G
.
ObjList
=
[]
G
.
RouterList
=
[]
if
input_data
is
None
:
# user passes the topology filename as first argument to the program
...
...
@@ -618,9 +618,9 @@ def main(argv=[], input_data=None):
G
.
env
=
simpy
.
Environment
()
# initialize the environment
G
.
maxSimTime
=
float
(
G
.
JSONData
[
'general'
].
get
(
'maxSimTime'
,
'100'
))
# read the maxSimTime in each replication
# since it may be changed for infinite ones
if
G
.
Router
:
G
.
Router
.
isActivated
=
False
G
.
Router
.
isInitialized
=
False
if
G
.
Router
List
:
G
.
Router
List
[
0
]
.
isActivated
=
False
G
.
Router
List
[
0
]
.
isInitialized
=
False
if
G
.
seed
:
G
.
Rnd
=
Random
(
'%s%s'
%
(
G
.
seed
,
i
))
...
...
@@ -695,7 +695,6 @@ def main(argv=[], input_data=None):
if
0
:
G
.
outputJSONFile
=
open
(
'outputJSON.json'
,
mode
=
'w'
)
G
.
outputJSONFile
.
write
(
outputJSONString
)
if
not
input_data
:
# Output on stdout
print
outputJSONString
...
...
dream/simulation/Machine.py
View file @
ef7c769e
...
...
@@ -257,16 +257,16 @@ class Machine(CoreObject):
if
(
self
.
operatorPool
!=
'None'
):
from
Globals
import
G
# if there is no router
if
not
G
.
Router
:
if
not
G
.
Router
List
:
# TODO if the dedicatedOperator flag is raised then create a SkilledRouter (temp)
if
self
.
dedicatedOperator
:
self
.
router
=
SkilledRouter
()
else
:
self
.
router
=
Router
()
G
.
Router
=
self
.
router
G
.
Router
List
[
0
]
=
self
.
router
# otherwise set the already existing router as the machines Router
else
:
self
.
router
=
G
.
Router
self
.
router
=
G
.
Router
List
[
0
]
#===========================================================================
# initialise broker if needed
#===========================================================================
...
...
@@ -507,7 +507,7 @@ class Machine(CoreObject):
yield
self
.
env
.
process
(
self
.
release
())
from
Globals
import
G
# append the entity that was stopped to the pending ones
if
G
.
Router
:
if
G
.
Router
List
:
G
.
pendingEntities
.
append
(
self
.
currentEntity
)
#===========================================================
# # request a resource after the interruption
...
...
@@ -581,8 +581,8 @@ class Machine(CoreObject):
if
self
.
signalGiver
():
# XXX cleaner implementation needed
# if there is skilled router the giver should also check
if
G
.
Router
:
if
'Skilled'
in
str
(
G
.
Router
.
__class__
):
if
G
.
Router
List
:
if
'Skilled'
in
str
(
G
.
Router
List
[
0
]
.
__class__
):
continue
break
if
self
.
loadOperatorAvailable
in
receivedEvent
:
...
...
@@ -594,8 +594,8 @@ class Machine(CoreObject):
if
self
.
signalGiver
():
# XXX cleaner implementation needed
# if there is router that is not skilled break
if
G
.
Router
:
if
not
'Skilled'
in
str
(
G
.
Router
.
__class__
):
if
G
.
Router
List
:
if
not
'Skilled'
in
str
(
G
.
Router
List
[
0
]
.
__class__
):
break
# else continue, the giver should also check
continue
...
...
@@ -889,7 +889,7 @@ class Machine(CoreObject):
except
IndexError
:
pass
from
Globals
import
G
if
G
.
Router
:
if
G
.
Router
List
:
# the just processed entity is added to the list of entities
# pending for the next processing
G
.
pendingEntities
.
append
(
activeObjectQueue
[
0
])
...
...
@@ -1095,7 +1095,7 @@ class Machine(CoreObject):
activeEntity
=
CoreObject
.
getEntity
(
self
)
# run the default method
# after the machine receives an entity, it must be removed from the pendingEntities list
from
Globals
import
G
if
G
.
Router
:
if
G
.
Router
List
:
if
activeEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
remove
(
activeEntity
)
return
activeEntity
...
...
@@ -1141,7 +1141,7 @@ class Machine(CoreObject):
activeEntity
=
entity
from
Globals
import
G
router
=
G
.
Router
router
=
G
.
Router
List
[
0
]
# if the entity is in a machines who's broker waits for operator then
if
self
in
router
.
pendingMachines
:
activeEntity
.
proceed
=
True
...
...
@@ -1177,11 +1177,11 @@ class Machine(CoreObject):
# if the Router is expecting for signal send it
from
Globals
import
G
from
SkilledOperatorRouter
import
SkilledRouter
if
G
.
Router
.
__class__
is
SkilledRouter
:
if
G
.
Router
.
expectedFinishSignals
:
if
self
.
id
in
G
.
Router
.
expectedFinishSignalsDict
:
signal
=
G
.
Router
.
expectedFinishSignalsDict
[
self
.
id
]
self
.
sendSignal
(
receiver
=
G
.
Router
,
signal
=
signal
)
if
G
.
Router
List
[
0
]
.
__class__
is
SkilledRouter
:
if
G
.
Router
List
[
0
]
.
expectedFinishSignals
:
if
self
.
id
in
G
.
Router
List
[
0
]
.
expectedFinishSignalsDict
:
signal
=
G
.
Router
List
[
0
]
.
expectedFinishSignalsDict
[
self
.
id
]
self
.
sendSignal
(
receiver
=
G
.
Router
List
[
0
]
,
signal
=
signal
)
self
.
broker
.
invoke
()
self
.
toBeOperated
=
False
...
...
dream/simulation/MachineManagedJob.py
View file @
ef7c769e
...
...
@@ -66,12 +66,12 @@ class MachineManagedJob(MachineJobShop):
def
createRouter
(
self
):
#create a Router
from
Globals
import
G
if
not
G
.
Router
:
if
not
G
.
Router
List
:
self
.
router
=
RouterManaged
()
G
.
Router
=
self
.
router
G
.
Router
List
[
0
]
=
self
.
router
# otherwise set the already existing router as the machines Router
else
:
self
.
router
=
G
.
Router
self
.
router
=
G
.
Router
List
[
0
]
#===========================================================================
# initialize broker if needed
...
...
dream/simulation/ManPyObject.py
View file @
ef7c769e
...
...
@@ -53,13 +53,13 @@ class ManPyObject(object):
def
requestAllocation
():
# TODO: signal the Router, skilled operators must be assigned to operatorPools
from
Globals
import
G
G
.
Router
.
allocation
=
True
G
.
Router
.
waitEndProcess
=
False
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]:
G
.
Router
.
invoked
=
True
G
.
Router
List
[
0
]
.
allocation
=
True
G
.
Router
List
[
0
]
.
waitEndProcess
=
False
if
not
G
.
Router
List
[
0
].
invoked
and
G
.
RouterList
[
0
]
.
expectedSignals
[
'isCalled'
]:
G
.
Router
List
[
0
]
.
invoked
=
True
succeedTuple
=
(
G
.
env
,
G
.
env
.
now
)
G
.
Router
.
isCalled
.
succeed
(
succeedTuple
)
G
.
Router
.
expectedSignals
[
'isCalled'
]
=
0
G
.
Router
List
[
0
]
.
isCalled
.
succeed
(
succeedTuple
)
G
.
Router
List
[
0
]
.
expectedSignals
[
'isCalled'
]
=
0
#===========================================================================
# signalRouter method
...
...
@@ -74,12 +74,12 @@ class ManPyObject(object):
if
receiver
.
isLoadRequested
():
try
:
from
Globals
import
G
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]:
if
not
G
.
Router
List
[
0
].
invoked
and
G
.
RouterList
[
0
]
.
expectedSignals
[
'isCalled'
]:
# self.printTrace(self.id, signal='router')
G
.
Router
.
invoked
=
True
G
.
Router
List
[
0
]
.
invoked
=
True
succeedTuple
=
(
G
.
env
,
G
.
env
.
now
)
G
.
Router
.
isCalled
.
succeed
(
succeedTuple
)
G
.
Router
.
expectedSignals
[
'isCalled'
]
=
0
G
.
Router
List
[
0
]
.
isCalled
.
succeed
(
succeedTuple
)
G
.
Router
List
[
0
]
.
expectedSignals
[
'isCalled'
]
=
0
return
True
except
:
return
False
...
...
dream/simulation/OperatedPoolBroker.py
View file @
ef7c769e
...
...
@@ -96,10 +96,10 @@ class Broker(ObjectInterruption):
# add the currentEntity to the pendingEntities
if
not
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
append
(
self
.
victim
.
currentEntity
)
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]:
if
not
G
.
Router
List
[
0
].
invoked
and
G
.
RouterList
[
0
]
.
expectedSignals
[
'isCalled'
]:
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
self
.
sendSignal
(
receiver
=
G
.
Router
,
signal
=
G
.
Router
.
isCalled
)
G
.
Router
.
invoked
=
True
self
.
sendSignal
(
receiver
=
G
.
Router
List
[
0
],
signal
=
G
.
RouterList
[
0
]
.
isCalled
)
G
.
Router
List
[
0
]
.
invoked
=
True
self
.
waitForOperator
=
True
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
...
...
@@ -118,7 +118,7 @@ class Broker(ObjectInterruption):
# else if the Router is already invoked for allocating purposes wait until a resource is allocated to the victim's operatorPool
# wait only if there is no current operator
# XXX discuss this
elif
G
.
Router
.
invoked
and
G
.
Router
.
allocation
and
not
self
.
victim
.
currentOperator
:
elif
G
.
Router
List
[
0
].
invoked
and
G
.
RouterList
[
0
]
.
allocation
and
not
self
.
victim
.
currentOperator
:
self
.
waitForOperator
=
True
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
...
...
@@ -178,10 +178,10 @@ class Broker(ObjectInterruption):
# TODO: signalling the router must be done more elegantly, router must be set as global variable
# if the router is already invoked then do not signal it again
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]:
if
not
G
.
Router
List
[
0
].
invoked
and
G
.
RouterList
[
0
]
.
expectedSignals
[
'isCalled'
]:
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
G
.
Router
.
invoked
=
True
self
.
sendSignal
(
receiver
=
G
.
Router
,
signal
=
G
.
Router
.
isCalled
)
G
.
Router
List
[
0
]
.
invoked
=
True
self
.
sendSignal
(
receiver
=
G
.
Router
List
[
0
],
signal
=
G
.
RouterList
[
0
]
.
isCalled
)
# TODO: signalling the router will give the chance to it to take the control, but when will it eventually receive it.
# after signalling the broker will signal it's victim that it has finished it's processes
# TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers.
...
...
dream/simulation/Operator.py
View file @
ef7c769e
...
...
@@ -128,7 +128,7 @@ class Operator(ObjectResource):
#===========================================================================
def
sortStations
(
self
):
from
Globals
import
G
router
=
G
.
Router
router
=
G
.
Router
List
[
0
]
candidateMachines
=
self
.
candidateStations
# for the candidateMachines
if
candidateMachines
:
...
...
dream/simulation/OperatorManagedJob.py
View file @
ef7c769e
...
...
@@ -84,7 +84,7 @@ class OperatorManagedJob(Operator):
#===========================================================================
def
findAvailableEntity
(
self
):
from
Globals
import
G
router
=
G
.
Router
router
=
G
.
Router
List
[
0
]
# if the candidateEntities and the entitiesWithOccupiedReceivers lists are identical then return None
if
len
(
set
(
self
.
candidateEntities
).
intersection
(
router
.
entitiesWithOccupiedReceivers
))
==
len
(
self
.
candidateEntities
):
return
None
...
...
@@ -106,7 +106,7 @@ class OperatorManagedJob(Operator):
#===========================================================================
def
findCandidateEntity
(
self
):
from
Globals
import
G
router
=
G
.
Router
router
=
G
.
Router
List
[
0
]
# pick a candidateEntity
candidateEntity
=
self
.
findAvailableEntity
()
if
not
candidateEntity
:
...
...
dream/simulation/QueueManagedJob.py
View file @
ef7c769e
...
...
@@ -105,12 +105,12 @@ class QueueManagedJob(QueueJobShop):
if
receiver
.
identifyEntityToGet
().
manager
.
isAssignedTo
()
!=
receiver
:
try
:
from
Globals
import
G
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]:
if
not
G
.
Router
List
[
0
].
invoked
and
G
.
RouterList
[
0
]
.
expectedSignals
[
'isCalled'
]:
# self.printTrace(self.id, signal='router')
G
.
Router
.
invoked
=
True
G
.
Router
List
[
0
]
.
invoked
=
True
succeedTuple
=
(
G
.
env
,
G
.
env
.
now
)
G
.
Router
.
isCalled
.
succeed
(
succeedTuple
)
G
.
Router
.
expectedSignals
[
'isCalled'
]
=
0
G
.
Router
List
[
0
]
.
isCalled
.
succeed
(
succeedTuple
)
G
.
Router
List
[
0
]
.
expectedSignals
[
'isCalled'
]
=
0
return
True
except
:
return
False
...
...
dream/simulation/SkilledOperatorRouter.py
View file @
ef7c769e
...
...
@@ -42,7 +42,7 @@ class SkilledRouter(Router):
# TODO: we should maybe define a global schedulingRule criterion that will be
# chosen in case of multiple criteria for different Operators
# =======================================================================
def
__init__
(
self
,
sorting
=
False
,
outputSolutions
=
Fals
e
):
def
__init__
(
self
,
sorting
=
False
,
outputSolutions
=
Tru
e
):
Router
.
__init__
(
self
)
# Flag used to notify the need for re-allocation of skilled operators to operatorPools
self
.
allocation
=
False
...
...
dream/simulation/Source.py
View file @
ef7c769e
...
...
@@ -167,7 +167,7 @@ class Source(CoreObject):
from
Globals
import
G
assert
entity
,
'cannot append None entity'
activeEntity
=
entity
if
G
.
Router
:
if
G
.
Router
List
:
# at the newly created entity to the pendingEntities
G
.
pendingEntities
.
append
(
activeEntity
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment