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
9d6e8f22
Commit
9d6e8f22
authored
May 08, 2015
by
panos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CreateCapacityStations plug-in added to create buffers and exits in the stations of this pilot case
parent
b306aae0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
132 additions
and
0 deletions
+132
-0
dream/KnowledgeExtraction/PilotCases/CapacityStations/CreateCapacityStations.py
...ion/PilotCases/CapacityStations/CreateCapacityStations.py
+132
-0
No files found.
dream/KnowledgeExtraction/PilotCases/CapacityStations/CreateCapacityStations.py
0 → 100644
View file @
9d6e8f22
from
copy
import
copy
,
deepcopy
import
json
import
time
import
random
import
operator
import
datetime
from
dream.plugins
import
plugin
class
CreateCapacityStations
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
creates the CapacityStationBuffer and CapacityStationExit for each CapacityStation
"""
def
preprocess
(
self
,
data
):
nodes
=
copy
(
data
[
'graph'
][
'node'
])
originalData
=
deepcopy
(
data
)
for
(
stationId
,
node
)
in
nodes
.
iteritems
():
_class
=
node
[
'_class'
]
if
_class
==
'dream.simulation.applications.CapacityStations.CapacityStation.CapacityStation'
:
nextCapacityStationBufferId
=
self
.
getNextCapacityStationBufferId
(
data
,
stationId
)
# the nextCapacityStationBufferId should point to the buffer
if
nextCapacityStationBufferId
:
nextCapacityStationBufferId
+=
'_B'
stationName
=
node
[
'name'
]
# create the CapacityStationBuffer
bufferName
=
stationName
+
'_Buffer'
bufferId
=
stationId
+
'_B'
requireFullProject
=
data
[
'graph'
][
'node'
][
stationId
].
pop
(
'requireFullProject'
,
None
)
data
[
'graph'
][
'node'
][
bufferId
]
=
{
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer"
,
"name"
:
bufferName
,
"wip"
:
[],
'requireFullProject'
:
requireFullProject
}
if
requireFullProject
:
data
[
'graph'
][
'node'
][
bufferId
][
'notRequiredOperations'
]
=
self
.
findNotRequiredOperations
(
originalData
,
stationId
)
data
[
'graph'
][
'node'
][
stationId
][
'notProcessOutsideThreshold'
]
=
1
# create an edge that connects the CapacityStationBuffer to the CapacityStation
data
[
'graph'
][
'edge'
][
bufferId
+
'_to_'
+
stationId
]
=
{
"source"
:
bufferId
,
"destination"
:
stationId
,
"data"
:
{},
"_class"
:
"Dream.Edge"
}
# create the CapacityStationExit
exitName
=
stationName
+
'_Exit'
exitId
=
stationId
+
'_E'
data
[
'graph'
][
'node'
][
exitId
]
=
{
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityStationExit.CapacityStationExit"
,
"name"
:
exitName
,
"nextCapacityStationBufferId"
:
nextCapacityStationBufferId
}
# create an edge that connects the CapacityStationBuffer to the CapacityStation
data
[
'graph'
][
'edge'
][
stationId
+
'_to_'
+
exitId
]
=
{
"source"
:
stationId
,
"destination"
:
exitId
,
"data"
:
{},
"_class"
:
"Dream.Edge"
}
# if projects shares from a pool read which others share resources and create
# the sharedResources element
pool
=
data
[
'graph'
][
'node'
][
stationId
].
get
(
'pool'
,
''
)
if
pool
:
sharingStations
=
[]
priority
=
data
[
'graph'
][
'node'
][
stationId
].
get
(
'priority'
,
None
)
for
other_id
,
other_node
in
originalData
[
'graph'
][
'node'
].
iteritems
():
if
other_id
==
stationId
:
continue
otherPool
=
other_node
.
get
(
'pool'
,
''
)
if
otherPool
==
pool
:
sharingStations
.
append
(
other_id
)
data
[
'graph'
][
'node'
][
stationId
][
'sharedResources'
]
=
{
"stationIds"
:
sharingStations
,
"priority"
:
priority
}
# add also a CapacityStationController
dueDateThreshold
=
data
[
'general'
].
get
(
'dueDateThreshold'
,
14
)
data
[
'graph'
][
'node'
][
'CSC'
]
=
{
"dueDateThreshold"
:
dueDateThreshold
,
"name"
:
"CSC"
,
"prioritizeIfCanFinish"
:
1
,
"interval"
:
"1"
,
"start"
:
"0"
,
"interruptions"
:
{},
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityStationController.CapacityStationController"
}
return
data
# gets the data and the stationId
# returns the successorId and erases the edge
def
getNextCapacityStationBufferId
(
self
,
data
,
stationId
):
successorId
=
None
edgeToErase
=
None
for
(
edgeId
,
edge
)
in
data
[
'graph'
][
'edge'
].
iteritems
():
if
data
[
'graph'
][
'edge'
][
edgeId
][
'source'
]
==
stationId
:
successorId
=
data
[
'graph'
][
'edge'
][
edgeId
][
'destination'
]
edgeToErase
=
edgeId
break
if
edgeToErase
:
data
[
'graph'
][
'edge'
].
pop
(
edgeToErase
,
None
)
return
successorId
# for an assembly station finds which are the not required operations
def
findNotRequiredOperations
(
self
,
data
,
stationId
):
requiredOperations
=
[]
nodes
=
data
[
'graph'
][
'node'
]
notRequiredOperations
=
nodes
.
keys
()
for
node_id
,
node
in
nodes
.
iteritems
():
currentId
=
node_id
while
1
:
successorList
=
self
.
getSuccessors
(
data
,
currentId
)
if
not
successorList
:
break
successorId
=
successorList
[
0
]
if
successorId
==
stationId
:
requiredOperations
.
append
(
node_id
)
break
currentId
=
successorId
for
element
in
deepcopy
(
notRequiredOperations
):
if
element
in
requiredOperations
:
notRequiredOperations
.
remove
(
element
)
return
notRequiredOperations
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