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
3d7e4ee8
Commit
3d7e4ee8
authored
Feb 27, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
capacity instance updated so that the user can define pool of capacity
parent
2db61a50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
13 deletions
+51
-13
dream/plugins/AvailableCapacitySpreadsheet.py
dream/plugins/AvailableCapacitySpreadsheet.py
+45
-13
dream/simulation/Examples/GUI_instances/CapacityProjectAllInOneEmpty.json
.../Examples/GUI_instances/CapacityProjectAllInOneEmpty.json
+6
-0
No files found.
dream/plugins/AvailableCapacitySpreadsheet.py
View file @
3d7e4ee8
...
@@ -12,24 +12,55 @@ class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
...
@@ -12,24 +12,55 @@ class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
read capacity data and update the capacity property of the stations.
read capacity data and update the capacity property of the stations.
"""
"""
def
preprocess
(
self
,
data
):
def
preprocess
(
self
,
data
):
strptime
=
datetime
.
datetime
.
strptime
strptime
=
datetime
.
datetime
.
strptime
capacityData
=
data
[
'input'
].
get
(
'available_capacity_spreadsheet'
,
None
)
capacityData
=
data
[
'input'
].
get
(
'available_capacity_spreadsheet'
,
None
)
node
=
data
[
'graph'
][
'node'
]
nodes
=
data
[
'graph'
][
'node'
]
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
if
capacityData
:
if
capacityData
:
# get the number of stations
poolDict
=
{}
numberOfStations
=
len
([
st
for
st
in
capacityData
[
0
]
if
(
st
and
not
st
==
'DAY'
)])
for
node_id
,
node
in
nodes
.
iteritems
():
pool
=
node
.
get
(
'pool'
,
None
)
if
pool
and
not
pool
in
nodes
.
keys
():
if
not
poolDict
.
get
(
pool
,
None
):
poolDict
[
pool
]
=
[]
poolDict
[
pool
].
append
(
node_id
)
# loop through columns and get those that contain a pool
columnsToErase
=
[]
for
col
in
range
(
len
(
copy
(
capacityData
[
0
]))):
# if the column contains a pool create new columns with the actual station id
if
capacityData
[
0
][
col
]
in
poolDict
.
keys
():
pool
=
capacityData
[
0
][
col
]
if
pool
in
[
'DAY'
,
None
,
''
]:
continue
poolCapacity
=
[
c
[
col
]
for
c
in
capacityData
]
columnsToErase
.
append
(
col
)
for
stationId
in
poolDict
[
pool
]:
capacityData
[
0
].
append
(
stationId
)
i
=
1
for
row
in
capacityData
[
1
:]:
row
.
append
(
poolCapacity
[
i
])
i
+=
1
# erase the columns that contain pools
for
col
in
columnsToErase
:
for
row
in
capacityData
:
row
.
pop
(
col
)
# loop through stations
# loop through stations
for
col
in
range
(
numberOfStations
):
for
col
in
range
(
len
(
capacityData
[
0
])):
stationId
=
capacityData
[
0
][
col
+
1
]
stationId
=
capacityData
[
0
][
col
]
if
stationId
in
[
'DAY'
,
None
,
''
]:
continue
assert
stationId
in
data
[
'graph'
][
'node'
].
keys
(),
(
'available capacity spreadsheet has station id:'
,
stationId
,
assert
stationId
in
data
[
'graph'
][
'node'
].
keys
(),
(
'available capacity spreadsheet has station id:'
,
stationId
,
'that does not exist in production line'
)
'that does not exist in production line'
)
# for every station read the interval capacity (Monday to Sunday)
# for every station read the interval capacity (Monday to Sunday)
intervalCapacity
=
[]
intervalCapacity
=
[]
for
row
in
range
(
7
):
for
row
in
range
(
7
):
intervalCapacity
.
append
(
float
(
capacityData
[
row
+
1
][
col
+
1
]))
intervalCapacity
.
append
(
float
(
capacityData
[
row
+
1
][
col
]))
node
[
stationId
][
'intervalCapacity'
]
=
intervalCapacity
node
s
[
stationId
][
'intervalCapacity'
]
=
intervalCapacity
# for every station read the interval capacity exceptions
# for every station read the interval capacity exceptions
for
row
in
range
(
8
,
len
(
capacityData
)):
for
row
in
range
(
8
,
len
(
capacityData
)):
# at the first empty line break
# at the first empty line break
...
@@ -38,12 +69,13 @@ class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
...
@@ -38,12 +69,13 @@ class AvailableCapacitySpreadsheet(plugin.InputPreparationPlugin):
exeptionDate
=
strptime
(
capacityData
[
row
][
0
],
'%Y/%m/%d'
)
exeptionDate
=
strptime
(
capacityData
[
row
][
0
],
'%Y/%m/%d'
)
dayDifference
=
(
exeptionDate
-
now
).
days
dayDifference
=
(
exeptionDate
-
now
).
days
assert
dayDifference
>=
0
,
'exception date for past day given'
assert
dayDifference
>=
0
,
'exception date for past day given'
intervalCapacityExceptions
=
node
[
stationId
].
get
(
'intervalCapacityExceptions'
,{})
intervalCapacityExceptions
=
node
s
[
stationId
].
get
(
'intervalCapacityExceptions'
,{})
if
not
intervalCapacityExceptions
:
if
not
intervalCapacityExceptions
:
node
[
stationId
][
'intervalCapacityExceptions'
]
=
{}
node
s
[
stationId
][
'intervalCapacityExceptions'
]
=
{}
node
[
stationId
][
'intervalCapacityExceptions'
][
str
(
float
(
dayDifference
))]
=
float
(
capacityData
[
row
][
col
+
1
])
node
s
[
stationId
][
'intervalCapacityExceptions'
][
str
(
float
(
dayDifference
))]
=
float
(
capacityData
[
row
][
col
])
# set the interval capacity start
# set the interval capacity start
node
[
stationId
][
'intervalCapacityStart'
]
=
now
.
weekday
()
node
s
[
stationId
][
'intervalCapacityStart'
]
=
now
.
weekday
()
return
data
return
data
\ No newline at end of file
dream/simulation/Examples/GUI_instances/CapacityProjectAllInOneEmpty.json
View file @
3d7e4ee8
...
@@ -410,6 +410,12 @@
...
@@ -410,6 +410,12 @@
"description"
:
"Is this station an assembly? Yes: 1, No: 0"
,
"description"
:
"Is this station an assembly? Yes: 1, No: 0"
,
"type"
:
"number"
,
"type"
:
"number"
,
"required"
:
true
"required"
:
true
},
"pool"
:
{
"_default"
:
""
,
"description"
:
"The pool of workers that is used for this station. If this station does not share resources leave empty"
,
"type"
:
"string"
,
"required"
:
false
}
}
}
}
}
}
...
...
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