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
1fcc8ffa
Commit
1fcc8ffa
authored
Jul 13, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in the algorithm copied
parent
83f69770
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
153 additions
and
60 deletions
+153
-60
dream/plugins/DemandPlanning/DemandPlanningLine.py
dream/plugins/DemandPlanning/DemandPlanningLine.py
+16
-6
dream/simulation/applications/DemandPlanning/AllocationRoutine_Final2.py
...n/applications/DemandPlanning/AllocationRoutine_Final2.py
+22
-8
dream/simulation/applications/DemandPlanning/Globals.py
dream/simulation/applications/DemandPlanning/Globals.py
+2
-2
dream/simulation/applications/DemandPlanning/ImportInput.py
dream/simulation/applications/DemandPlanning/ImportInput.py
+78
-26
dream/simulation/applications/DemandPlanning/UtilisationCalculation.py
...ion/applications/DemandPlanning/UtilisationCalculation.py
+15
-6
dream/simulation/applications/DemandPlanning/executor_M_controlled.py
...tion/applications/DemandPlanning/executor_M_controlled.py
+18
-10
dream/simulation/applications/DemandPlanning/outputResults.py
...m/simulation/applications/DemandPlanning/outputResults.py
+2
-2
No files found.
dream/plugins/DemandPlanning/DemandPlanningLine.py
View file @
1fcc8ffa
...
...
@@ -34,8 +34,13 @@ class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin):
options
=
{
"xaxis"
:
{
"mode"
:
"time"
,
"minTickSize"
:
[
1
,
self
.
getTimeUnitText
()],
}
#"minTickSize": [1, self.getTimeUnitText()],
"minTickSize"
:
[
1
,
"day"
],
},
"legend"
:
{
"backgroundOpacity"
:
0.1
,
"position"
:
"se"
,
},
}
bottleNeckUtilizationDict
[
bottleneck
]
=
{
...
...
@@ -84,13 +89,18 @@ class BottleNeckByWeek(plugin.OutputPreparationPlugin, TimeSupportMixin):
for
week
,
bottleneckData
in
by_week
.
items
():
series
=
[]
ticks
=
list
(
enumerate
(
bottleneckData
.
keys
()))
#ticks = list(enumerate(bottleneckData.keys()))
ticks
=
list
(
enumerate
(
G
.
Bottlenecks
))
options
=
{
"xaxis"
:
{
"minTickSize"
:
1
,
"ticks"
:
ticks
},
"legend"
:
{
"backgroundOpacity"
:
0.1
,
"position"
:
"se"
,
},
"series"
:
{
"bars"
:
{
"show"
:
True
,
...
...
@@ -115,7 +125,7 @@ class BottleNeckByWeek(plugin.OutputPreparationPlugin, TimeSupportMixin):
(
'maxUtilization'
,
'Target Utilization'
)
]:
series
.
append
({
"label"
:
utilizationLabel
,
"data"
:
list
(
enumerate
([
x
[
utilizationType
]
for
x
in
bottleneckData
.
values
()
])),
"data"
:
list
(
enumerate
([
bottleneckData
[
x
][
utilizationType
]
for
x
in
G
.
Bottlenecks
])),
})
return
data
\ No newline at end of file
dream/simulation/applications/DemandPlanning/AllocationRoutine_Final2.py
View file @
1fcc8ffa
...
...
@@ -150,9 +150,9 @@ def AllocationRoutine_Final(initialWeek, itemList, itemType, ant):
# for orders add allocation information
if
itemType
==
'order'
:
if
chosenMA
==
None
:
G
.
OrderResults
.
append
((
item
[
'orderID'
],
item
[
'sp'
],
item
[
'MAlist'
],
item
[
'Week'
],
item
[
'
Customer'
],
item
[
'
Qty'
],
item
[
'priority'
],
chosenMA
,
oMAlist2
,
'NaN'
,
'NaN'
,
'None'
))
G
.
OrderResults
.
append
((
item
[
'orderID'
],
item
[
'sp'
],
item
[
'MAlist'
],
item
[
'Week'
],
item
[
'Qty'
],
item
[
'priority'
],
chosenMA
,
oMAlist2
,
'NaN'
,
'NaN'
,
'None'
))
else
:
G
.
OrderResults
.
append
((
item
[
'orderID'
],
item
[
'sp'
],
item
[
'MAlist'
],
item
[
'Week'
],
item
[
'
Customer'
],
item
[
'
Qty'
],
item
[
'priority'
],
chosenMA
,
oMAlist2
,
Results
[
chosenMA
][
'lateness'
],
Results
[
chosenMA
][
'earliness'
],
Results
[
chosenMA
][
'Allocation'
]))
G
.
OrderResults
.
append
((
item
[
'orderID'
],
item
[
'sp'
],
item
[
'MAlist'
],
item
[
'Week'
],
item
[
'Qty'
],
item
[
'priority'
],
chosenMA
,
oMAlist2
,
Results
[
chosenMA
][
'lateness'
],
Results
[
chosenMA
][
'earliness'
],
Results
[
chosenMA
][
'Allocation'
]))
if
itemType
==
'forecast'
:
if
chosenMA
==
None
:
...
...
@@ -180,8 +180,15 @@ def choseMA(allResults, possibleSolutions, MAlist, weeklist):
for
week
in
weeklist
:
for
bn
in
allResults
[
ma
][
'utilisation'
]:
if
week
in
allResults
[
ma
][
'utilisation'
][
bn
]:
if
G
.
Capacity
[
bn
][
week
][
'minUtilisation'
]:
minUtil
.
append
(
max
(
0
,
(
G
.
Capacity
[
bn
][
week
][
'minUtilisation'
]
-
allResults
[
ma
][
'utilisation'
][
bn
][
week
])
/
G
.
Capacity
[
bn
][
week
][
'minUtilisation'
]))
else
:
minUtil
.
append
(
max
(
0
,
(
G
.
Capacity
[
bn
][
week
][
'minUtilisation'
]
-
allResults
[
ma
][
'utilisation'
][
bn
][
week
])))
if
G
.
Capacity
[
bn
][
week
][
'targetUtilisation'
]:
targetUtil
.
append
((
G
.
Capacity
[
bn
][
week
][
'targetUtilisation'
]
-
allResults
[
ma
][
'utilisation'
][
bn
][
week
])
/
G
.
Capacity
[
bn
][
week
][
'targetUtilisation'
])
else
:
targetUtil
.
append
(
G
.
Capacity
[
bn
][
week
][
'targetUtilisation'
]
-
allResults
[
ma
][
'utilisation'
][
bn
][
week
])
res
.
append
([
ma
,
allResults
[
ma
][
'remainingUnits'
],
allResults
[
ma
][
'lateness'
],
std
(
array
(
targetUtil
)),
std
(
array
(
minUtil
)),
allResults
[
ma
][
'earliness'
]])
...
...
@@ -218,13 +225,20 @@ def choseMA2(allResults, possibleSolutions, MAlist, weeklist): # more simil
targetU
=
[]
for
week
in
weeklist
:
utilisation
=
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
allResults
[
ma
][
'remainingCap'
][
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
if
G
.
Capacity
[
bottleneck
][
week
][
'minUtilisation'
]:
minU
.
append
(
max
(
0
,
(
G
.
Capacity
[
bottleneck
][
week
][
'minUtilisation'
]
-
utilisation
)
/
G
.
Capacity
[
bottleneck
][
week
][
'minUtilisation'
]))
else
:
minU
.
append
(
max
(
0
,
(
G
.
Capacity
[
bottleneck
][
week
][
'minUtilisation'
]
-
utilisation
)))
if
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]:
targetU
.
append
((
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
/
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
else
:
targetU
.
append
((
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]))
minUtil
.
append
(
mean
(
array
(
minU
)))
targetUtil
.
append
(
mean
(
absolute
(
targetU
)))
res
.
append
([
ma
,
allResults
[
ma
][
'remainingUnits'
],
allResults
[
ma
][
'lateness'
],
std
(
array
(
targetUtil
)),
std
(
array
(
minUtil
)),
allResults
[
ma
][
'earliness'
]])
res
.
append
([
ma
,
allResults
[
ma
][
'remainingUnits'
],
allResults
[
ma
][
'lateness'
],
mean
(
array
(
targetUtil
)),
mean
(
array
(
minUtil
)),
allResults
[
ma
][
'earliness'
]])
# order results...1st criterion: target utilisation (stdDev), 2nd criterion: min utilisation(stdDev)
sortedMA
=
sorted
(
res
,
key
=
itemgetter
(
1
,
2
,
3
,
4
,
5
))
...
...
dream/simulation/applications/DemandPlanning/Globals.py
View file @
1fcc8ffa
...
...
@@ -80,7 +80,7 @@ class G:
# output variables
reportResults
=
tablib
.
Databook
()
OrderResults
=
tablib
.
Dataset
(
title
=
'OrderSummary'
)
OrderResults
.
headers
=
(
'OrderID'
,
'SP_NUMBER'
,
'MA_LIST'
,
'REQUEST_DATE'
,
'
DFSELLER'
,
'
ORDERQTY'
,
'PRIORITY'
,
'CHOSEN_MA'
,
'ORDERED_MA_LIST'
,
'LATENESS'
,
'EARLINESS'
,
'ALLOCATION'
)
OrderResults
.
headers
=
(
'OrderID'
,
'SP_NUMBER'
,
'MA_LIST'
,
'REQUEST_DATE'
,
'ORDERQTY'
,
'PRIORITY'
,
'CHOSEN_MA'
,
'ORDERED_MA_LIST'
,
'LATENESS'
,
'EARLINESS'
,
'ALLOCATION'
)
forecastResults
=
tablib
.
Dataset
(
title
=
'ForecastSummary'
)
forecastResults
.
headers
=
(
'PPOS'
,
'SP_NUMBER'
,
'MA_LIST'
,
'REQUEST_DATE'
,
'ORDERQTY'
,
'PRIORITY'
,
'CHOSEN_MA'
,
'LATENESS'
,
'EARLINESS'
,
'ALLOCATION'
)
globalMAAllocation
=
{}
...
...
@@ -150,7 +150,7 @@ def initialiseVar():
# output variables
G
.
reportResults
=
tablib
.
Databook
()
G
.
OrderResults
=
tablib
.
Dataset
(
title
=
'OrderSummary'
)
G
.
OrderResults
.
headers
=
(
'OrderID'
,
'SP_NUMBER'
,
'MA_LIST'
,
'REQUEST_DATE'
,
'
DFSELLER'
,
'
ORDERQTY'
,
'PRIORITY'
,
'CHOSEN_MA'
,
'ORDERED_MA_LIST'
,
'LATENESS'
,
'EARLINESS'
,
'ALLOCATION'
)
G
.
OrderResults
.
headers
=
(
'OrderID'
,
'SP_NUMBER'
,
'MA_LIST'
,
'REQUEST_DATE'
,
'ORDERQTY'
,
'PRIORITY'
,
'CHOSEN_MA'
,
'ORDERED_MA_LIST'
,
'LATENESS'
,
'EARLINESS'
,
'ALLOCATION'
)
G
.
forecastResults
=
tablib
.
Dataset
(
title
=
'ForecastSummary'
)
G
.
forecastResults
.
headers
=
(
'PPOS'
,
'SP_NUMBER'
,
'MA_LIST'
,
'REQUEST_DATE'
,
'ORDERQTY'
,
'PRIORITY'
,
'CHOSEN_MA'
,
'LATENESS'
,
'EARLINESS'
,
'ALLOCATION'
)
G
.
CapacityResults
=
None
...
...
dream/simulation/applications/DemandPlanning/ImportInput.py
View file @
1fcc8ffa
...
...
@@ -50,6 +50,7 @@ def ImportInput(input, algorithmAttributes):
wbin
=
xlrd
.
open_workbook
(
file_contents
=
attachement_data
)
G
.
maxEarliness
=
algorithmAttributes
.
get
(
'maxEarliness'
,
None
)
G
.
maxLateness
=
algorithmAttributes
.
get
(
'maxLateness'
,
None
)
startWeek
=
algorithmAttributes
.
get
(
'CurrentWeek'
,
None
)
# utilisation calculation
G
.
minDeltaUt
=
algorithmAttributes
.
get
(
'minDelta'
,
None
)
...
...
@@ -81,12 +82,24 @@ def ImportInput(input, algorithmAttributes):
sh
=
wbin
.
sheet_by_name
(
'BN_Capa'
)
rows
=
sh
.
nrows
G
.
planningHorizon
=
sh
.
ncols
-
2
Weeks
=
{}
for
week
in
range
(
2
,
sh
.
ncols
):
w
=
2
while
w
<
sh
.
ncols
and
withoutFormat
(
1
,
w
,
sh
,
1
)
!=
startWeek
:
w
+=
1
if
w
==
sh
.
ncols
:
print
"please enter a valid week value"
return
"stop"
refCap
=
{}
noTarget
=
[]
for
week
in
range
(
w
,
sh
.
ncols
):
Weeks
[
week
]
=
withoutFormat
(
1
,
week
,
sh
,
1
)
G
.
WeekList
.
append
(
withoutFormat
(
1
,
week
,
sh
,
1
))
refCap
[
Weeks
[
week
]]
=
1
G
.
planningHorizon
=
len
(
G
.
WeekList
)
for
row
in
range
(
2
,
rows
,
4
):
bn
=
withoutFormat
(
row
,
0
,
sh
,
0
)
...
...
@@ -95,18 +108,42 @@ def ImportInput(input, algorithmAttributes):
G
.
Capacity
[
bn
]
=
{}
#{'OriginalCapacity':{}, 'RemainingCapacity':{}, 'minUtilisation':{}, 'targetUtilisation':{}}
G
.
CurrentCapacityDictOrig
[
bn
]
=
{}
for
week
in
range
(
2
,
sh
.
ncols
):
G
.
Capacity
[
bn
][
Weeks
[
week
]]
=
{
'OriginalCapacity'
:
withoutFormat
(
row
,
week
,
sh
,
1
),
'RemainingCapacity'
:
withoutFormat
(
row
+
1
,
week
,
sh
,
1
),
'minUtilisation'
:
withoutFormat
(
row
+
2
,
week
,
sh
,
0
),
'targetUtilisation'
:
withoutFormat
(
row
+
3
,
week
,
sh
,
0
)}
for
week
in
range
(
w
,
sh
.
ncols
):
G
.
Capacity
[
bn
][
Weeks
[
week
]]
=
{
'OriginalCapacity'
:
withoutFormat
(
row
,
week
,
sh
,
1
),
'RemainingCapacity'
:
withoutFormat
(
row
+
1
,
week
,
sh
,
1
),
'minUtOrig'
:
withoutFormat
(
row
+
2
,
week
,
sh
,
0
),
'targetUtOrig'
:
withoutFormat
(
row
+
3
,
week
,
sh
,
0
)}
if
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'minUtOrig'
]
==
''
:
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'minUtilisation'
]
=
0
else
:
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'minUtilisation'
]
=
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'minUtOrig'
]
if
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'targetUtOrig'
]
==
''
:
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'targetUtilisation'
]
=
1
noTarget
.
append
([
bn
,
Weeks
[
week
]])
else
:
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'targetUtilisation'
]
=
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'targetUtOrig'
]
if
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'targetUtOrig'
]
<
refCap
[
Weeks
[
week
]]:
refCap
[
Weeks
[
week
]]
=
G
.
Capacity
[
bn
][
Weeks
[
week
]][
'targetUtOrig'
]
G
.
CurrentCapacityDictOrig
[
bn
][
Weeks
[
week
]]
=
withoutFormat
(
row
,
week
,
sh
,
1
)
for
coppie
in
noTarget
:
if
refCap
[
coppie
[
1
]]
==
1
:
refCap
[
coppie
[
1
]]
=
0
G
.
Capacity
[
coppie
[
0
]][
coppie
[
1
]][
'targetUtilisation'
]
=
refCap
[
coppie
[
1
]]
# Import loading factors
sh
=
wbin
.
sheet_by_name
(
'BN_Load Factor'
)
rows
=
sh
.
nrows
w
=
3
while
withoutFormat
(
1
,
w
,
sh
,
1
)
!=
startWeek
:
w
+=
1
Weeks
=
{}
for
week
in
range
(
3
,
sh
.
ncols
):
for
week
in
range
(
w
,
sh
.
ncols
):
Weeks
[
week
]
=
withoutFormat
(
1
,
week
,
sh
,
1
)
for
row
in
range
(
2
,
rows
):
...
...
@@ -125,15 +162,19 @@ def ImportInput(input, algorithmAttributes):
bn
=
withoutFormat
(
row
,
2
,
sh
,
0
)
G
.
RouteDict
[
ma
][
bn
]
=
{}
for
week
in
range
(
3
,
sh
.
ncols
):
for
week
in
range
(
w
,
sh
.
ncols
):
G
.
RouteDict
[
ma
][
bn
][
Weeks
[
week
]]
=
withoutFormat
(
row
,
week
,
sh
,
0
)
# Import batch size
sh
=
wbin
.
sheet_by_name
(
'BatchSize'
)
rows
=
sh
.
nrows
w
=
2
while
withoutFormat
(
2
,
w
,
sh
,
1
)
!=
startWeek
:
w
+=
1
Weeks
=
{}
for
week
in
range
(
2
,
sh
.
ncols
):
for
week
in
range
(
w
,
sh
.
ncols
):
Weeks
[
week
]
=
withoutFormat
(
2
,
week
,
sh
,
1
)
for
row
in
range
(
3
,
rows
):
...
...
@@ -144,7 +185,7 @@ def ImportInput(input, algorithmAttributes):
G
.
BatchSize
[
ma
]
=
{}
G
.
incompleteBatches
[
ma
]
=
0
for
week
in
range
(
2
,
sh
.
ncols
):
for
week
in
range
(
w
,
sh
.
ncols
):
G
.
BatchSize
[
ma
][
Weeks
[
week
]]
=
withoutFormat
(
row
,
week
,
sh
,
0
)
# G.incompleteBatches[ma][Weeks[week]] = 0
...
...
@@ -153,24 +194,28 @@ def ImportInput(input, algorithmAttributes):
sh
=
wbin
.
sheet_by_name
(
'OrderSummary'
)
rows
=
sh
.
nrows
orderID
=
1
G
.
priorityList
[
'order'
]
=
[]
G
.
sortedOrders
[
'order'
]
=
{}
for
row
in
range
(
1
,
rows
):
week
=
withoutFormat
(
row
,
3
,
sh
,
1
)
if
week
<
startWeek
:
continue
orderID
=
withoutFormat
(
row
,
2
,
sh
,
0
)
G
.
orders
[
orderID
]
=
{}
G
.
orders
[
orderID
][
'orderID'
]
=
orderID
G
.
orders
[
orderID
][
'ppos'
]
=
0
G
.
orders
[
orderID
][
'sp'
]
=
withoutFormat
(
row
,
1
,
sh
,
0
)
maList
=
withoutFormat
(
row
,
2
,
sh
,
0
)
G
.
orders
[
orderID
][
'sp'
]
=
withoutFormat
(
row
,
0
,
sh
,
0
)
maList
=
withoutFormat
(
row
,
1
,
sh
,
0
)
maList
=
my_split
(
maList
,
[
'; '
,
';'
])
print
'malist'
,
maList
maList
.
remove
(
''
)
G
.
orders
[
orderID
][
'MAlist'
]
=
maList
week
=
withoutFormat
(
row
,
3
,
sh
,
1
)
G
.
orders
[
orderID
][
'Week'
]
=
week
G
.
orders
[
orderID
][
'Customer'
]
=
withoutFormat
(
row
,
4
,
sh
,
0
)
G
.
orders
[
orderID
][
'Qty'
]
=
withoutFormat
(
row
,
5
,
sh
,
0
)
priority
=
withoutFormat
(
row
,
6
,
sh
,
1
)
G
.
orders
[
orderID
][
'Qty'
]
=
withoutFormat
(
row
,
4
,
sh
,
0
)
priority
=
withoutFormat
(
row
,
5
,
sh
,
1
)
G
.
orders
[
orderID
][
'priority'
]
=
priority
if
priority
not
in
G
.
priorityList
[
'order'
]:
G
.
priorityList
[
'order'
].
append
(
priority
)
...
...
@@ -179,19 +224,22 @@ def ImportInput(input, algorithmAttributes):
if
week
not
in
G
.
sortedOrders
[
'order'
][
priority
]:
G
.
sortedOrders
[
'order'
][
priority
][
week
]
=
[]
G
.
sortedOrders
[
'order'
][
priority
][
week
].
append
(
G
.
orders
[
orderID
])
orderID
+=
1
print
'sorted orders keys'
,
G
.
sortedOrders
[
'order'
].
keys
()
# Import forecast
sh
=
wbin
.
sheet_by_name
(
'FC_Summary'
)
rows
=
sh
.
nrows
G
.
priorityList
[
'forecast'
]
=
[]
G
.
sortedOrders
[
'forecast'
]
=
{}
Weeks
=
{}
w
=
3
while
withoutFormat
(
1
,
w
,
sh
,
1
)
!=
startWeek
:
w
+=
1
for
week
in
range
(
3
,
sh
.
ncols
):
Weeks
[
week
]
=
withoutFormat
(
1
,
week
,
sh
,
1
)
row
=
2
row
=
w
while
row
<
rows
:
newSp
=
withoutFormat
(
row
,
1
,
sh
,
0
)
...
...
@@ -210,6 +258,8 @@ def ImportInput(input, algorithmAttributes):
subRow
+=
1
print
'ma sug'
,
maSuggested
,
subRow
oID
=
1
orderID
=
'Forecast_'
+
str
(
oID
)
for
week
in
range
(
4
,
sh
.
ncols
):
qty
=
withoutFormat
(
row
+
subRow
,
week
,
sh
,
1
)
if
qty
:
...
...
@@ -233,7 +283,8 @@ def ImportInput(input, algorithmAttributes):
if
Weeks
[
week
]
not
in
G
.
sortedOrders
[
'forecast'
][
priority
]:
G
.
sortedOrders
[
'forecast'
][
priority
][
Weeks
[
week
]]
=
[]
G
.
sortedOrders
[
'forecast'
][
priority
][
Weeks
[
week
]].
append
(
G
.
orders
[
orderID
])
orderID
+=
1
oID
+=
1
orderID
=
'Forecast_'
+
str
(
oID
)
row
+=
subRow
+
1
...
...
@@ -282,3 +333,4 @@ def ImportInput(input, algorithmAttributes):
if
__name__
==
'__main__'
:
ImportInput
()
\ No newline at end of file
dream/simulation/applications/DemandPlanning/UtilisationCalculation.py
View file @
1fcc8ffa
...
...
@@ -51,12 +51,15 @@ def utilisationCalc1(ACOcapacityDict, initialWeek, ind):
for
week
in
weekList
:
utilisation
=
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
ACOcapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
minU
.
append
(
utilisation
>
G
.
Capacity
[
bottleneck
][
week
][
'minUtilisation'
])
if
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]:
targetU
.
append
(
float
(
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
/
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
else
:
targetU
.
append
(
float
(
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]))
minUtil
.
append
(
mean
(
array
(
minU
)))
targetUtil
.
append
(
mean
(
absolute
(
targetU
)))
ACOtargetUtil
=
std
(
array
(
targetUtil
))
#mean(array(targetUtil)) #FIXME: potrebbe essere std(array(targetUtil))
ACOtargetUtil
=
mean
(
array
(
targetUtil
))
#mean(array(targetUtil)) #FIXME: potrebbe essere std(array(targetUtil))
ACOminUtil
=
mean
(
array
(
minUtil
))
*-
1
return
ACOtargetUtil
,
ACOminUtil
...
...
@@ -72,11 +75,14 @@ def utilisationCalc2(ACOcapacityDict, initialWeek, ind):
minUtil
=
[]
targetUtil
=
[]
for
bottleneck
in
G
.
Bottlenecks
:
weekList
=
[
initialWeek
]
+
[
G
.
WeekList
[
i
]
for
i
in
range
(
ind
-
1
,
max
(
-
1
,
ind
-
G
.
maxEarliness
-
1
),
-
1
)]
weekList
=
[
initialWeek
]
#
+ [G.WeekList[i] for i in range(ind-1, max(-1,ind-G.maxEarliness-1), -1)]
for
week
in
weekList
:
utilisation
=
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
ACOcapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
minUtil
.
append
(
utilisation
>
G
.
Capacity
[
bottleneck
][
week
][
'minUtilisation'
])
if
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]:
targetUtil
.
append
(
float
(
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
/
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
else
:
targetUtil
.
append
(
float
(
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]))
ACOtargetUtil
=
std
(
array
(
targetUtil
))
ACOminUtil
=
mean
(
array
(
minUtil
))
*-
1
...
...
@@ -100,7 +106,10 @@ def utilisationCalc3(ACOcapacityDict, initialWeek, ind):
for
week
in
weekList
:
utilisation
=
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
ACOcapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
minU
.
append
(
utilisation
)
if
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]:
targetU
.
append
(
float
(
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
/
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
else
:
targetU
.
append
(
float
(
utilisation
-
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]))
minUtil
.
append
(
mean
(
array
(
minU
)))
targetUtil
.
append
(
mean
(
array
(
max
(
minU
))))
...
...
dream/simulation/applications/DemandPlanning/executor_M_controlled.py
View file @
1fcc8ffa
...
...
@@ -29,22 +29,27 @@ from ImportInput import ImportInput
from
outputResults
import
outputResults
from
Globals
import
G
,
initialiseVar
import
time
from
numpy
import
mean
,
std
,
array
from
numpy
import
mean
,
std
,
array
,
absolute
from
operator
import
itemgetter
def
main
(
input
,
algorithmAttributes
):
startTime
=
time
.
time
()
ImportInput
(
input
,
algorithmAttributes
)
if
str
(
G
.
ACO
).
lower
()
==
"all"
:
ver
=
ImportInput
(
input
,
algorithmAttributes
)
if
ver
==
"stop"
:
return
if
G
.
ACO
==
"all"
:
G
.
acoRange
=
[
0
,
1
]
G
.
minRange
=
{
0
:[
0
,
1
],
1
:[
0
,
1
]}
elif
str
(
G
.
ACO
)
==
"1"
:
G
.
acoRange
=
[
0
,
1
]
G
.
minRange
=
{
0
:[
0
,
1
],
1
:[
G
.
minDeltaUt
]}
elif
G
.
ACO
==
"1"
:
G
.
acoRange
=
[
1
]
G
.
minRange
=
{
0
:[
0
,
1
],
1
:[
G
.
minDeltaUt
]}
else
:
G
.
acoRange
=
[
0
]
G
.
minRange
=
{
0
:[
G
.
minDeltaUt
]}
for
j
in
G
.
acoRange
:
for
i
in
G
.
minRange
[
j
]:
initialiseVar
()
...
...
@@ -68,9 +73,12 @@ def main(input, algorithmAttributes):
for
bottleneck
in
G
.
Bottlenecks
:
for
week
in
G
.
WeekList
:
utilisation
.
append
(
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
G
.
CurrentCapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
])
if
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]:
targetUt
.
append
((
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]
-
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
G
.
CurrentCapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
])
/
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
])
else
:
targetUt
.
append
((
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]
-
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
G
.
CurrentCapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]))
G
.
Summary
[(
G
.
ACO
,
G
.
minDeltaUt
)][
'utilisation'
]
=
mean
(
array
(
utilisation
))
G
.
Summary
[(
G
.
ACO
,
G
.
minDeltaUt
)][
'targetM'
]
=
mean
(
a
rray
(
targetUt
))
G
.
Summary
[(
G
.
ACO
,
G
.
minDeltaUt
)][
'targetM'
]
=
mean
(
a
bsolute
(
array
(
targetUt
)
))
G
.
Summary
[(
G
.
ACO
,
G
.
minDeltaUt
)][
'targetStd'
]
=
std
(
array
(
targetUt
))
if
G
.
ACO
:
G
.
Summary
[(
G
.
ACO
,
G
.
minDeltaUt
)][
'ant'
]
=
bestAnt
...
...
@@ -81,7 +89,7 @@ def main(input, algorithmAttributes):
# selection
listSummary
=
[
G
.
Summary
[
item
]
for
item
in
G
.
Summary
.
keys
()]
print
'list summary'
,
listSummary
listSummary
=
sorted
(
listSummary
,
key
=
itemgetter
(
'exUnits'
,
'lateness'
,
'target
Std'
,
'utilisation'
,
'targetM
'
,
'earliness'
))
listSummary
=
sorted
(
listSummary
,
key
=
itemgetter
(
'exUnits'
,
'lateness'
,
'target
M'
,
'targetStd'
,
'utilisation
'
,
'earliness'
))
bestScenario
=
listSummary
[
0
][
'scenario'
]
aco
=
bestScenario
[
0
]
...
...
dream/simulation/applications/DemandPlanning/outputResults.py
View file @
1fcc8ffa
...
...
@@ -71,7 +71,7 @@ def outputResults():
G
.
CapacityResults
.
append
([
bottleneck
,
'Capa Pegging Resource Capacity (UoM)'
,]
+
initialCap
)
G
.
CapacityResults
.
append
([
''
,
'Capa Pegging Resource Total Load (UoM)'
,]
+
[
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
G
.
CurrentCapacityDict
[
bottleneck
][
week
]
for
week
in
G
.
WeekList
])
G
.
CapacityResults
.
append
([
''
,
'Capa Pegging Resource Total Util (Percent)'
,]
+
[
float
(
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
-
G
.
CurrentCapacityDict
[
bottleneck
][
week
])
/
G
.
Capacity
[
bottleneck
][
week
][
'OriginalCapacity'
]
*
100
for
week
in
G
.
WeekList
])
G
.
CapacityResults
.
append
([
''
,
'Capa Pegging Resource Min Util (Percent)'
,]
+
[
G
.
Capacity
[
bottleneck
][
week
][
'minUt
ilisation
'
]
*
100
for
week
in
G
.
WeekList
])
G
.
CapacityResults
.
append
([
''
,
'Capa Pegging Resource Min Util (Percent)'
,]
+
[
G
.
Capacity
[
bottleneck
][
week
][
'minUt
Orig
'
]
*
100
for
week
in
G
.
WeekList
])
G
.
CapacityResults
.
append
([
''
,
'Capa Pegging Resource Target Util (Percent)'
,]
+
[
G
.
Capacity
[
bottleneck
][
week
][
'targetUtilisation'
]
*
100
for
week
in
G
.
WeekList
])
# utilisation 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