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):
...
@@ -43,6 +43,7 @@ class CapacityEntity(Entity):
def
initialize
(
self
):
def
initialize
(
self
):
Entity
.
initialize
(
self
)
Entity
.
initialize
(
self
)
self
.
shouldMove
=
False
from
Globals
import
G
from
Globals
import
G
# find the project that the capacity entity is part of
# find the project that the capacity entity is part of
for
project
in
G
.
CapacityProjectList
:
for
project
in
G
.
CapacityProjectList
:
...
...
dream/simulation/CapacityStationController.py
View file @
d6cc276e
...
@@ -28,6 +28,7 @@ event generator that controls the capacity station objects
...
@@ -28,6 +28,7 @@ event generator that controls the capacity station objects
import
simpy
import
simpy
from
EventGenerator
import
EventGenerator
from
EventGenerator
import
EventGenerator
from
CapacityEntity
import
CapacityEntity
from
Globals
import
G
from
Globals
import
G
class
CapacityStationController
(
EventGenerator
):
class
CapacityStationController
(
EventGenerator
):
...
@@ -61,6 +62,7 @@ class CapacityStationController(EventGenerator):
...
@@ -61,6 +62,7 @@ class CapacityStationController(EventGenerator):
# Send canDispose to all the Stations
# Send canDispose to all the Stations
print
2
print
2
for
station
in
G
.
CapacityStationList
:
for
station
in
G
.
CapacityStationList
:
if
len
(
station
.
getActiveObjectQueue
())
>
0
:
station
.
canDispose
.
succeed
()
station
.
canDispose
.
succeed
()
# give control until all the Stations become empty
# give control until all the Stations become empty
print
3
print
3
...
@@ -82,14 +84,26 @@ class CapacityStationController(EventGenerator):
...
@@ -82,14 +84,26 @@ class CapacityStationController(EventGenerator):
print
7
print
7
for
station
in
G
.
CapacityStationList
:
for
station
in
G
.
CapacityStationList
:
station
.
isLocked
=
False
station
.
isLocked
=
False
# Send canDispose to all the StationBuffers
print
8
print
8
,
9
for
buffer
in
G
.
CapacityStationBufferList
:
# loop through the stations
buffer
.
canDispose
.
succeed
()
for
station
in
G
.
CapacityStationList
:
# give control until all StationBuffers hold only Entities that are not to be given
buffer
=
station
.
previous
[
0
]
# take the buffer
print
9
buffer
.
sortEntities
()
# sort the entities of the buffer so the ones to move go in front
while
not
self
.
checkIfBuffersFinished
():
# loop though the entities
yield
self
.
env
.
timeout
(
0
)
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
print
10
# for every station update the remaining interval capacity so that it is ready for next loop
# for every station update the remaining interval capacity so that it is ready for next loop
for
station
in
G
.
CapacityStationList
:
for
station
in
G
.
CapacityStationList
:
...
@@ -108,20 +122,49 @@ class CapacityStationController(EventGenerator):
...
@@ -108,20 +122,49 @@ class CapacityStationController(EventGenerator):
def
calculateWhatIsToBeProcessed
(
self
):
def
calculateWhatIsToBeProcessed
(
self
):
# loop through the capacity station buffers
# loop through the capacity station buffers
for
buffer
in
G
.
CapacityStationBufferList
:
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
totalRequestedCapacity
=
0
print
buffer
.
next
totalAvailableCapacity
=
buffer
.
next
[
0
].
remainingIntervalCapacity
[
0
]
for
entity
in
buffer
.
getActiveObjectQueue
():
for
entity
in
buffer
.
getActiveObjectQueue
():
totalRequestedCapacity
+=
entity
.
requiredCapacity
totalRequestedCapacity
+=
entity
.
requiredCapacity
# if there is enough capacity for all the entities set them that they all should move
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
if
totalRequestedCapacity
<=
totalAvailableCapacity
:
for
entity
in
buffer
.
getActiveObjectQueue
():
for
entity
in
buffer
.
getActiveObjectQueue
():
pass
entity
.
shouldMove
=
True
#entity.shouldMove=True
# else calculate the capacity for every entity and create the entities
else
:
def
checkIfBuffersFinished
(
self
):
entitiesInBuffer
=
list
(
buffer
.
getActiveObjectQueue
())
for
buffer
in
G
.
CapacityStationBufferList
:
# 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
():
for
entity
in
buffer
.
getActiveObjectQueue
():
if
entity
.
shouldMove
:
print
entity
.
name
,
entity
.
shouldMove
print
'-'
def
checkIfBufferFinished
(
self
,
buffer
):
if
buffer
.
getActiveObjectQueue
():
return
False
return
False
return
True
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