Commit bb2092c7 authored by Georgios Dagkakis's avatar Georgios Dagkakis

updates in frozen simulation approach

parent 5d81ba21
...@@ -32,6 +32,6 @@ class AddOfferPhaseGenerator(plugin.InputPreparationPlugin): ...@@ -32,6 +32,6 @@ class AddOfferPhaseGenerator(plugin.InputPreparationPlugin):
"stop": 0.5, "stop": 0.5,
"_class": "dream.simulation.EventGenerator.EventGenerator", "_class": "dream.simulation.EventGenerator.EventGenerator",
"method": "dream.simulation.applications.FrozenSimulation.exeSim.exeSim", "method": "dream.simulation.applications.FrozenSimulation.exeSim.exeSim",
"argumentDict": {'jsonInput':data_uri_encoded_input_data, 'workplanInput':data_uri_encoded_workplan_data} "argumentDict": {'jsonInput':data_uri_encoded_input_data, 'workplanInput':data_uri_encoded_workplan_data, 'algorithmAttributes':algorithmAttributes}
} }
return data return data
\ No newline at end of file
...@@ -3,7 +3,6 @@ Created on 4 Sep 2015 ...@@ -3,7 +3,6 @@ Created on 4 Sep 2015
@author: Anna @author: Anna
''' '''
from dream.plugins import plugin from dream.plugins import plugin
class projTabular(plugin.OutputPreparationPlugin): class projTabular(plugin.OutputPreparationPlugin):
...@@ -16,4 +15,6 @@ class projTabular(plugin.OutputPreparationPlugin): ...@@ -16,4 +15,6 @@ class projTabular(plugin.OutputPreparationPlugin):
for proj in G.completionDate.keys(): for proj in G.completionDate.keys():
data['result']['result_list'][0]['exit_output'].append([proj, G.completionDate[proj]]) data['result']['result_list'][0]['exit_output'].append([proj, G.completionDate[proj]])
return data return data
\ No newline at end of file
from dream.plugins import plugin
from operator import itemgetter
class schedTabular(plugin.OutputPreparationPlugin):
""" Output the schedule in a tab
"""
def postprocess(self, data):
data['result']['result_list'][0]['schedule_output'] = [['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:
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'].append(item)
return data
\ No newline at end of file
...@@ -179,7 +179,7 @@ def MAM_allocation(currentOp): ...@@ -179,7 +179,7 @@ def MAM_allocation(currentOp):
print G.resAvailability[sorted_startTimeOp[0]['pm']] print G.resAvailability[sorted_startTimeOp[0]['pm']]
def exeSim(jsonInput, workplanInput): def exeSim(jsonInput, workplanInput, algorithmAttributes):
mime_type, attachement_data = jsonInput[len('data:'):].split(';base64,', 1) mime_type, attachement_data = jsonInput[len('data:'):].split(';base64,', 1)
attachement_data = attachement_data.decode('base64') attachement_data = attachement_data.decode('base64')
...@@ -190,7 +190,7 @@ def exeSim(jsonInput, workplanInput): ...@@ -190,7 +190,7 @@ def exeSim(jsonInput, workplanInput):
excelInput = attachement_data excelInput = attachement_data
# read input data # read input data
importInput(jInput, excelInput) importInput(jInput, excelInput, algorithmAttributes)
# find initial operation # find initial operation
opDone = [] opDone = []
......
...@@ -46,11 +46,10 @@ def findSequence(Projects, seqPrjDone, idDone): ...@@ -46,11 +46,10 @@ def findSequence(Projects, seqPrjDone, idDone):
newOp['minStartTime'] = minStartTime newOp['minStartTime'] = minStartTime
newOp['project'] = proj newOp['project'] = proj
newOp['part'] = part newOp['part'] = part
if newOp['personnel'].lower() != 'automatic': if newOp['operation'] not in ['INJM', 'MILL', 'EDM','INJM-MAN']: #newOp['personnel'].lower() != 'automatic':
newOp['manualTime'] = newOp['pt'] * newOp['qty'] newOp['manualTime'] = newOp['pt'] * newOp['qty']
seqPrjDone[proj][part] += 1 seqPrjDone[proj][part] += 1
# newOp['manualTime']
# if it is a setup operation add the following operation # if it is a setup operation add the following operation
if 'SET' in newOp['operation']: if 'SET' in newOp['operation']:
...@@ -78,7 +77,7 @@ def findSequence(Projects, seqPrjDone, idDone): ...@@ -78,7 +77,7 @@ def findSequence(Projects, seqPrjDone, idDone):
newOp['autoTime'] = 0 newOp['autoTime'] = 0
newOp['preID'] = None newOp['preID'] = None
if newOp['operation'] in ['INJM', 'MILL', 'EDM', 'TURN', 'DRILL']: if newOp['operation'] in ['INJM', 'MILL', 'EDM']: #, 'TURN', 'DRILL']:
newOp['mode'] = 'MA' newOp['mode'] = 'MA'
elif newOp['operation'] == 'INJM-MAN': elif newOp['operation'] == 'INJM-MAN':
...@@ -88,6 +87,8 @@ def findSequence(Projects, seqPrjDone, idDone): ...@@ -88,6 +87,8 @@ def findSequence(Projects, seqPrjDone, idDone):
else: else:
newOp['mode'] = 'M' newOp['mode'] = 'M'
newOp['sequence'] = seqPrjDone[proj][part]
opReady.append(newOp) opReady.append(newOp)
print 'pre', opReady print 'pre', opReady
...@@ -97,16 +98,3 @@ def findSequence(Projects, seqPrjDone, idDone): ...@@ -97,16 +98,3 @@ def findSequence(Projects, seqPrjDone, idDone):
return opReady return opReady
if __name__ == '__main__':
import jsonReader as jR
seq = jR.seqPrjDone
seq['Order 1']['Order 1 - Mould'] = 2
seq['Order 1']['Order 1 - Part 01'] = 3
seq['Order 1']['Order 1 - Part 02'] = 3
seq['Order 1']['Order 1 - Part 03'] = 1
op = findSequence(jR.Projects, jR.seqPrjDone, ['ID-00001','ID-00002','ID-00003','ID-00004','ID-00005', 'ID-00006', 'ID-00007', 'ID-00008', 'ID-00009'])
print 'op', op
\ No newline at end of file
...@@ -7,28 +7,29 @@ Created on 6 Aug 2015 ...@@ -7,28 +7,29 @@ Created on 6 Aug 2015
import datetime as dt import datetime as dt
from copy import deepcopy from copy import deepcopy
def shiftGenerator(startDate, noDays): def shiftGenerator(startDate, noDays, exceptions):
shift = {} shift = {}
day = 0 day = 0
actualDays = 0 actualDays = 0
preDay = deepcopy(startDate.date()) preDay = deepcopy(startDate.date())
while actualDays < noDays: while actualDays < noDays:
st = deepcopy(startDate)
if day: st = deepcopy(startDate)
dateStart = st.date() dateStart = st.date()
dateStart += dt.timedelta(days=day) dateStart += dt.timedelta(days=day)
if dateStart in exceptions:
st = dt.datetime(dateStart.year,dateStart.month, dateStart.day, exceptions[dateStart][0].hour, exceptions[dateStart][0].minute)
fin = dt.datetime(st.year, st.month, st.day, exceptions[st.date()][1].hour, exceptions[st.date()][1].minute)
else:
st = dt.datetime(dateStart.year,dateStart.month, dateStart.day, 8,0) st = dt.datetime(dateStart.year,dateStart.month, dateStart.day, 8,0)
if st.weekday() < 5:
fin = dt.datetime(st.year, st.month, st.day, 18,0) fin = dt.datetime(st.year, st.month, st.day, 18,0)
if st.weekday() < 5 or st.date() in exceptions:
shift[st] = {'end':fin, 'startMode':'SOS', 'endMode':'EOS', 'preDay':preDay} shift[st] = {'end':fin, 'startMode':'SOS', 'endMode':'EOS', 'preDay':preDay}
preDay = st.date() preDay = st.date()
actualDays += 1 actualDays += 1
day += 1 day += 1
return shift return shift
if __name__ == '__main__':
shift = shiftGenerator(dt.datetime(2015,8,4,12,00),10)
...@@ -127,13 +127,11 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime): ...@@ -127,13 +127,11 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
# print 'end manual', sortedTime[i] # print 'end manual', sortedTime[i]
if autoTime: if autoTime:
# if availTime[sortedTime[i]]['end']- max(tStart,sortedTime[i]) <= (manualTime+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':
if i==len(sortedTime)-1: if i==len(sortedTime)-1:
break break
# if availTime[sortedTime[i+1]]['startMode']=='SOS' and availTime[sortedTime[i+1]]['preDay'] == sortedTime[i].date() and availTime[sortedTime[i+1]]['end'] - max(tStart,sortedTime[i]) >= (manualTime+autoTime):
if availTime[sortedTime[i+1]]['startMode']=='SOS' and availTime[sortedTime[i+1]]['preDay'] == sortedTime[i].date() and availTime[sortedTime[i+1]]['end'] - max(tManualEnd,sortedTime[i]) >= autoTime: if availTime[sortedTime[i+1]]['startMode']=='SOS' and availTime[sortedTime[i+1]]['preDay'] == sortedTime[i].date() and availTime[sortedTime[i+1]]['end'] - max(tManualEnd,sortedTime[i]) >= autoTime:
break break
else: else:
...@@ -146,14 +144,12 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime): ...@@ -146,14 +144,12 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
else: else:
break break
# return sortedTime[i]
return startSorted, tManualEnd - max(tStart,startSorted) return startSorted, tManualEnd - max(tStart,startSorted)
def updateAvailTime(keyStart, reqTime, tStart, availTime): def updateAvailTime(keyStart, reqTime, tStart, availTime):
# tStart e` tempo effettivo di inizio calcolato in precedenza come max(tStart,keyStart) # tStart e` tempo effettivo di inizio calcolato in precedenza come max(tStart,keyStart)
# print 'update', keyStart, reqTime, tStart
if reqTime <= dt.timedelta(seconds=0): if reqTime <= dt.timedelta(seconds=0):
return availTime return availTime
...@@ -166,8 +162,7 @@ def updateAvailTime(keyStart, reqTime, tStart, availTime): ...@@ -166,8 +162,7 @@ def updateAvailTime(keyStart, reqTime, tStart, availTime):
availTime[keyStart]['end'] = tStart availTime[keyStart]['end'] = tStart
availTime[keyStart]['endMode'] = 'IS' availTime[keyStart]['endMode'] = 'IS'
# print 'inizio', keyStart, availTime[keyStart]
# case of interval ending before previous end # case of interval ending before previous end
if tStart+reqTime < tempSave['end']: if tStart+reqTime < tempSave['end']:
availTime[tStart+reqTime] = {'end':tempSave['end'], 'startMode':'IS', 'endMode':tempSave['endMode'], 'preDay':tempSave['preDay']} availTime[tStart+reqTime] = {'end':tempSave['end'], 'startMode':'IS', 'endMode':tempSave['endMode'], 'preDay':tempSave['preDay']}
...@@ -220,7 +215,7 @@ def availableTime_Shift(tStart, tEnd, availTime): ...@@ -220,7 +215,7 @@ def availableTime_Shift(tStart, tEnd, availTime):
print 'WARNING: beyond last interval' print 'WARNING: beyond last interval'
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)
if availTime[sortedTime[i+1]]['preDay'] == sortedTime[i].date() and sortedTime[i+1] >= tEnd: elif availTime[sortedTime[i+1]]['preDay'] == sortedTime[i].date() and sortedTime[i+1] >= tEnd:
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:
...@@ -234,28 +229,3 @@ def availableTime_Shift(tStart, tEnd, availTime): ...@@ -234,28 +229,3 @@ def availableTime_Shift(tStart, tEnd, availTime):
return availTime return availTime
if __name__ == '__main__':
availTime = {dt.datetime(2015, 7, 23, 8, 0): {'end': dt.datetime(2015, 7, 23, 18, 0), 'startMode': 'SOS', 'endMode': 'EOS'},
dt.datetime(2015, 7, 24, 8, 0): {'end': dt.datetime(2015, 7, 24, 18, 0), 'startMode': 'SOS', 'endMode': 'EOS'},
dt.datetime(2015, 7, 25, 8, 0): {'end': dt.datetime(2015, 7, 27, 18, 0), 'startMode': 'SOS', 'endMode': 'EOS'}}
tStart = dt.datetime(2015,7,23,12,00)
tEnd = dt.datetime(2015,7,25,14,0)
autoTime = dt.timedelta(hours=20)
manualTime = dt.timedelta(hours=4)
print tStart
keyStart, pt = availableTimeInterval_MM(manualTime, autoTime, tStart, availTime)
print keyStart
# pt = manualTime + autoTime
print 'pt', pt
if keyStart:
availTime = updateAvailTime(keyStart, pt, max(tStart,keyStart), availTime)
else:
print 'WARNING: operation cannot be performed'
#availTime = availableTime_Shift(tStart, tEnd, availTime)
print 'updated time', availTime
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment