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
bc10b985
Commit
bc10b985
authored
Mar 26, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DemandPlanning plugins moved to separate folder
parent
5241294f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
0 deletions
+133
-0
dream/plugins/DemandPlanning/AddDemandPlannerGenerator.py
dream/plugins/DemandPlanning/AddDemandPlannerGenerator.py
+34
-0
dream/plugins/DemandPlanning/DemandPlanningLine.py
dream/plugins/DemandPlanning/DemandPlanningLine.py
+58
-0
dream/plugins/DemandPlanning/PostProcessDemandPlanning.py
dream/plugins/DemandPlanning/PostProcessDemandPlanning.py
+17
-0
dream/plugins/DemandPlanning/__init__.py
dream/plugins/DemandPlanning/__init__.py
+24
-0
No files found.
dream/plugins/DemandPlanning/AddDemandPlannerGenerator.py
0 → 100644
View file @
bc10b985
from
copy
import
copy
import
json
import
time
import
random
import
operator
import
datetime
from
dream.plugins
import
plugin
class
AddDemandPlannerGenerator
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
adds an EventGenerator that will call the Demand Planning algorithm once
"""
def
preprocess
(
self
,
data
):
nodes
=
data
[
'graph'
][
'node'
]
data_uri_encoded_input_data
=
data
[
'input'
].
get
(
self
.
configuration_dict
[
'input_id'
],
{})
algorithmAttributes
=
copy
(
data
[
'general'
])
nodes
[
'DPG'
]
=
{
"name"
:
"DemandPlannerGenerator"
,
"prioritizeIfCanFinish"
:
1
,
"interval"
:
1
,
"start"
:
0
,
"stop"
:
0.5
,
"_class"
:
"dream.simulation.EventGenerator.EventGenerator"
,
"method"
:
"dream.simulation.applications.DemandPlanning.executor_ACO.main"
,
"argumentDict"
:
{
'input'
:
data_uri_encoded_input_data
,
'algorithmAttributes'
:
algorithmAttributes
}
}
#print nodes
return
data
\ No newline at end of file
dream/plugins/DemandPlanning/DemandPlanningLine.py
0 → 100644
View file @
bc10b985
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
from
datetime
import
datetime
class
DemandPlanningLine
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
""" Output the queue statistics in a format compatible with Output_viewGraph
"""
def
postprocess
(
self
,
data
):
from
dream.simulation.applications.DemandPlanning.Globals
import
G
utilisation
=
G
.
Utilisation
# XXX current implementation for one bottleneck
for
bottleneck
in
[
'BE_A_VF78_DSO_3'
,
'BE_A_VK18_DKO_5'
]:
bottleNeckUtilization
=
G
.
Utilisation
[
bottleneck
]
dateList
=
[]
# get the current date from the data
for
record_id
,
record
in
bottleNeckUtilization
.
iteritems
():
year
=
str
(
record_id
)[
0
:
4
]
week
=
str
(
record_id
)[
4
:]
fullDate
=
datetime
.
strptime
(
year
+
'-'
+
week
+
'-0'
,
'%Y-%W-%w'
)
dateList
.
append
(
fullDate
)
currentDate
=
str
(
min
(
dateList
))
currentDate
=
currentDate
.
replace
(
'-'
,
'/'
)
data
[
'general'
][
'currentDate'
]
=
currentDate
data
[
'general'
][
'timeUnit'
]
=
'week'
self
.
initializeTimeSupport
(
data
)
result
=
data
[
'result'
][
'result_list'
][
-
1
]
series
=
[]
options
=
{
"xaxis"
:
{
"mode"
:
"time"
,
"minTickSize"
:
[
1
,
self
.
getTimeUnitText
()],
}
}
result
[
bottleneck
]
=
{
"series"
:
series
,
"options"
:
options
}
# create the 3 lines
for
utilizationType
in
[
'averageUtilization'
,
'minUtilization'
,
'maxUtilization'
]:
utilizationList
=
[]
for
record_id
,
record
in
bottleNeckUtilization
.
iteritems
():
year
=
str
(
record_id
)[
0
:
4
]
week
=
str
(
record_id
)[
4
:]
fullDate
=
datetime
.
strptime
(
year
+
'-'
+
week
+
'-0'
,
'%Y-%W-%w'
)
utilizationList
.
append
([
fullDate
,
record
[
utilizationType
]])
utilizationList
.
sort
(
key
=
lambda
x
:
x
[
0
],
reverse
=
True
)
series
.
append
({
"label"
:
utilizationType
,
"data"
:
[((
time
-
datetime
(
1970
,
1
,
1
)).
total_seconds
()
*
1000
,
value
)
for
(
time
,
value
)
in
utilizationList
]
})
return
data
dream/plugins/DemandPlanning/PostProcessDemandPlanning.py
0 → 100644
View file @
bc10b985
from
dream.plugins
import
plugin
class
PostProcessDemandPlanning
(
plugin
.
OutputPreparationPlugin
):
""" Output the result of demand planning in a format compatible with
Output_viewDownloadFile
"""
def
postprocess
(
self
,
data
):
# XXX the event generator should store its result in data and not in global
# variable.
from
dream.simulation.applications.DemandPlanning.Globals
import
G
data
[
'result'
][
'result_list'
][
-
1
][
self
.
configuration_dict
[
'output_id'
]]
=
{
'name'
:
'Result.xlsx'
,
'mime_type'
:
'application/vnd.ms-excel'
,
'data'
:
G
.
reportResults
.
xlsx
.
encode
(
'base64'
)
}
return
data
dream/plugins/DemandPlanning/__init__.py
0 → 100644
View file @
bc10b985
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try
:
__import__
(
'pkg_resources'
).
declare_namespace
(
__name__
)
except
ImportError
:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
\ 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