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
70cfe089
Commit
70cfe089
authored
Feb 17, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'addBatchStations'
parents
a7a3a7b8
281333da
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2382 additions
and
1024 deletions
+2382
-1024
dream/plugins/AddBatchStations.py
dream/plugins/AddBatchStations.py
+152
-0
dream/plugins/plugin.py
dream/plugins/plugin.py
+30
-0
dream/simulation/Examples/BatchAllInOneEmpty.json
dream/simulation/Examples/BatchAllInOneEmpty.json
+640
-1022
dream/simulation/Examples/BatchModel.json
dream/simulation/Examples/BatchModel.json
+1558
-0
dream/simulation/JSONInputs/Batches_VD_Sc1.json
dream/simulation/JSONInputs/Batches_VD_Sc1.json
+1
-1
dream/tests/dump/Batches_VD_Sc1.json.result
dream/tests/dump/Batches_VD_Sc1.json.result
+1
-1
No files found.
dream/plugins/AddBatchStations.py
0 → 100644
View file @
70cfe089
from
copy
import
copy
import
json
import
time
import
random
import
operator
import
datetime
from
dream.plugins
import
plugin
class
AddBatchStations
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
checks if the Batch Station processes Batchs or SubBatches and in the former case adds a decomposition/reassembly
to set to the working batch
"""
def
preprocess
(
self
,
data
):
nodes
=
copy
(
data
[
'graph'
][
'node'
])
edges
=
copy
(
data
[
'graph'
][
'edge'
])
data_uri_encoded_input_data
=
data
[
'input'
].
get
(
self
.
configuration_dict
[
'input_id'
],
{})
# get the number of units for a standard batch
standardBatchUnits
=
0
for
node_id
,
node
in
nodes
.
iteritems
():
if
node
[
'_class'
]
==
'Dream.BatchSource'
:
standardBatchUnits
=
int
(
node
[
'numberOfUnits'
])
# loop in BatchScrapMachines to change the classes if need be
for
node_id
,
node
in
nodes
.
iteritems
():
if
node
[
'_class'
]
==
'Dream.BatchScrapMachine'
:
# get the first successor. If it is BatchReassembly set the class to M3
successorIdList
=
self
.
getSuccessors
(
data
,
node_id
)
if
successorIdList
:
successorId
=
successorIdList
[
0
]
successorClass
=
nodes
[
successorId
][
'_class'
]
if
successorClass
==
'Dream.BatchReassembly'
:
data
[
'graph'
][
'node'
][
node_id
][
'_class'
]
=
'Dream.M3'
# get the first predecessor. If it is BatchDecomposition set the class to BatchScrapMachineAfterDecompose
predecessorIdList
=
self
.
getPredecessors
(
data
,
node_id
)
if
predecessorIdList
:
predecessorId
=
predecessorIdList
[
0
]
predecessorClass
=
nodes
[
predecessorId
][
'_class'
]
if
predecessorClass
==
'Dream.BatchDecomposition'
:
data
[
'graph'
][
'node'
][
node_id
][
'_class'
]
=
'Dream.BatchScrapMachineAfterDecompose'
# loop in BatchDecompositions to change the classes to BatchDecompositionBlocking
# XXX StartTime to be thought upon
for
node_id
,
node
in
nodes
.
iteritems
():
if
node
[
'_class'
]
==
'Dream.BatchDecomposition'
:
data
[
'graph'
][
'node'
][
node_id
][
'_class'
]
=
'Dream.BatchDecompositionBlocking'
# loop in BatchReassemblies to change the classes to BatchReassemblyBlocking
for
node_id
,
node
in
nodes
.
iteritems
():
if
node
[
'_class'
]
==
'Dream.BatchReassembly'
:
data
[
'graph'
][
'node'
][
node_id
][
'_class'
]
=
'Dream.BatchReassemblyBlocking'
# loop through the nodes to find the machines that do need addition
machinesThatNeedAddition
=
{}
for
node_id
,
node
in
nodes
.
iteritems
():
if
node
[
'_class'
]
==
'Dream.BatchScrapMachine'
and
self
.
checkIfMachineNeedsAddition
(
data
,
node_id
,
standardBatchUnits
):
machinesThatNeedAddition
[
node_id
]
=
node
# loop through the nodes
for
node_id
,
node
in
machinesThatNeedAddition
.
iteritems
():
# find BatchScrapMachines that process batches
import
math
workingBatchSize
=
int
((
node
.
get
(
'workingBatchSize'
)))
numberOfSubBatches
=
int
((
math
.
ceil
((
standardBatchUnits
/
float
(
workingBatchSize
)))))
#create a batchDecomposition
batchDecompositionId
=
node_id
+
'_D'
data
[
'graph'
][
'node'
][
batchDecompositionId
]
=
{
"name"
:
batchDecompositionId
,
"processingTime"
:
{
"Fixed"
:
{
"mean"
:
0
}
},
"numberOfSubBatches"
:
numberOfSubBatches
,
"wip"
:
[],
"element_id"
:
"DreamNode_39"
,
"_class"
:
"Dream.BatchDecompositionBlocking"
,
"id"
:
batchDecompositionId
}
#put the batchDecomposition between the predecessor and the node
for
edge_id
,
edge
in
edges
.
iteritems
():
if
edge
[
'destination'
]
==
node_id
:
source
=
edge
[
'source'
]
# remove the edge
data
[
'graph'
][
'edge'
].
pop
(
edge_id
,
None
)
# add an edge from source to batchDecomposition
self
.
addEdge
(
data
,
source
,
batchDecompositionId
)
# add an edge from batchDecomposition machine
self
.
addEdge
(
data
,
batchDecompositionId
,
node_id
)
#create a batchReassembly
batchReassemblyId
=
node_id
+
'_R'
data
[
'graph'
][
'node'
][
batchReassemblyId
]
=
{
"name"
:
batchReassemblyId
,
"processingTime"
:
{
"Fixed"
:
{
"mean"
:
0
}
},
"outputResults"
:
1
,
"numberOfSubBatches"
:
numberOfSubBatches
,
"wip"
:
[],
"_class"
:
"Dream.BatchReassemblyBlocking"
,
"id"
:
batchReassemblyId
}
#put the batchReassembly between the node and the successor
for
edge_id
,
edge
in
edges
.
iteritems
():
if
edge
[
'source'
]
==
node_id
:
destination
=
edge
[
'destination'
]
# remove the edge
data
[
'graph'
][
'edge'
].
pop
(
edge_id
,
None
)
# add an edge from machine to batchReassembly
self
.
addEdge
(
data
,
node_id
,
batchReassemblyId
)
# add an edge from batchReassembly to destination
self
.
addEdge
(
data
,
batchReassemblyId
,
destination
)
dataString
=
json
.
dumps
(
data
[
'graph'
][
'edge'
],
indent
=
5
)
# print dataString
# for node_id, node in nodes.iteritems():
# print node_id, node['_class']
return
data
# returns true if it is needed to add decomposition/reassembly
def
checkIfMachineNeedsAddition
(
self
,
data
,
machineId
,
standardBatchUnits
):
nodes
=
copy
(
data
[
'graph'
][
'node'
])
workingBatchSize
=
int
(
nodes
[
machineId
].
get
(
'workingBatchSize'
,
standardBatchUnits
))
# if the workingBatchSize is equal or higher to standardBatchUnits we do not need to add decomposition/reassembly
if
workingBatchSize
>=
standardBatchUnits
:
return
False
# loop in the predecessors
currentId
=
machineId
while
1
:
predecessorIdsList
=
self
.
getPredecessors
(
data
,
currentId
)
# get the first. In this model every machine is fed by one point
if
predecessorIdsList
:
predecessorId
=
predecessorIdsList
[
0
]
# if there is no predecessor, i.e. the start was reached break
else
:
break
predecessorClass
=
nodes
[
predecessorId
][
'_class'
]
# if BatchDecomposition is reached we are in subline so return False
if
predecessorClass
==
'Dream.BatchDecomposition'
:
return
False
# if BatchReassembly is reached we are not in subline so return True
elif
predecessorClass
==
'Dream.BatchReassembly'
:
return
True
currentId
=
predecessorId
return
True
\ No newline at end of file
dream/plugins/plugin.py
View file @
70cfe089
...
...
@@ -31,6 +31,36 @@ class InputPreparationPlugin(Plugin):
"""
return
data
# adds an edge with the given source and destination
def
addEdge
(
self
,
data
,
source
,
destination
,
nodeData
=
{}):
data
[
'graph'
][
'edge'
][
source
+
'_to_'
+
destination
]
=
{
"source"
:
source
,
"destination"
:
destination
,
"data"
:
{},
"_class"
:
"Dream.Edge"
}
return
data
# returns the predecessors of a node
def
getPredecessors
(
self
,
data
,
node_id
):
predecessors
=
[]
from
copy
import
copy
edges
=
copy
(
data
[
'graph'
][
'edge'
])
for
edge_id
,
edge
in
edges
.
iteritems
():
if
edge
[
'destination'
]
==
node_id
:
predecessors
.
append
(
edge
[
'source'
])
return
predecessors
# returns the successors of a node
def
getSuccessors
(
self
,
data
,
node_id
):
successors
=
[]
from
copy
import
copy
edges
=
copy
(
data
[
'graph'
][
'edge'
])
for
edge_id
,
edge
in
edges
.
iteritems
():
if
edge
[
'source'
]
==
node_id
:
successors
.
append
(
edge
[
'destination'
])
return
successors
class
OutputPreparationPlugin
(
Plugin
):
def
postprocess
(
self
,
data
):
"""Postprocess the data after simulation run.
...
...
dream/simulation/Examples/BatchAllInOneEmpty.json
View file @
70cfe089
This diff is collapsed.
Click to expand it.
dream/simulation/Examples/BatchModel.json
0 → 100644
View file @
70cfe089
This diff is collapsed.
Click to expand it.
dream/simulation/JSONInputs/Batches_VD_Sc1.json
View file @
70cfe089
...
...
@@ -692,7 +692,7 @@
}
},
"element_id"
:
"DreamNode_13"
,
"_class"
:
"Dream.
M3
"
,
"_class"
:
"Dream.
BatchScrapMachine
"
,
"id"
:
"St4M0"
},
"St6M1R"
:
{
...
...
dream/tests/dump/Batches_VD_Sc1.json.result
View file @
70cfe089
...
...
@@ -327,7 +327,7 @@
}
},
{
"_class": "Dream.
M3
",
"_class": "Dream.
BatchScrapMachine
",
"family": "Server",
"id": "St4M0",
"results": {
...
...
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