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
64ffdf2a
Commit
64ffdf2a
authored
Feb 03, 2015
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new series of plugins for partjobshop case
parent
13617be4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
243 additions
and
0 deletions
+243
-0
dream/plugins/InsertQueues.py
dream/plugins/InsertQueues.py
+121
-0
dream/plugins/MergeSteps.py
dream/plugins/MergeSteps.py
+77
-0
dream/plugins/UpdateStationList.py
dream/plugins/UpdateStationList.py
+45
-0
No files found.
dream/plugins/InsertQueues.py
0 → 100644
View file @
64ffdf2a
from
copy
import
copy
import
json
import
time
import
random
import
operator
from
datetime
import
datetime
import
copy
from
dream.plugins
import
plugin
# XXX HARDCODED
MACHINE_TYPE_SET
=
set
([
"Dream.MachineJobShop"
,
"Dream.MouldAssembly"
])
class
InsertQueues
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
reads the data from external data base and inserts buffers before the corresponding stations
"""
def
getNotMachineNodePredecessorList
(
self
,
stationIDs_list
):
"""
Give the list of all predecessors that are not of type machine
For example, for stations with ids that starts with "CAM", it may return "QCAM"
"""
predecessor_list
=
[]
for
edge
in
self
.
data
[
"graph"
][
"edge"
].
values
():
if
edge
[
"destination"
]
in
stationIDs_list
:
predecessor_step
=
edge
[
"source"
]
if
predecessor_step
in
predecessor_list
:
continue
if
not
self
.
data
[
"graph"
][
"node"
][
predecessor_step
][
"_class"
]
in
MACHINE_TYPE_SET
:
predecessor_list
=
[
predecessor_step
]
+
predecessor_list
predecessor_list
=
[
x
for
x
in
getNotMachineNodePredecessorList
([
predecessor_step
])
\
if
x
not
in
predecessor_list
]
+
predecessor_list
return
predecessor_list
def
getNotMachineNodeSuccessorList
(
self
,
stationIDs_list
):
"""
Give the list of all successors that are not of type machine
For example, for stations of technology "CAM", it may return "Decomposition"
for stations of technology "INJM-MAN" or "INJM" it may return "Exit"
"""
successor_list
=
[]
for
edge
in
self
.
data
[
"graph"
][
"edge"
].
values
():
if
edge
[
"source"
]
in
stationIDs_list
:
successor_step
=
edge
[
"destination"
]
if
successor_step
in
successor_list
:
continue
if
not
self
.
data
[
"graph"
][
"node"
][
successor_step
][
"_class"
]
in
MACHINE_TYPE_SET
:
successor_list
=
[
successor_step
]
+
successor_list
successor_list
=
[
x
for
x
in
getNotMachineNodeSuccessorList
([
successor_step
])
\
if
x
not
in
successor_list
]
+
successor_list
return
successor_list
def
preprocess
(
self
,
data
):
""" inserts buffers before the corresponding stations
"""
self
.
data
=
copy
(
data
)
orders
=
self
.
data
[
"BOM"
][
"orders"
]
stations
=
self
.
data
[
"BOM"
][
"stations"
]
graph_data
=
self
.
data
[
"graph"
]
nodes
=
graph_data
[
"node"
]
for
order
in
orders
:
orderComponents
=
order
.
get
(
"componentsList"
,
[])
for
component
in
orderComponents
:
updatedRoute
=
[]
route
=
component
.
get
(
"route"
,
[])
# XXX separate mould from design
for
step
in
route
:
stationIdsList
=
step
.
get
(
"stationIdsList"
,
[])
for
index
,
step
in
enumerate
(
route
):
stationIdsList
=
step
.
get
(
"stationIdsList"
,
[])
for
predecessor
in
self
.
getNotMachineNodePredecessorList
(
stationIdsList
):
# XXX if the component is a mould then before the assembly do not add AssemblyBuffer
if
predecessor
.
startswith
(
"ASSM"
):
break
# XXX if there is a QCAM there must an OrderDecomposition come
if
predecessor
.
startswith
(
"QCAM"
):
for
pre_predecessor
in
self
.
getNotMachineNodePredecessorList
([
predecessor
]):
"""insert this step (pre_predecessor) to the route
{"stationIdsList": [pre_predecessor],}
"""
"""insert this step (predecessor) to the route
{"stationIdsList": [predecessor],}
"""
# XXX design case - add OrderDecomposition
if
any
(
station
.
startswith
(
"CAD"
)
for
station
in
stationIdsList
)
and
index
==
len
(
route
)
-
1
:
for
successor
in
self
.
getNotMachineNodeSuccessorList
(
stationIdsList
):
"""insert this step (successor) to the route
{"stationIdsList": [succecssor],}
"""
# XXX mould case - add exit
elif
any
(
station
.
startswith
(
"INJ"
)
for
station
in
stationIdsList
)
and
index
==
len
(
route
)
-
1
:
for
successor
in
self
.
getNotMachineNodeSuccessorList
(
stationIdsList
):
"""insert this step (successor) to the route
{"stationIdsList": [succecssor],}
"""
# XXX normal components - add ASSM buffer and ASSM after manual operations?
elif
index
==
len
(
route
)
-
1
:
exitAssigned
=
(
station
.
startswith
(
"ASS"
)
for
station
in
stationIdsList
)
if
not
exitAssigned
:
"""insert ASSM buffer to the route
{"stationIdsList": [AssemblyBufferIdsList],}
"""
"""insert ASSM to the route
{"stationIdsList": [AssemblyIdsList],}
"""
# XXX route.insert(indexToInsert, additionalStep)
return
data
if
__name__
==
'__main__'
:
pass
\ No newline at end of file
dream/plugins/MergeSteps.py
0 → 100644
View file @
64ffdf2a
from
copy
import
copy
import
json
import
time
import
random
import
operator
from
datetime
import
datetime
import
copy
from
dream.plugins
import
plugin
class
MergeSteps
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
reads the data from external data base and merges the route steps that constitute on technology step
"""
def
preprocess
(
self
,
data
):
""" merge the steps that constitute one single technology step
"""
orders
=
data
[
"BOM"
][
'orders'
]
for
order
in
orders
:
orderComponents
=
order
.
get
(
"componentsList"
,
[])
for
component
in
orderComponents
:
route
=
component
.
get
(
"route"
,
[])
updatedRoute
=
[]
technologySequence
=
[]
idxToMerge
=
None
for
index
,
step
in
enumerate
(
route
):
technology
=
step
[
"technology"
]
technology
=
technology
.
split
(
"-"
)[
0
]
# loadType is always manual for this pilot
step
[
"operationType"
]
=
{
"load"
:
"Manual"
}
step
[
"operator"
]
=
{}
# processingType + operator for processing
if
step
[
"operator"
]
==
"Automatic"
step
[
"operationType"
][
"processing"
]
=
"Automatic"
else
:
step
[
"operationType"
][
"processing"
]
=
"Manual"
tempOperator
=
copy
.
deepcopy
(
step
[
"operator"
])
step
[
"operator"
][
"processing"
]
=
[
tempOperator
],
step
[
"operator"
][
"load"
]
=
[
tempOperator
]}
# find out if there is there is any previous step to merge with
if
technology
==
technologySequence
[
-
1
]:
if
len
(
route
[
index
-
1
][
"technology"
].
split
(
"-"
)):
if
route
[
index
-
1
][
"technology"
].
split
(
"-"
)[
-
1
]
==
"SET"
:
idxToMerge
=
index
-
1
else
:
idxToMerge
=
None
# if we must merge two steps
if
idxToMerge
!=
None
:
# remove the previous step from the updatedRoute and technologySequence
updatedRoute
.
pop
(
-
1
)
technologySequence
.
pop
(
-
1
)
stepToMerge
=
route
[
idxToMerge
]
# parts needed
step
[
"parts_needed"
]
=
route
[
idxToMerge
][
"parts_needed"
]
# technology
step
[
"technology"
]
=
technology
# setupTime
if
route
[
idxToMerge
][
"processingTime"
]:
step
[
"setupTime"
]
=
route
[
idxToMerge
][
"processingTime"
]
# setupType + operator for setup
if
route
[
idxToMerge
][
"operator"
]
==
"Automatic"
step
[
"operationType"
][
"setup"
]
=
"Automatic"
else
:
step
[
"operationType"
][
"setup"
]
=
"Manual"
step
[
"operator"
][
"setup"
]
=
route
[
idxToMerge
][
"operator"
]
step
[
"operator"
][
"load"
]
=
route
[
idxToMerge
][
"operator"
]
technologySequence
.
append
(
techonology
)
# append the (updated) step to the temporary route
updatedRoute
.
append
(
step
)
# update the route of the step
component
[
"route"
]
=
updatedRoute
return
data
if
__name__
==
'__main__'
:
pass
\ No newline at end of file
dream/plugins/UpdateStationList.py
0 → 100644
View file @
64ffdf2a
from
copy
import
copy
import
json
import
time
import
random
import
operator
from
datetime
import
datetime
import
copy
from
dream.plugins
import
plugin
class
UpdateStationList
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
reads the data from external data base and substitutes the technology information with stationIDs lists
"""
def
preprocess
(
self
,
data
):
""" substitutes the technology information with stationIDs lists
"""
orders
=
data
[
"BOM"
][
'orders'
]
stations
=
data
[
"BOM"
][
'stations'
]
nodes
=
data
[
"graph"
][
"node"
]
for
order
in
orders
:
orderComponents
=
order
.
get
(
"componentsList"
,
[])
for
component
in
orderComponents
:
route
=
component
.
get
(
"route"
,
[])
for
index
,
step
in
enumerate
(
route
):
technology
=
step
.
pop
(
"technology"
,
None
)
technology
=
technology
.
split
(
"-"
)[
0
]
technologyStations
=
[]
for
station
in
stations
:
if
station
.
startswith
(
technology
):
found
=
False
# check that the id of the station provided by the db BOM exist in the nodes of the graph
for
node
in
nodes
:
if
node
[
"id"
]
==
station
:
found
=
True
break
assert
found
==
True
,
"the station ids in the DB must be the same with the stations ids provided by the model"
technologyStations
.
append
(
station
)
assert
len
(
technologyStations
)
>
0
,
"the stations corresponding to the defined technology must be more than 0"
step
[
"stationIdsList"
]
=
technologyStations
return
data
if
__name__
==
'__main__'
:
pass
\ 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