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
d6cc276e
Commit
d6cc276e
authored
Jun 08, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jun 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in CapacityEntitiesController
parent
0eafc667
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
20 deletions
+64
-20
dream/simulation/CapacityEntity.py
dream/simulation/CapacityEntity.py
+1
-0
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+63
-20
No files found.
dream/simulation/CapacityEntity.py
View file @
d6cc276e
...
...
@@ -43,6 +43,7 @@ class CapacityEntity(Entity):
def
initialize
(
self
):
Entity
.
initialize
(
self
)
self
.
shouldMove
=
False
from
Globals
import
G
# find the project that the capacity entity is part of
for
project
in
G
.
CapacityProjectList
:
...
...
dream/simulation/CapacityStationController.py
View file @
d6cc276e
...
...
@@ -28,6 +28,7 @@ event generator that controls the capacity station objects
import
simpy
from
EventGenerator
import
EventGenerator
from
CapacityEntity
import
CapacityEntity
from
Globals
import
G
class
CapacityStationController
(
EventGenerator
):
...
...
@@ -61,6 +62,7 @@ class CapacityStationController(EventGenerator):
# Send canDispose to all the Stations
print
2
for
station
in
G
.
CapacityStationList
:
if
len
(
station
.
getActiveObjectQueue
())
>
0
:
station
.
canDispose
.
succeed
()
# give control until all the Stations become empty
print
3
...
...
@@ -82,14 +84,26 @@ class CapacityStationController(EventGenerator):
print
7
for
station
in
G
.
CapacityStationList
:
station
.
isLocked
=
False
# Send canDispose to all the StationBuffers
print
8
for
buffer
in
G
.
CapacityStationBufferList
:
buffer
.
canDispose
.
succeed
()
# give control until all StationBuffers hold only Entities that are not to be given
print
9
while
not
self
.
checkIfBuffersFinished
():
yield
self
.
env
.
timeout
(
0
)
print
8
,
9
# loop through the stations
for
station
in
G
.
CapacityStationList
:
buffer
=
station
.
previous
[
0
]
# take the buffer
buffer
.
sortEntities
()
# sort the entities of the buffer so the ones to move go in front
# loop though the entities
entitiesToCheck
=
list
(
buffer
.
getActiveObjectQueue
())
for
entity
in
entitiesToCheck
:
print
entity
.
name
,
entity
.
shouldMove
if
not
entity
.
shouldMove
:
# when the first entity that should not move is reached break
break
station
.
isRequested
.
succeed
(
buffer
)
# send is requested to station
# wait until the entity is removed
yield
buffer
.
entityRemoved
buffer
.
entityRemoved
=
self
.
env
.
event
()
print
10
# for every station update the remaining interval capacity so that it is ready for next loop
for
station
in
G
.
CapacityStationList
:
...
...
@@ -108,20 +122,49 @@ class CapacityStationController(EventGenerator):
def
calculateWhatIsToBeProcessed
(
self
):
# loop through the capacity station buffers
for
buffer
in
G
.
CapacityStationBufferList
:
station
=
buffer
.
next
[
0
]
# get the station
totalAvailableCapacity
=
station
.
remainingIntervalCapacity
[
0
]
# get the available capacity of the station
# for this interval
# if there is no capacity continue with the next buffer
if
totalAvailableCapacity
<=
0
:
continue
# calculate the total capacity that is requested
totalRequestedCapacity
=
0
print
buffer
.
next
totalAvailableCapacity
=
buffer
.
next
[
0
].
remainingIntervalCapacity
[
0
]
for
entity
in
buffer
.
getActiveObjectQueue
():
totalRequestedCapacity
+=
entity
.
requiredCapacity
# if there is enough capacity for all the entities set them that they all should move
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
for
entity
in
buffer
.
getActiveObjectQueue
():
pass
#entity.shouldMove=True
def
checkIfBuffersFinished
(
self
):
for
buffer
in
G
.
CapacityStationBufferList
:
entity
.
shouldMove
=
True
# else calculate the capacity for every entity and create the entities
else
:
entitiesInBuffer
=
list
(
buffer
.
getActiveObjectQueue
())
# loop through the entities
for
entity
in
entitiesInBuffer
:
# calculate what is the capacity that should proceed and what that should remain
capacityToMove
=
totalAvailableCapacity
*
(
entity
.
requiredCapacity
)
/
float
(
totalRequestedCapacity
)
capacityToStay
=
entity
.
requiredCapacity
-
capacityToMove
# remove the capacity entity by the buffer so that the broken ones are created
buffer
.
getActiveObjectQueue
().
remove
(
entity
)
entityToMoveName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToMove
)
entityToMove
=
CapacityEntity
(
name
=
entityToMoveName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToMove
)
entityToMove
.
initialize
()
entityToMove
.
currentStation
=
buffer
entityToMove
.
shouldMove
=
True
entityToStayName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToStay
)
entityToStay
=
CapacityEntity
(
name
=
entityToStayName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToStay
)
entityToStay
.
initialize
()
entityToStay
.
currentStation
=
buffer
import
Globals
Globals
.
setWIP
([
entityToMove
,
entityToStay
])
#set the new components as wip
buffer
.
sortEntities
()
print
'-'
for
entity
in
buffer
.
getActiveObjectQueue
():
if
entity
.
shouldMove
:
print
entity
.
name
,
entity
.
shouldMove
print
'-'
def
checkIfBufferFinished
(
self
,
buffer
):
if
buffer
.
getActiveObjectQueue
():
return
False
return
True
\ No newline at end of file
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