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
16248954
Commit
16248954
authored
Sep 02, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DemandPlanning: make a GUI class
parent
fe11a349
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
111 deletions
+189
-111
dream/simulation/AllocationManagement.py
dream/simulation/AllocationManagement.py
+2
-2
dream/simulation/FutureDemandCreator.py
dream/simulation/FutureDemandCreator.py
+1
-11
dream/simulation/GUI/DemandPlanning.py
dream/simulation/GUI/DemandPlanning.py
+186
-98
dream/simulation/GUI/inputs.xlsx
dream/simulation/GUI/inputs.xlsx
+0
-0
No files found.
dream/simulation/AllocationManagement.py
View file @
16248954
...
...
@@ -3,8 +3,8 @@ Created on 3 Oct 2013
@author: Anna
Basic implementation: runs the allocation routine for the future demand first
(one week at a time for the whole planning horizon) and the
PPOS after
Basic implementation: runs the allocation routine for the future demand first
(one week at a time for the whole planning horizon) and the
PPOS after
Equivalent to M2 in MATLAB functions
'''
...
...
dream/simulation/FutureDemandCreator.py
View file @
16248954
...
...
@@ -49,21 +49,11 @@ class FutureDemandCreator():
G
.
PPOSLateness
.
append
(
0
)
G
.
PPOSEarliness
.
append
(
0
)
G
.
Capacity
=
[]
wbin
=
xlrd
.
open_workbook
(
'GUI/inputs.xlsx'
)
sh
=
wbin
.
sheet_by_name
(
'Capacity'
)
nCols
=
sh
.
ncols
assert
(
nCols
==
G
.
planningHorizon
+
1
)
capacity
=
[]
for
i
in
range
(
1
,
nCols
):
capacity
.
append
(
sh
.
col_values
(
i
,
2
))
G
.
Capacity
=
capacity
G
.
currentCapacity
=
G
.
Capacity
# PPOS initial disaggregation profile
G
.
demandFile
=
'GUI/DemandProfile.xlsx'
G
.
demandFile
=
(
'/home/jerome/src/dream/dream/simulation/GUI/DemandProfile.xlsx'
)
wbin
=
xlrd
.
open_workbook
(
G
.
demandFile
)
MAData
=
G
.
RouteDict
...
...
dream/simulation/GUI/DemandPlanning.py
View file @
16248954
...
...
@@ -28,10 +28,12 @@ test script to convert the static excels to JSON. It does not communicate with G
import
xlwt
import
xlrd
import
json
from
AllocManagement
import
Alloc
Management
from
dream.simulation.AllocationManagement
import
Allocation
Management
from
dream.simulation.LineGenerationJSON
import
main
as
simulate_line_json
from
dream.simulation.Globals
import
G
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
from
dream.simulation.GUI.Default
import
schema
,
overloaded_property
class
IG
:
TargetPPOS
=
0
...
...
@@ -78,53 +80,61 @@ def createGlobals():
#===================================
# import simulation input data
#===================================
def
readGeneralInput
():
# general simulation input
wbin
=
xlrd
.
open_workbook
(
'GUI/inputs.xlsx'
)
sh
=
wbin
.
sheet_by_name
(
'Scalar_Var'
)
IG
.
TargetPPOS
=
int
(
sh
.
cell
(
2
,
1
).
value
)
-
1
IG
.
TargetPPOSqty
=
int
(
sh
.
cell
(
3
,
1
).
value
)
IG
.
TargetPPOSweek
=
int
(
sh
.
cell
(
6
,
1
).
value
)
-
1
G
.
planningHorizon
=
int
(
sh
.
cell
(
7
,
1
).
value
)
G
.
ReplicationNo
=
int
(
sh
.
cell
(
15
,
1
).
value
)
IG
.
maxEarliness
=
int
(
sh
.
cell
(
18
,
1
).
value
)
IG
.
maxLateness
=
int
(
sh
.
cell
(
19
,
1
).
value
)
IG
.
minPackingSize
=
int
(
sh
.
cell
(
22
,
1
).
value
)
# capacity information
sh
=
wbin
.
sheet_by_name
(
'Capacity'
)
nCols
=
sh
.
ncols
nRows
=
sh
.
nrows
assert
(
nCols
==
G
.
planningHorizon
+
1
)
capacity
=
[]
# for i in range(1,nCols):
# capacity.append(sh.col_values(i,2))
for
i
in
range
(
2
,
nRows
):
capacity
.
append
(
sh
.
row_values
(
i
,
1
,
4
))
def
readGeneralInput
(
data
):
# Info on PPOS to be disaggregated
# PPOS ID 1
# PPOS Quantity 430
IG
.
TargetPPOS
=
data
[
'general'
][
'TargetPPOS'
]
-
1
IG
.
TargetPPOSqty
=
data
[
'general'
][
'TargetPPOSqty'
]
# Time Line
# Week when the disaggregation has to be performed 2
# Planning horizon (consistent with capacity info) 3
IG
.
TargetPPOSweek
=
data
[
'general'
][
'TargetPPOSweek'
]
-
1
G
.
planningHorizon
=
data
[
'general'
][
'planningHorizon'
]
# Info on Global Demand - normal distribution parameters
# DistributionType Normal
# Mean 100000
# Standard Deviation 3000
# XXX those 3 cannot be configured
# Info on scenario analysis
# Number of Iterations 1
G
.
ReplicationNo
=
data
[
'general'
][
'numberOfReplications'
]
# Info on Time Cosntraints for Allocation
# Max Earliness 1
# Max Lateness 1
IG
.
maxEarliness
=
data
[
'general'
][
'maxEarliness'
]
IG
.
maxLateness
=
data
[
'general'
][
'maxLateness'
]
# Info on minimum allocable size
# Min Packing Size 10
IG
.
minPackingSize
=
data
[
'general'
][
'minPackingSize'
]
capacity_data
=
data
[
'dp_capacity_spreadsheet'
]
assert
(
len
(
capacity_data
[
0
])
==
G
.
planningHorizon
+
2
)
capacity
=
[]
for
i
in
range
(
2
,
len
(
capacity_data
)
-
1
):
capacity
.
append
([
int
(
x
)
for
x
in
capacity_data
[
i
][
1
:
-
1
]])
G
.
Capacity
=
capacity
# PPOS-MA disaggregation and corresponding routes
sh
=
wbin
.
sheet_by_name
(
'Route'
)
nRows
=
sh
.
nrows
nCols
=
sh
.
ncols
# prepare a dict that holds the capacity of every bottleneck per week
for
i
in
range
(
3
,
nCols
):
IG
.
CapacityDict
[
sh
.
cell
(
2
,
i
).
value
]
=
G
.
Capacity
[
i
-
3
]
for
i
in
range
(
4
,
nRows
):
tempPPOSlist
=
sh
.
row_values
(
i
,
0
,
3
)
id
=
tempPPOSlist
[
2
]
ppos
=
tempPPOSlist
[
0
]
sp
=
tempPPOSlist
[
1
]
routeValues
=
sh
.
row_values
(
i
,
3
,
nCols
)
IG
.
RouteDict
[
id
]
=
{
'PPOS'
:
ppos
,
'SP'
:
sp
,
'route'
:{}}
for
j
in
range
(
len
(
routeValues
)):
IG
.
RouteDict
[
id
][
'route'
][
sh
.
cell
(
2
,
j
+
3
).
value
]
=
routeValues
[
j
]
route_data
=
data
[
'dp_route_spreadsheet'
]
for
i
in
range
(
3
,
len
(
route_data
[
0
])
-
1
):
IG
.
CapacityDict
[
route_data
[
2
][
i
]]
=
G
.
Capacity
[
i
-
3
]
def
writeOutput
():
for
i
in
range
(
4
,
len
(
route_data
)
-
1
):
id
=
float
(
route_data
[
i
][
2
])
ppos
=
float
(
route_data
[
i
][
0
])
sp
=
float
(
route_data
[
i
][
1
])
IG
.
RouteDict
[
id
]
=
{
'PPOS'
:
ppos
,
'SP'
:
sp
,
'route'
:{}}
for
j
in
range
(
3
,
len
(
route_data
[
i
])
-
1
):
IG
.
RouteDict
[
id
][
'route'
][
route_data
[
2
][
j
]]
=
float
(
route_data
[
i
][
j
])
def
writeOutput
():
wbin
=
xlwt
.
Workbook
()
for
k
in
range
(
G
.
ReplicationNo
):
...
...
@@ -254,15 +264,92 @@ def writeOutput():
i
+=
1
wbin
.
save
(
"demandPlannerOutput.xls"
)
# temporary have a file for verification
def
main
():
import
StringIO
out
=
StringIO
.
StringIO
()
wbin
.
save
(
out
)
return
out
.
getvalue
()
class
Simulation
(
DefaultSimulation
):
def
getConfigurationDict
(
self
):
conf
=
{
'Dream-Configuration'
:
DefaultSimulation
.
getConfigurationDict
(
self
)[
'Dream-Configuration'
]}
conf
[
"Dream-Configuration"
][
"gui"
][
"exit_stat"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"debug_json"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"graph_editor"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"station_utilisation_graph"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"exit_stat"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"queue_stat"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"dp_capacity_spreadsheet"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"dp_route_spreadsheet"
]
=
1
prop_list
=
conf
[
"Dream-Configuration"
][
"property_list"
]
=
[]
prop_list
.
append
({
"id"
:
"TargetPPOS"
,
"name"
:
"PPOS ID"
,
"description"
:
"Info on PPOS to be disaggregated"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
1
})
prop_list
.
append
({
"id"
:
"TargetPPOSqty"
,
"name"
:
"PPOS Quantity"
,
"description"
:
"Info on PPOS to be disaggregated"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
430
})
prop_list
.
append
({
"id"
:
"TargetPPOSweek"
,
"name"
:
"PPOS Week"
,
"description"
:
"Week when the disaggregation has to be performed"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
2
})
prop_list
.
append
({
"id"
:
"planningHorizon"
,
"name"
:
"Planning horizon"
,
"description"
:
"Planning horizon (consistent with capacity info)"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
3
})
prop_list
.
append
(
overloaded_property
(
schema
[
'numberOfReplications'
],
{
'_default'
:
1
}))
prop_list
.
append
({
"id"
:
"maxEarliness"
,
"name"
:
"Max Earliness"
,
"description"
:
"Info on Time Constraints for Allocation"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
1
})
prop_list
.
append
({
"id"
:
"maxLateness"
,
"name"
:
"Max Lateness"
,
"description"
:
"Info on Time Constraints for Allocation"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
1
})
prop_list
.
append
({
"id"
:
"minPackingSize"
,
"name"
:
"Min Packing Size"
,
"description"
:
"Info on minimum allocable size"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
10
})
return
conf
def
run
(
self
,
data
):
# set up global variables
createGlobals
()
# read from inputs spreadsheet
readGeneralInput
()
# open json file
argumentDictFile
=
open
(
'inputFile.json'
,
mode
=
'w'
)
readGeneralInput
(
data
)
inputDict
=
{}
inputDict
[
'_class'
]
=
'Dream.Simulation'
...
...
@@ -300,11 +387,12 @@ def main():
inputDict
[
'nodes'
][
'AM'
][
'argumentDict'
][
'MAList'
]
=
IG
.
RouteDict
G
.
argumentDictString
=
json
.
dumps
(
inputDict
,
indent
=
5
)
argumentDictFile
.
write
(
G
.
argumentDictString
)
simulate_line_json
(
input_data
=
(
G
.
argumentDictString
))
# writeOutput() # currently to excel for verification. To be outputted in JSON
out
=
json
.
loads
(
simulate_line_json
(
input_data
=
(
G
.
argumentDictString
)))
output
=
writeOutput
()
out
[
'demandPlannerOutput.xls'
]
=
output
.
encode
(
'base64'
)
return
[{
'key'
:
'default'
,
'score'
:
0
,
'result'
:
out
}]
if
__name__
==
'__main__'
:
main
()
dream/simulation/GUI/inputs.xlsx
deleted
100644 → 0
View file @
fe11a349
File deleted
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