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
f1b8b2bd
Commit
f1b8b2bd
authored
Sep 17, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in frozen simulation
parent
6227d142
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
181 additions
and
128 deletions
+181
-128
dream/plugins/FrozenSimulation/PostProcessingOfferPhase.py
dream/plugins/FrozenSimulation/PostProcessingOfferPhase.py
+1
-1
dream/plugins/FrozenSimulation/projTabular.py
dream/plugins/FrozenSimulation/projTabular.py
+3
-3
dream/plugins/FrozenSimulation/schedTabular.py
dream/plugins/FrozenSimulation/schedTabular.py
+20
-2
dream/simulation/applications/FrozenSimulation/Globals.py
dream/simulation/applications/FrozenSimulation/Globals.py
+17
-6
dream/simulation/applications/FrozenSimulation/exeSim.py
dream/simulation/applications/FrozenSimulation/exeSim.py
+90
-73
dream/simulation/applications/FrozenSimulation/findSequence.py
.../simulation/applications/FrozenSimulation/findSequence.py
+5
-13
dream/simulation/applications/FrozenSimulation/jsonReader.py
dream/simulation/applications/FrozenSimulation/jsonReader.py
+34
-20
dream/simulation/applications/FrozenSimulation/timeCalculations.py
...ulation/applications/FrozenSimulation/timeCalculations.py
+11
-10
No files found.
dream/plugins/FrozenSimulation/PostProcessingOfferPhase.py
View file @
f1b8b2bd
...
@@ -18,6 +18,6 @@ class PostProcessingOfferPhase(plugin.OutputPreparationPlugin):
...
@@ -18,6 +18,6 @@ class PostProcessingOfferPhase(plugin.OutputPreparationPlugin):
data
[
'result'
][
'result_list'
][
-
1
][
self
.
configuration_dict
[
'output_id'
]]
=
{
data
[
'result'
][
'result_list'
][
-
1
][
self
.
configuration_dict
[
'output_id'
]]
=
{
'name'
:
'Result.xlsx'
,
'name'
:
'Result.xlsx'
,
'mime_type'
:
'application/vnd.ms-excel'
,
'mime_type'
:
'application/vnd.ms-excel'
,
'data'
:
G
.
tabSchedule
.
xlsx
.
encode
(
'base64'
)
'data'
:
G
.
reportResults
.
xlsx
.
encode
(
'base64'
)
}
}
return
data
return
data
\ No newline at end of file
dream/plugins/FrozenSimulation/projTabular.py
View file @
f1b8b2bd
...
@@ -10,10 +10,10 @@ class projTabular(plugin.OutputPreparationPlugin):
...
@@ -10,10 +10,10 @@ class projTabular(plugin.OutputPreparationPlugin):
"""
"""
def
postprocess
(
self
,
data
):
def
postprocess
(
self
,
data
):
data
[
'result'
][
'result_list'
][
0
][
'exit_output'
]
=
[[
'Project'
,
'Earliest Completion Date'
]]
data
[
'result'
][
'result_list'
][
0
][
'exit_output'
]
=
[[
'Project'
,
'Earliest Completion Date'
,
'Conservative estimate Completion Date'
]]
from
dream.simulation.applications.FrozenSimulation.Globals
import
G
from
dream.simulation.applications.FrozenSimulation.Globals
import
G
for
proj
in
G
.
completionDate
.
keys
():
for
proj
in
G
.
completionDate
[
'Earliest'
]
.
keys
():
data
[
'result'
][
'result_list'
][
0
][
'exit_output'
].
append
([
proj
,
G
.
completionDate
[
proj
]])
data
[
'result'
][
'result_list'
][
0
][
'exit_output'
].
append
([
proj
,
G
.
completionDate
[
'Earliest'
][
proj
],
G
.
completionDate
[
'Latest'
]
[
proj
]])
return
data
return
data
...
...
dream/plugins/FrozenSimulation/schedTabular.py
View file @
f1b8b2bd
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
from
dream.plugins
import
plugin
from
dream.plugins
import
plugin
from
operator
import
itemgetter
from
operator
import
itemgetter
class
schedTabular
(
plugin
.
OutputPreparationPlugin
):
class
schedTabular
Earliest
(
plugin
.
OutputPreparationPlugin
):
""" Output the schedule in a tab
""" Output the schedule in a tab
"""
"""
...
@@ -11,11 +11,29 @@ class schedTabular(plugin.OutputPreparationPlugin):
...
@@ -11,11 +11,29 @@ class schedTabular(plugin.OutputPreparationPlugin):
from
dream.simulation.applications.FrozenSimulation.Globals
import
G
from
dream.simulation.applications.FrozenSimulation.Globals
import
G
# sort schedule items in start time ascending order
# sort schedule items in start time ascending order
sList
=
[]
sList
=
[]
for
entry
in
G
.
tabSchedule
:
for
entry
in
G
.
tabSchedule
[
'Earliest'
]
:
if
'End Time'
not
in
entry
:
if
'End Time'
not
in
entry
:
sList
.
append
([
x
for
x
in
entry
])
sList
.
append
([
x
for
x
in
entry
])
sList
=
sorted
(
sList
,
key
=
itemgetter
(
5
))
sList
=
sorted
(
sList
,
key
=
itemgetter
(
5
))
for
item
in
sList
:
for
item
in
sList
:
data
[
'result'
][
'result_list'
][
0
][
'schedule_output'
].
append
(
item
)
data
[
'result'
][
'result_list'
][
0
][
'schedule_output'
].
append
(
item
)
return
data
class
schedTabularLatest
(
plugin
.
OutputPreparationPlugin
):
""" Output the schedule in a tab
"""
def
postprocess
(
self
,
data
):
data
[
'result'
][
'result_list'
][
0
][
'schedule_output_latest'
]
=
[[
'Project'
,
'Part'
,
'Task ID'
,
'Station'
,
'Operator'
,
'Start Time'
,
'End Time'
]]
from
dream.simulation.applications.FrozenSimulation.Globals
import
G
# sort schedule items in start time ascending order
sList
=
[]
for
entry
in
G
.
tabSchedule
[
'Latest'
]:
if
'End Time'
not
in
entry
:
sList
.
append
([
x
for
x
in
entry
])
sList
=
sorted
(
sList
,
key
=
itemgetter
(
5
))
for
item
in
sList
:
data
[
'result'
][
'result_list'
][
0
][
'schedule_output_latest'
].
append
(
item
)
return
data
return
data
\ No newline at end of file
dream/simulation/applications/FrozenSimulation/Globals.py
View file @
f1b8b2bd
...
@@ -9,14 +9,25 @@ import tablib
...
@@ -9,14 +9,25 @@ import tablib
class
G
:
class
G
:
Schedule
=
{}
Schedule
=
{}
seqPrjDone
=
None
resAvailability
=
None
MachPool
=
None
MachPool
=
None
PMPool
=
None
PMPool
=
None
Projects
=
None
Projects
=
None
xlreftime
=
None
xlreftime
=
None
reportResults
=
tablib
.
Databook
()
tabSchedule
=
tablib
.
Dataset
(
title
=
'Schedule'
)
tabSchedule
.
headers
=
([
'Project'
,
'Part'
,
'Task ID'
,
'Station'
,
'Operator'
,
'Start Time'
,
'End Time'
])
OrderDates
=
None
OrderDates
=
None
completionDate
=
None
jsonInput
=
None
excelInput
=
None
simMode
=
None
# reporting tabs
reportResults
=
tablib
.
Databook
()
tabSchedule
=
{}
pmSchedule
=
{}
tabScheduleOrig
=
[]
pmScheduleOrig
=
[]
# re-initialised variables
completionDate
=
{}
seqPrjDone
=
None
resAvailability
=
None
seqPrjDoneOrig
=
None
resAvailabilityOrig
=
None
dream/simulation/applications/FrozenSimulation/exeSim.py
View file @
f1b8b2bd
...
@@ -4,7 +4,7 @@ Created on 20 Aug 2015
...
@@ -4,7 +4,7 @@ Created on 20 Aug 2015
@author: Anna
@author: Anna
'''
'''
from
jsonReader
import
importInput
from
jsonReader
import
importInput
,
initGlobals
from
findSequence
import
findSequence
from
findSequence
import
findSequence
from
timeCalculations
import
availableTimeInterval_MA
,
updateAvailTime
,
availableTimeInterval_MM
,
availableTimeInterval_Manual
from
timeCalculations
import
availableTimeInterval_MA
,
updateAvailTime
,
availableTimeInterval_MM
,
availableTimeInterval_Manual
from
operator
import
itemgetter
from
operator
import
itemgetter
...
@@ -18,8 +18,6 @@ def manual_allocation(currentOp):
...
@@ -18,8 +18,6 @@ def manual_allocation(currentOp):
tStart
=
currentOp
[
'minStartTime'
]
# earliest start date for current operation
tStart
=
currentOp
[
'minStartTime'
]
# earliest start date for current operation
remPT
=
dt
.
timedelta
(
hours
=
currentOp
[
'manualTime'
])
remPT
=
dt
.
timedelta
(
hours
=
currentOp
[
'manualTime'
])
print
'in manual allocation'
,
currentOp
[
'id'
]
print
'tStart manual'
,
tStart
,
remPT
while
remPT
>
dt
.
timedelta
(
seconds
=
0
):
while
remPT
>
dt
.
timedelta
(
seconds
=
0
):
startTimeMach
=
[]
# collects earliest keyDate for machines
startTimeMach
=
[]
# collects earliest keyDate for machines
...
@@ -42,30 +40,25 @@ def manual_allocation(currentOp):
...
@@ -42,30 +40,25 @@ def manual_allocation(currentOp):
# sort available time
# sort available time
sorted_startTimeOp
=
sorted
(
startTimeOp
,
key
=
itemgetter
(
'start'
,
'avPT'
))
sorted_startTimeOp
=
sorted
(
startTimeOp
,
key
=
itemgetter
(
'start'
,
'avPT'
))
print
tStart
print
'sort mach'
,
sorted_startTimeMach
print
'sort pm'
,
sorted_startTimeOp
# calculate available PT
# calculate available PT
if
sorted_startTimeOp
[
0
][
'start'
]
<=
tStart
:
if
sorted_startTimeOp
[
0
][
'start'
]
<=
tStart
:
print
'first op'
#
print 'first op'
availablePT
=
min
(
sorted_startTimeMach
[
0
][
'avPT'
]
*
(
-
1
),
sorted_startTimeOp
[
0
][
'avPT'
]
*
(
-
1
),
remPT
)
availablePT
=
min
(
sorted_startTimeMach
[
0
][
'avPT'
]
*
(
-
1
),
sorted_startTimeOp
[
0
][
'avPT'
]
*
(
-
1
),
remPT
)
elif
sorted_startTimeOp
[
0
][
'start'
]
<
tStart
+
sorted_startTimeMach
[
0
][
'avPT'
]:
elif
sorted_startTimeOp
[
0
][
'start'
]
<
tStart
+
sorted_startTimeMach
[
0
][
'avPT'
]:
print
'sec op'
#
print 'sec op'
tEnd
=
min
(
tStart
+
sorted_startTimeMach
[
0
][
'avPT'
],
sorted_startTimeOp
[
0
][
'start'
]
+
sorted_startTimeOp
[
0
][
'avPT'
])
tEnd
=
min
(
tStart
+
sorted_startTimeMach
[
0
][
'avPT'
],
sorted_startTimeOp
[
0
][
'start'
]
+
sorted_startTimeOp
[
0
][
'avPT'
])
tStart
=
sorted_startTimeOp
[
0
][
'start'
]
tStart
=
sorted_startTimeOp
[
0
][
'start'
]
availablePT
=
min
(
tEnd
-
tStart
,
remPT
)
availablePT
=
min
(
tEnd
-
tStart
,
remPT
)
else
:
else
:
print
'3 op'
#
print '3 op'
availablePT
=
dt
.
timedelta
(
seconds
=
0
)
availablePT
=
dt
.
timedelta
(
seconds
=
0
)
tStart
=
sorted_startTimeOp
[
0
][
'start'
]
tStart
=
sorted_startTimeOp
[
0
][
'start'
]
# update remaining PT
# update remaining PT
remPT
-=
availablePT
remPT
-=
availablePT
print
'fine all'
,
tStart
,
availablePT
,
remPT
if
availablePT
>
dt
.
timedelta
(
seconds
=
0
):
if
availablePT
>
dt
.
timedelta
(
seconds
=
0
):
# update machine and operator availability
# update machine and operator availability
...
@@ -74,28 +67,28 @@ def manual_allocation(currentOp):
...
@@ -74,28 +67,28 @@ def manual_allocation(currentOp):
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]]
=
updateAvailTime
(
sorted_startTimeOp
[
0
][
'start'
],
availablePT
,
tStart
,
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]]
=
updateAvailTime
(
sorted_startTimeOp
[
0
][
'start'
],
availablePT
,
tStart
,
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]])
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]])
#
aggiorna
schedule
#
update
schedule
if
currentOp
[
'id'
]
not
in
G
.
Schedule
.
keys
():
if
currentOp
[
'id'
]
not
in
G
.
Schedule
[
G
.
simMode
]
.
keys
():
G
.
Schedule
[
currentOp
[
'id'
]]
=
{}
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]]
=
{}
G
.
Schedule
[
currentOp
[
'id'
]][
'startDate'
]
=
tStart
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]][
'startDate'
]
=
tStart
tEnd
=
tStart
+
availablePT
tEnd
=
tStart
+
availablePT
G
.
Schedule
[
currentOp
[
'id'
]][
'endDate'
]
=
tEnd
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]][
'endDate'
]
=
tEnd
G
.
Schedule
[
currentOp
[
'id'
]].
setdefault
(
'rList'
,{})[(
tStart
,
tEnd
)]
=
{
'mach'
:
sorted_startTimeMach
[
0
][
'mach'
],
'operator'
:
sorted_startTimeOp
[
0
][
'pm'
]}
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]].
setdefault
(
'rList'
,{})[(
tStart
,
tEnd
)]
=
{
'mach'
:
sorted_startTimeMach
[
0
][
'mach'
],
'operator'
:
sorted_startTimeOp
[
0
][
'pm'
]}
G
.
tabSchedule
.
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'id'
],
sorted_startTimeMach
[
0
][
'mach'
],
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
])
G
.
tabSchedule
[
G
.
simMode
].
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'id'
],
sorted_startTimeMach
[
0
][
'mach'
],
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
])
G
.
pmSchedule
[
G
.
simMode
].
append
([
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
,
currentOp
[
'id'
]])
if
currentOp
[
'preID'
]
!=
None
:
if
currentOp
[
'preID'
]
!=
None
:
G
.
Schedule
[
currentOp
[
'preID'
]]
=
G
.
Schedule
[
currentOp
[
'id'
]]
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'preID'
]]
=
G
.
Schedule
[
G
.
simMode
]
[
currentOp
[
'id'
]]
if
G
.
completionDate
[
currentOp
[
'project'
]]
<
tEnd
:
if
G
.
completionDate
[
G
.
simMode
][
currentOp
[
'project'
]]
<
tEnd
:
G
.
completionDate
[
currentOp
[
'project'
]]
=
tEnd
G
.
completionDate
[
G
.
simMode
][
currentOp
[
'project'
]]
=
tEnd
tStart
=
tEnd
tStart
=
tEnd
print
currentOp
[
'id'
],
G
.
Schedule
[
currentOp
[
'id'
]]
def
MAM_allocation
(
currentOp
):
def
MAM_allocation
(
currentOp
):
# set earliest start date for current operation
tStart
=
currentOp
[
'minStartTime'
]
# earliest start date for current operation
tStart
=
currentOp
[
'minStartTime'
]
# earliest start date for current operation
print
'tStart'
,
tStart
# set processing time
remPT
=
currentOp
[
'manualTime'
]
+
currentOp
[
'autoTime'
]
remPT
=
currentOp
[
'manualTime'
]
+
currentOp
[
'autoTime'
]
while
remPT
:
while
remPT
:
...
@@ -107,38 +100,31 @@ def MAM_allocation(currentOp):
...
@@ -107,38 +100,31 @@ def MAM_allocation(currentOp):
for
mach
in
G
.
MachPool
[
currentOp
[
'operation'
]]:
for
mach
in
G
.
MachPool
[
currentOp
[
'operation'
]]:
# find available time (availableTimeInterval_MA)
# find available time (availableTimeInterval_MA)
print
'man'
,
currentOp
[
'manualTime'
]
mTime
=
dt
.
timedelta
(
hours
=
currentOp
[
'manualTime'
])
mTime
=
dt
.
timedelta
(
hours
=
currentOp
[
'manualTime'
])
aTime
=
dt
.
timedelta
(
hours
=
currentOp
[
'autoTime'
])
aTime
=
dt
.
timedelta
(
hours
=
currentOp
[
'autoTime'
])
print
'mach av'
,
mach
,
G
.
resAvailability
[
mach
]
if
currentOp
[
'mode'
]
==
'MM'
or
currentOp
[
'mode'
]
==
'M'
:
if
currentOp
[
'mode'
]
==
'MM'
:
res
=
availableTimeInterval_MM
(
mTime
,
aTime
,
tStart
,
G
.
resAvailability
[
mach
])
res
=
availableTimeInterval_MM
(
mTime
,
aTime
,
tStart
,
G
.
resAvailability
[
mach
])
startTimeMach
.
append
({
'mach'
:
mach
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]})
startTimeMach
.
append
({
'mach'
:
mach
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]})
else
:
else
:
res
=
availableTimeInterval_MA
(
mTime
,
aTime
,
tStart
,
G
.
resAvailability
[
mach
])
res
=
availableTimeInterval_MA
(
mTime
,
aTime
,
tStart
,
G
.
resAvailability
[
mach
])
#startTimeMach.append({'mach':mach, 'start':res, 'eqPT':mTime+aTime})
#startTimeMach.append({'mach':mach, 'start':res, 'eqPT':mTime+aTime})
startTimeMach
.
append
({
'mach'
:
mach
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]
+
aTime
})
startTimeMach
.
append
({
'mach'
:
mach
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]
+
aTime
})
print
'start time mach'
,
startTimeMach
# sort available time
# sort available time
sorted_startTimeMach
=
sorted
(
startTimeMach
,
key
=
itemgetter
(
'start'
,
'eqPT'
))
sorted_startTimeMach
=
sorted
(
startTimeMach
,
key
=
itemgetter
(
'start'
,
'eqPT'
))
tStart
=
max
(
sorted_startTimeMach
[
0
][
'start'
],
tStart
)
tStart
=
max
(
sorted_startTimeMach
[
0
][
'start'
],
tStart
)
print
'mach tent'
,
sorted_startTimeMach
[
0
][
'mach'
],
tStart
# verify whether PM are available during the same time interval
# verify whether PM are available in the same time
for
pm
in
G
.
PMPool
[
currentOp
[
'operation'
]]:
for
pm
in
G
.
PMPool
[
currentOp
[
'operation'
]]:
print
'operator'
,
pm
#find available time
#find available time
if
currentOp
[
'mode'
]
==
'MM'
:
if
currentOp
[
'mode'
]
==
'MM'
or
currentOp
[
'mode'
]
==
'M'
:
res
=
availableTimeInterval_MM
(
mTime
,
aTime
,
tStart
,
G
.
resAvailability
[
pm
])
res
=
availableTimeInterval_MM
(
mTime
,
aTime
,
tStart
,
G
.
resAvailability
[
pm
])
startTimeOp
.
append
({
'pm'
:
pm
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]})
startTimeOp
.
append
({
'pm'
:
pm
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]})
else
:
else
:
res
=
availableTimeInterval_MA
(
mTime
,
dt
.
timedelta
(
hours
=
0
),
tStart
,
G
.
resAvailability
[
pm
])
res
=
availableTimeInterval_MA
(
mTime
,
dt
.
timedelta
(
hours
=
0
),
tStart
,
G
.
resAvailability
[
pm
])
# startTimeOp.append({'pm':pm, 'start':res[0], 'eqPT':mTime})
# startTimeOp.append({'pm':pm, 'start':res[0], 'eqPT':mTime})
startTimeOp
.
append
({
'pm'
:
pm
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]})
startTimeOp
.
append
({
'pm'
:
pm
,
'start'
:
res
[
0
],
'eqPT'
:
res
[
1
]})
# sort available time
# sort available time
sorted_startTimeOp
=
sorted
(
startTimeOp
,
key
=
itemgetter
(
'start'
,
'eqPT'
))
sorted_startTimeOp
=
sorted
(
startTimeOp
,
key
=
itemgetter
(
'start'
,
'eqPT'
))
...
@@ -148,11 +134,6 @@ def MAM_allocation(currentOp):
...
@@ -148,11 +134,6 @@ def MAM_allocation(currentOp):
tStart
=
sorted_startTimeOp
[
0
][
'start'
]
tStart
=
sorted_startTimeOp
[
0
][
'start'
]
print
'machine chosen'
,
sorted_startTimeMach
[
0
][
'mach'
]
print
'operator chosen'
,
sorted_startTimeOp
[
0
][
'pm'
],
sorted_startTimeOp
print
G
.
resAvailability
[
sorted_startTimeMach
[
0
][
'mach'
]]
print
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]]
# update machine availability
# update machine availability
G
.
resAvailability
[
sorted_startTimeMach
[
0
][
'mach'
]]
=
updateAvailTime
(
sorted_startTimeMach
[
0
][
'start'
],
sorted_startTimeMach
[
0
][
'eqPT'
],
tStart
,
G
.
resAvailability
[
sorted_startTimeMach
[
0
][
'mach'
]]
=
updateAvailTime
(
sorted_startTimeMach
[
0
][
'start'
],
sorted_startTimeMach
[
0
][
'eqPT'
],
tStart
,
G
.
resAvailability
[
sorted_startTimeMach
[
0
][
'mach'
]])
G
.
resAvailability
[
sorted_startTimeMach
[
0
][
'mach'
]])
...
@@ -161,22 +142,23 @@ def MAM_allocation(currentOp):
...
@@ -161,22 +142,23 @@ def MAM_allocation(currentOp):
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]]
=
updateAvailTime
(
sorted_startTimeOp
[
0
][
'start'
],
sorted_startTimeOp
[
0
][
'eqPT'
],
tStart
,
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]]
=
updateAvailTime
(
sorted_startTimeOp
[
0
][
'start'
],
sorted_startTimeOp
[
0
][
'eqPT'
],
tStart
,
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]])
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]])
#
aggiorna
schedule
#
update
schedule
G
.
Schedule
.
setdefault
(
currentOp
[
'id'
],{})
G
.
Schedule
[
G
.
simMode
]
.
setdefault
(
currentOp
[
'id'
],{})
G
.
Schedule
[
currentOp
[
'id'
]][
'startDate'
]
=
tStart
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]][
'startDate'
]
=
tStart
tEnd
=
tStart
+
sorted_startTimeMach
[
0
][
'eqPT'
]
tEnd
=
tStart
+
sorted_startTimeMach
[
0
][
'eqPT'
]
G
.
Schedule
[
currentOp
[
'id'
]][
'endDate'
]
=
tEnd
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]][
'endDate'
]
=
tEnd
G
.
Schedule
[
currentOp
[
'id'
]].
setdefault
(
'rList'
,{})[(
tStart
,
tEnd
)]
=
{
'mach'
:
sorted_startTimeMach
[
0
][
'mach'
],
'operator'
:
sorted_startTimeOp
[
0
][
'pm'
]}
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]].
setdefault
(
'rList'
,{})[(
tStart
,
tEnd
)]
=
{
'mach'
:
sorted_startTimeMach
[
0
][
'mach'
],
'operator'
:
sorted_startTimeOp
[
0
][
'pm'
]}
if
currentOp
[
'preID'
]
!=
None
:
if
currentOp
[
'preID'
]
!=
None
:
G
.
Schedule
[
currentOp
[
'preID'
]]
=
G
.
Schedule
[
currentOp
[
'id'
]]
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'preID'
]]
=
G
.
Schedule
[
G
.
simMode
][
currentOp
[
'id'
]]
if
G
.
completionDate
[
currentOp
[
'project'
]]
<
tEnd
:
if
G
.
completionDate
[
G
.
simMode
][
currentOp
[
'project'
]]
<
tEnd
:
G
.
completionDate
[
currentOp
[
'project'
]]
=
tEnd
G
.
completionDate
[
G
.
simMode
][
currentOp
[
'project'
]]
=
tEnd
G
.
tabSchedule
.
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'preID'
],
sorted_startTimeMach
[
0
][
'mach'
],
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
-
aTime
])
if
currentOp
[
'mode'
]
==
'MM'
or
currentOp
[
'mode'
]
==
'MA'
:
G
.
tabSchedule
.
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'id'
],
sorted_startTimeMach
[
0
][
'mach'
],
'automatic'
,
tEnd
-
aTime
,
tEnd
])
G
.
tabSchedule
[
G
.
simMode
].
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'preID'
],
sorted_startTimeMach
[
0
][
'mach'
],
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
-
aTime
])
G
.
tabSchedule
[
G
.
simMode
].
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'id'
],
sorted_startTimeMach
[
0
][
'mach'
],
'automatic'
,
tEnd
-
aTime
,
tEnd
])
print
'schedule'
,
G
.
Schedule
G
.
pmSchedule
[
G
.
simMode
].
append
([
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
-
aTime
,
currentOp
[
'id'
]])
else
:
print
G
.
resAvailability
[
sorted_startTimeOp
[
0
][
'pm'
]]
G
.
tabSchedule
[
G
.
simMode
].
append
([
currentOp
[
'project'
],
currentOp
[
'part'
],
currentOp
[
'id'
],
sorted_startTimeMach
[
0
][
'mach'
],
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
])
G
.
pmSchedule
[
G
.
simMode
].
append
([
sorted_startTimeOp
[
0
][
'pm'
],
tStart
,
tEnd
,
currentOp
[
'id'
]])
def
exeSim
(
jsonInput
,
workplanInput
,
algorithmAttributes
):
def
exeSim
(
jsonInput
,
workplanInput
,
algorithmAttributes
):
...
@@ -190,53 +172,88 @@ def exeSim(jsonInput, workplanInput, algorithmAttributes):
...
@@ -190,53 +172,88 @@ def exeSim(jsonInput, workplanInput, algorithmAttributes):
excelInput
=
attachement_data
excelInput
=
attachement_data
# read input data
# read input data
G
.
simMode
=
'Earliest'
importInput
(
jInput
,
excelInput
,
algorithmAttributes
)
importInput
(
jInput
,
excelInput
,
algorithmAttributes
)
#==========================
# Earliest Completion Date
#==========================
initGlobals
()
# find initial operation
# find initial operation
opDone
=
[]
opDone
=
[]
seq
=
deepcopy
(
G
.
seqPrjDone
)
seq
=
deepcopy
(
G
.
seqPrjDone
)
proj
=
deepcopy
(
G
.
Projects
)
proj
=
deepcopy
(
G
.
Projects
)
opReady
=
findSequence
(
proj
,
seq
,
opDone
)
opReady
=
findSequence
(
proj
,
seq
,
opDone
)
print
'opready'
,
opReady
,
G
.
seqPrjDone
while
len
(
opReady
):
while
len
(
opReady
):
# set current operation
# set current operation
currentOp
=
opReady
[
0
]
currentOp
=
opReady
[
0
]
print
'chosen operation'
,
currentOp
[
'id'
]
# check op mode and allocate operation
# check op mode
if
currentOp
[
'mode'
]
==
'MA'
or
currentOp
[
'mode'
]
==
'MM'
:
if
currentOp
[
'mode'
]
==
'MA'
or
currentOp
[
'mode'
]
==
'MM'
:
MAM_allocation
(
currentOp
)
MAM_allocation
(
currentOp
)
else
:
else
:
manual_allocation
(
currentOp
)
manual_allocation
(
currentOp
)
# elif currentOp['mode'] == 'MM':
# print 'MM'
# MM_allocation(currentOp)
# save results
# save results
and update sequence number
opDone
.
append
(
currentOp
[
'id'
])
opDone
.
append
(
currentOp
[
'id'
])
G
.
seqPrjDone
[
currentOp
[
'project'
]][
currentOp
[
'part'
]]
+=
1
G
.
seqPrjDone
[
currentOp
[
'project'
]][
currentOp
[
'part'
]]
+=
1
print
'op'
,
currentOp
if
currentOp
[
'preID'
]
!=
None
:
if
currentOp
[
'preID'
]
!=
None
:
opDone
.
append
(
currentOp
[
'preID'
])
opDone
.
append
(
currentOp
[
'preID'
])
G
.
seqPrjDone
[
currentOp
[
'project'
]][
currentOp
[
'part'
]]
+=
1
G
.
seqPrjDone
[
currentOp
[
'project'
]][
currentOp
[
'part'
]]
+=
1
# aggiorna seqPrjDone
# find next operation
seq
=
deepcopy
(
G
.
seqPrjDone
)
proj
=
deepcopy
(
G
.
Projects
)
opReady
=
findSequence
(
proj
,
seq
,
opDone
)
# add result sheets
G
.
reportResults
.
add_sheet
(
G
.
tabSchedule
[
G
.
simMode
])
G
.
reportResults
.
add_sheet
(
G
.
pmSchedule
[
G
.
simMode
])
#==========================
# Latest Completion Date
#==========================
G
.
simMode
=
'Latest'
initGlobals
()
# find initial operation
opDone
=
[]
seq
=
deepcopy
(
G
.
seqPrjDone
)
proj
=
deepcopy
(
G
.
Projects
)
opReady
=
findSequence
(
proj
,
seq
,
opDone
)
while
len
(
opReady
):
# set current operation
currentOp
=
opReady
[
0
]
# allocate operation
MAM_allocation
(
currentOp
)
# save results
opDone
.
append
(
currentOp
[
'id'
])
G
.
seqPrjDone
[
currentOp
[
'project'
]][
currentOp
[
'part'
]]
+=
1
if
currentOp
[
'preID'
]
!=
None
:
opDone
.
append
(
currentOp
[
'preID'
])
G
.
seqPrjDone
[
currentOp
[
'project'
]][
currentOp
[
'part'
]]
+=
1
# find following operation
seq
=
deepcopy
(
G
.
seqPrjDone
)
seq
=
deepcopy
(
G
.
seqPrjDone
)
proj
=
deepcopy
(
G
.
Projects
)
proj
=
deepcopy
(
G
.
Projects
)
opReady
=
findSequence
(
proj
,
seq
,
opDone
)
opReady
=
findSequence
(
proj
,
seq
,
opDone
)
print
opDone
# report results
print
'completion date'
,
G
.
completionDate
G
.
reportResults
.
add_sheet
(
G
.
tabSchedule
[
G
.
simMode
])
G
.
reportResults
.
add_sheet
(
G
.
pmSchedule
[
G
.
simMode
])
G
.
reportResults
.
add_sheet
(
G
.
tabSchedule
)
# with open('schedule.xlsx', 'wb') as f: #time level schedule info
with
open
(
'schedule.xlsx'
,
'wb'
)
as
f
:
#time level schedule info
# f.write(G.reportResults.xlsx)
f
.
write
(
G
.
reportResults
.
xlsx
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
dream/simulation/applications/FrozenSimulation/findSequence.py
View file @
f1b8b2bd
...
@@ -11,9 +11,6 @@ def findSequence(Projects, seqPrjDone, idDone):
...
@@ -11,9 +11,6 @@ def findSequence(Projects, seqPrjDone, idDone):
opReady
=
[]
opReady
=
[]
print
'find sequence'
,
Projects
print
'find sequence'
,
seqPrjDone
for
proj
in
seqPrjDone
.
keys
():
for
proj
in
seqPrjDone
.
keys
():
for
part
in
seqPrjDone
[
proj
].
keys
():
for
part
in
seqPrjDone
[
proj
].
keys
():
...
@@ -22,12 +19,11 @@ def findSequence(Projects, seqPrjDone, idDone):
...
@@ -22,12 +19,11 @@ def findSequence(Projects, seqPrjDone, idDone):
possibleOp
=
True
possibleOp
=
True
print
'part'
,
part
,
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]][
'id'
]
# set minimum start time for operation
if
seqPrjDone
[
proj
][
part
]
==
0
or
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]
-
1
][
'id'
]
not
in
G
.
Schedule
[
G
.
simMode
].
keys
():
if
seqPrjDone
[
proj
][
part
]
==
0
or
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]
-
1
][
'id'
]
not
in
G
.
Schedule
.
keys
():
minStartTime
=
max
(
G
.
xlreftime
,
G
.
OrderDates
[
proj
])
minStartTime
=
max
(
G
.
xlreftime
,
G
.
OrderDates
[
proj
])
else
:
else
:
minStartTime
=
G
.
Schedule
[
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]
-
1
][
'id'
]][
'endDate'
]
minStartTime
=
G
.
Schedule
[
G
.
simMode
][
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]
-
1
][
'id'
]][
'endDate'
]
# verify whether the operation can be performed in terms of prerequisite operations
# verify whether the operation can be performed in terms of prerequisite operations
for
preReq
in
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]][
'preReq'
]:
for
preReq
in
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]][
'preReq'
]:
...
@@ -37,12 +33,11 @@ def findSequence(Projects, seqPrjDone, idDone):
...
@@ -37,12 +33,11 @@ def findSequence(Projects, seqPrjDone, idDone):
break
break
else
:
else
:
if
minStartTime
<
G
.
Schedule
[
preReq
][
'endDate'
]:
if
minStartTime
<
G
.
Schedule
[
G
.
simMode
][
preReq
][
'endDate'
]:
minStartTime
=
G
.
Schedule
[
preReq
][
'endDate'
]
minStartTime
=
G
.
Schedule
[
G
.
simMode
][
preReq
][
'endDate'
]
if
possibleOp
:
if
possibleOp
:
newOp
=
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]]
newOp
=
Projects
[
proj
][
part
][
seqPrjDone
[
proj
][
part
]]
print
newOp
[
'id'
],
'possible'
newOp
[
'minStartTime'
]
=
minStartTime
newOp
[
'minStartTime'
]
=
minStartTime
newOp
[
'project'
]
=
proj
newOp
[
'project'
]
=
proj
newOp
[
'part'
]
=
part
newOp
[
'part'
]
=
part
...
@@ -59,7 +54,6 @@ def findSequence(Projects, seqPrjDone, idDone):
...
@@ -59,7 +54,6 @@ def findSequence(Projects, seqPrjDone, idDone):
seqPrjDone
[
proj
][
part
]
+=
1
seqPrjDone
[
proj
][
part
]
+=
1
# verify that the operation is the same
# verify that the operation is the same
print
followOp
[
'operation'
],
newOp
[
'operation'
]
assert
(
followOp
[
'operation'
].
split
(
'-'
)[
0
]
in
newOp
[
'operation'
])
assert
(
followOp
[
'operation'
].
split
(
'-'
)[
0
]
in
newOp
[
'operation'
])
# update operation (erase set)
# update operation (erase set)
...
@@ -91,10 +85,8 @@ def findSequence(Projects, seqPrjDone, idDone):
...
@@ -91,10 +85,8 @@ def findSequence(Projects, seqPrjDone, idDone):
opReady
.
append
(
newOp
)
opReady
.
append
(
newOp
)
print
'pre'
,
opReady
opReady
=
sorted
(
opReady
,
key
=
itemgetter
(
'sequence'
,
'manualTime'
,
'autoTime'
))
opReady
=
sorted
(
opReady
,
key
=
itemgetter
(
'sequence'
,
'manualTime'
,
'autoTime'
))
print
'seq'
,
seqPrjDone
,
G
.
seqPrjDone
return
opReady
return
opReady
dream/simulation/applications/FrozenSimulation/jsonReader.py
View file @
f1b8b2bd
...
@@ -114,22 +114,18 @@ def importInput(jInput, excelInput, algorithmAttributes):
...
@@ -114,22 +114,18 @@ def importInput(jInput, excelInput, algorithmAttributes):
part
=
item
[
0
].
encode
(
'ascii'
,
'ignore'
)
part
=
item
[
0
].
encode
(
'ascii'
,
'ignore'
)
#print 'startDate', startDate.date()
if
pt
.
seconds
>
0
or
pt
.
days
>
0
:
if
pt
.
seconds
>
0
or
pt
.
days
>
0
:
forzenOpsData
.
append
([
startDate
.
date
(),
part
,
order
,
item
[
3
],
item
[
7
],
station
,
startDate
.
time
(),
dateOut
.
time
(),
ordinalOutDate
,
'X'
])
forzenOpsData
.
append
([
startDate
.
date
(),
part
,
order
,
item
[
3
],
item
[
7
],
station
,
startDate
.
time
(),
dateOut
.
time
(),
ordinalOutDate
,
'X'
])
frozen
[
item
[
3
]]
=
'X'
frozen
[
item
[
3
]]
=
'X'
G
.
tabSchedule
.
append
([
order
,
part
,
item
[
3
],
station
,
item
[
7
],
startDate
,
dateOut
])
G
.
tabSchedule
Orig
.
append
([
order
,
part
,
item
[
3
],
station
,
item
[
7
],
startDate
,
dateOut
])
if
station
not
in
takenPeriods
:
takenPeriods
.
setdefault
(
station
,{})[
startDate
]
=
{
'endDate'
:
dateOut
,
'taskID'
:
item
[
3
]}
takenPeriods
[
station
]
=
{}
takenPeriods
[
station
][
startDate
]
=
{
'endDate'
:
dateOut
,
'taskID'
:
item
[
3
]}
PMschedule
=
dataJSON
[
'result'
][
'result_list'
][
selSol
][
'operator_gantt'
][
'task_list'
]
# import PM schedule
PMschedule
=
dataJSON
[
'result'
][
'result_list'
][
selSol
][
'operator_gantt'
][
'task_list'
]
# extract resource availability
for
item
in
PMschedule
:
for
item
in
PMschedule
:
if
'parent'
in
item
.
keys
():
if
'parent'
in
item
.
keys
():
pm
=
item
[
'parent'
]
pm
=
item
[
'parent'
]
...
@@ -143,22 +139,17 @@ def importInput(jInput, excelInput, algorithmAttributes):
...
@@ -143,22 +139,17 @@ def importInput(jInput, excelInput, algorithmAttributes):
continue
continue
if
pt
:
if
pt
:
print
pm
,
taskID
if
pm
not
in
takenPeriods
:
if
pm
not
in
takenPeriods
:
takenPeriods
[
pm
]
=
{}
takenPeriods
[
pm
]
=
{}
takenPeriods
[
pm
][
startDate
]
=
{
'endDate'
:
stopDate
,
'taskID'
:
taskID
}
takenPeriods
[
pm
][
startDate
]
=
{
'endDate'
:
stopDate
,
'taskID'
:
taskID
}
G
.
pmScheduleOrig
.
append
([
pm
,
startDate
,
stopDate
,
taskID
])
print
'frozen operations'
,
forzenOpsData
print
'taken periods'
,
takenPeriods
#=================================
#=================================
# Import Workplan from Excel file
# Import Workplan from Excel file
#=================================
#=================================
global
numParts
WorkPlan
=
wb
.
sheet_by_index
(
0
)
WorkPlan
=
wb
.
sheet_by_index
(
0
)
Projects
=
{}
Projects
=
{}
...
@@ -304,6 +295,15 @@ def importInput(jInput, excelInput, algorithmAttributes):
...
@@ -304,6 +295,15 @@ def importInput(jInput, excelInput, algorithmAttributes):
if
'INJM-MAN'
in
skills
:
if
'INJM-MAN'
in
skills
:
skills
.
remove
(
'INJM-MAN'
)
skills
.
remove
(
'INJM-MAN'
)
skills
.
append
(
'INJM'
)
skills
.
append
(
'INJM'
)
if
'INJM-SET'
in
skills
:
skills
.
remove
(
'INJM-SET'
)
skills
.
append
(
'INJM'
)
if
'EDM-SET'
in
skills
:
skills
.
remove
(
'EDM-SET'
)
skills
.
append
(
'EDM'
)
if
'MILL-SET'
in
skills
:
skills
.
remove
(
'MILL-SET'
)
skills
.
append
(
'MILL'
)
PMInfo
.
append
({
'name'
:
PMskills
[
item
][
0
],
'skills'
:
skills
,
'sched'
:
'FIFO'
,
'status'
:
''
})
PMInfo
.
append
({
'name'
:
PMskills
[
item
][
0
],
'skills'
:
skills
,
'sched'
:
'FIFO'
,
'status'
:
''
})
for
sk
in
skills
:
for
sk
in
skills
:
...
@@ -348,11 +348,25 @@ def importInput(jInput, excelInput, algorithmAttributes):
...
@@ -348,11 +348,25 @@ def importInput(jInput, excelInput, algorithmAttributes):
resAvailability
[
mach
]
=
availableTime_Shift
(
unavailDate
,
takenPeriods
[
mach
][
unavailDate
][
'endDate'
],
resAvailability
[
mach
])
resAvailability
[
mach
]
=
availableTime_Shift
(
unavailDate
,
takenPeriods
[
mach
][
unavailDate
][
'endDate'
],
resAvailability
[
mach
])
# set global variables
# set global variables
G
.
resAvailability
=
deepcopy
(
resAvailability
)
G
.
seqPrjDoneOrig
=
deepcopy
(
seqPrjDone
)
G
.
seqPrjDone
=
deepcopy
(
seqPrjDone
)
G
.
resAvailabilityOrig
=
deepcopy
(
resAvailability
)
G
.
resAvailability
=
deepcopy
(
resAvailability
)
G
.
MachPool
=
deepcopy
(
MachPool
)
G
.
MachPool
=
deepcopy
(
MachPool
)
print
'mach pool'
,
G
.
MachPool
G
.
PMPool
=
deepcopy
(
PMPool
)
G
.
PMPool
=
deepcopy
(
PMPool
)
G
.
Projects
=
deepcopy
(
Projects
)
G
.
Projects
=
deepcopy
(
Projects
)
G
.
OrderDates
=
deepcopy
(
OrderDates
)
G
.
OrderDates
=
deepcopy
(
OrderDates
)
G
.
completionDate
=
deepcopy
(
OrderDates
)
def
initGlobals
():
G
.
resAvailability
=
deepcopy
(
G
.
resAvailabilityOrig
)
G
.
seqPrjDone
=
deepcopy
(
G
.
seqPrjDoneOrig
)
G
.
Schedule
[
G
.
simMode
]
=
{}
G
.
completionDate
[
G
.
simMode
]
=
deepcopy
(
G
.
OrderDates
)
G
.
tabSchedule
[
G
.
simMode
]
=
tablib
.
Dataset
(
title
=
'Schedule'
+
str
(
G
.
simMode
))
G
.
tabSchedule
[
G
.
simMode
].
headers
=
([
'Project'
,
'Part'
,
'Task ID'
,
'Station'
,
'Operator'
,
'Start Time'
,
'End Time'
])
for
item
in
G
.
tabScheduleOrig
:
G
.
tabSchedule
[
G
.
simMode
].
append
(
item
)
G
.
pmSchedule
[
G
.
simMode
]
=
tablib
.
Dataset
(
title
=
'PMschedule'
+
str
(
G
.
simMode
))
for
item
in
G
.
pmScheduleOrig
:
G
.
pmSchedule
[
G
.
simMode
].
append
(
item
)
dream/simulation/applications/FrozenSimulation/timeCalculations.py
View file @
f1b8b2bd
...
@@ -12,8 +12,10 @@ def availableTimeInterval_Manual(manualTime, tStart, availTime):
...
@@ -12,8 +12,10 @@ def availableTimeInterval_Manual(manualTime, tStart, availTime):
# suitable for manual operations...returns available time until the end
# suitable for manual operations...returns available time until the end
# sort time intervals according to ascending start date
sortedTime
=
sorted
(
availTime
.
keys
())
sortedTime
=
sorted
(
availTime
.
keys
())
# find the interval for which the start date is just above tStart
i
=
0
i
=
0
while
i
<
len
(
sortedTime
)
and
sortedTime
[
i
]
<=
tStart
:
while
i
<
len
(
sortedTime
)
and
sortedTime
[
i
]
<=
tStart
:
i
+=
1
i
+=
1
...
@@ -25,6 +27,7 @@ def availableTimeInterval_Manual(manualTime, tStart, availTime):
...
@@ -25,6 +27,7 @@ def availableTimeInterval_Manual(manualTime, tStart, availTime):
# if i == 0 and tStart + manualTime < sortedTime[i]:
# if i == 0 and tStart + manualTime < sortedTime[i]:
# return None
# return None
# go to next interval if available time is null
if
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tStart
,
sortedTime
[
i
])
<=
dt
.
timedelta
(
seconds
=
0
):
if
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tStart
,
sortedTime
[
i
])
<=
dt
.
timedelta
(
seconds
=
0
):
i
+=
1
i
+=
1
...
@@ -59,6 +62,10 @@ def availableTimeInterval_MM(manualTime, autoTime, tStart, availTime):
...
@@ -59,6 +62,10 @@ def availableTimeInterval_MM(manualTime, autoTime, tStart, availTime):
if
availTime
[
sortedTime
[
i
]][
'endMode'
]
==
'EOS'
:
if
availTime
[
sortedTime
[
i
]][
'endMode'
]
==
'EOS'
:
if
i
+
1
<
len
(
sortedTime
)
and
availTime
[
sortedTime
[
i
+
1
]][
'preDay'
]
==
sortedTime
[
i
].
date
()
and
availTime
[
sortedTime
[
i
+
1
]][
'startMode'
]
==
'SOS'
:
if
i
+
1
<
len
(
sortedTime
)
and
availTime
[
sortedTime
[
i
+
1
]][
'preDay'
]
==
sortedTime
[
i
].
date
()
and
availTime
[
sortedTime
[
i
+
1
]][
'startMode'
]
==
'SOS'
:
tCumulative
+=
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tStart
,
sortedTime
[
i
])
tCumulative
+=
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tStart
,
sortedTime
[
i
])
else
:
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
if
i
+
1
<
len
(
sortedTime
):
startSorted
=
sortedTime
[
i
+
1
]
else
:
else
:
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
...
@@ -79,8 +86,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
...
@@ -79,8 +86,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
sortedTime
=
sorted
(
availTime
.
keys
())
sortedTime
=
sorted
(
availTime
.
keys
())
print
sortedTime
i
=
0
i
=
0
while
i
<
len
(
sortedTime
)
and
sortedTime
[
i
]
<=
tStart
:
while
i
<
len
(
sortedTime
)
and
sortedTime
[
i
]
<=
tStart
:
i
+=
1
i
+=
1
...
@@ -92,8 +97,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
...
@@ -92,8 +97,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
# if i == 0 and tStart + autoTime + manualTime < sortedTime[i]:
# if i == 0 and tStart + autoTime + manualTime < sortedTime[i]:
# return None
# return None
print
'start'
,
sortedTime
[
i
]
while
True
:
while
True
:
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
...
@@ -104,6 +107,10 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
...
@@ -104,6 +107,10 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
if
availTime
[
sortedTime
[
i
]][
'endMode'
]
==
'EOS'
:
if
availTime
[
sortedTime
[
i
]][
'endMode'
]
==
'EOS'
:
if
i
+
1
<
len
(
sortedTime
)
and
availTime
[
sortedTime
[
i
+
1
]][
'preDay'
]
==
sortedTime
[
i
].
date
()
and
availTime
[
sortedTime
[
i
+
1
]][
'startMode'
]
==
'SOS'
:
if
i
+
1
<
len
(
sortedTime
)
and
availTime
[
sortedTime
[
i
+
1
]][
'preDay'
]
==
sortedTime
[
i
].
date
()
and
availTime
[
sortedTime
[
i
+
1
]][
'startMode'
]
==
'SOS'
:
tCumulative
+=
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tStart
,
sortedTime
[
i
])
tCumulative
+=
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tStart
,
sortedTime
[
i
])
else
:
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
if
i
+
1
<
len
(
sortedTime
):
startSorted
=
sortedTime
[
i
+
1
]
else
:
else
:
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
tCumulative
=
dt
.
timedelta
(
seconds
=
0
)
...
@@ -124,8 +131,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
...
@@ -124,8 +131,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
if
i
>=
len
(
sortedTime
):
if
i
>=
len
(
sortedTime
):
return
None
return
None
# print 'end manual', sortedTime[i]
if
autoTime
:
if
autoTime
:
if
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tManualEnd
,
sortedTime
[
i
])
<=
autoTime
:
if
availTime
[
sortedTime
[
i
]][
'end'
]
-
max
(
tManualEnd
,
sortedTime
[
i
])
<=
autoTime
:
if
availTime
[
sortedTime
[
i
]][
'endMode'
]
==
'EOS'
:
if
availTime
[
sortedTime
[
i
]][
'endMode'
]
==
'EOS'
:
...
@@ -181,7 +186,6 @@ def updateAvailTime(keyStart, reqTime, tStart, availTime):
...
@@ -181,7 +186,6 @@ def updateAvailTime(keyStart, reqTime, tStart, availTime):
print
'WARNING: beyond planning horizon'
print
'WARNING: beyond planning horizon'
return
availTime
return
availTime
# print 'find next time', sortedTime[i], i
if
tStart
+
reqTime
>
sortedTime
[
i
]:
if
tStart
+
reqTime
>
sortedTime
[
i
]:
# repeat procedure
# repeat procedure
availTime
=
updateAvailTime
(
sortedTime
[
i
],
reqTime
-
(
sortedTime
[
i
]
-
tStart
),
sortedTime
[
i
],
availTime
)
availTime
=
updateAvailTime
(
sortedTime
[
i
],
reqTime
-
(
sortedTime
[
i
]
-
tStart
),
sortedTime
[
i
],
availTime
)
...
@@ -198,8 +202,6 @@ def availableTime_Shift(tStart, tEnd, availTime):
...
@@ -198,8 +202,6 @@ def availableTime_Shift(tStart, tEnd, availTime):
i
+=
1
i
+=
1
# print i, sortedTime[i], availTime[sortedTime[i]]['end'], tStart, tEnd
if
i
>=
len
(
sortedTime
):
if
i
>=
len
(
sortedTime
):
print
'WARNING: time interval not found'
print
'WARNING: time interval not found'
return
availTime
return
availTime
...
@@ -219,7 +221,6 @@ def availableTime_Shift(tStart, tEnd, availTime):
...
@@ -219,7 +221,6 @@ def availableTime_Shift(tStart, tEnd, availTime):
availTime
=
updateAvailTime
(
sortedTime
[
i
],
tEnd
-
max
(
tStart
,
sortedTime
[
i
]),
max
(
tStart
,
sortedTime
[
i
]),
availTime
)
availTime
=
updateAvailTime
(
sortedTime
[
i
],
tEnd
-
max
(
tStart
,
sortedTime
[
i
]),
max
(
tStart
,
sortedTime
[
i
]),
availTime
)
elif
availTime
[
sortedTime
[
i
+
1
]][
'startMode'
]
==
'SOS'
and
availTime
[
sortedTime
[
i
+
1
]][
'preDay'
]
==
sortedTime
[
i
].
date
()
and
availTime
[
sortedTime
[
i
+
1
]][
'end'
]
>=
tEnd
:
elif
availTime
[
sortedTime
[
i
+
1
]][
'startMode'
]
==
'SOS'
and
availTime
[
sortedTime
[
i
+
1
]][
'preDay'
]
==
sortedTime
[
i
].
date
()
and
availTime
[
sortedTime
[
i
+
1
]][
'end'
]
>=
tEnd
:
print
'beyond eos'
,
max
(
tStart
,
sortedTime
[
i
]),
tEnd
-
max
(
tStart
,
sortedTime
[
i
])
availTime
=
updateAvailTime
(
sortedTime
[
i
],
tEnd
-
max
(
tStart
,
sortedTime
[
i
]),
max
(
tStart
,
sortedTime
[
i
]),
availTime
)
availTime
=
updateAvailTime
(
sortedTime
[
i
],
tEnd
-
max
(
tStart
,
sortedTime
[
i
]),
max
(
tStart
,
sortedTime
[
i
]),
availTime
)
else
:
else
:
return
availTime
return
availTime
...
...
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