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):
"stop": 0.5,
"_class": "dream.simulation.EventGenerator.EventGenerator",
"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
\ No newline at end of file
......@@ -3,7 +3,6 @@ Created on 4 Sep 2015
@author: Anna
'''
from dream.plugins import plugin
class projTabular(plugin.OutputPreparationPlugin):
......@@ -17,3 +16,5 @@ class projTabular(plugin.OutputPreparationPlugin):
data['result']['result_list'][0]['exit_output'].append([proj, G.completionDate[proj]])
return data
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):
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)
attachement_data = attachement_data.decode('base64')
......@@ -190,7 +190,7 @@ def exeSim(jsonInput, workplanInput):
excelInput = attachement_data
# read input data
importInput(jInput, excelInput)
importInput(jInput, excelInput, algorithmAttributes)
# find initial operation
opDone = []
......
......@@ -46,10 +46,9 @@ def findSequence(Projects, seqPrjDone, idDone):
newOp['minStartTime'] = minStartTime
newOp['project'] = proj
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']
seqPrjDone[proj][part] += 1
# newOp['manualTime']
# if it is a setup operation add the following operation
if 'SET' in newOp['operation']:
......@@ -78,7 +77,7 @@ def findSequence(Projects, seqPrjDone, idDone):
newOp['autoTime'] = 0
newOp['preID'] = None
if newOp['operation'] in ['INJM', 'MILL', 'EDM', 'TURN', 'DRILL']:
if newOp['operation'] in ['INJM', 'MILL', 'EDM']: #, 'TURN', 'DRILL']:
newOp['mode'] = 'MA'
elif newOp['operation'] == 'INJM-MAN':
......@@ -88,6 +87,8 @@ def findSequence(Projects, seqPrjDone, idDone):
else:
newOp['mode'] = 'M'
newOp['sequence'] = seqPrjDone[proj][part]
opReady.append(newOp)
print 'pre', opReady
......@@ -97,16 +98,3 @@ def findSequence(Projects, seqPrjDone, idDone):
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
import datetime as dt
from copy import deepcopy
def shiftGenerator(startDate, noDays):
def shiftGenerator(startDate, noDays, exceptions):
shift = {}
day = 0
actualDays = 0
preDay = deepcopy(startDate.date())
while actualDays < noDays:
st = deepcopy(startDate)
if day:
st = deepcopy(startDate)
dateStart = st.date()
dateStart += dt.timedelta(days=day)
st = dt.datetime(dateStart.year,dateStart.month, dateStart.day, 8,0)
if st.weekday() < 5:
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)
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}
preDay = st.date()
actualDays += 1
day += 1
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):
# print 'end manual', sortedTime[i]
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]]['endMode'] == 'EOS':
if i==len(sortedTime)-1:
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:
break
else:
......@@ -146,13 +144,11 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
else:
break
# return sortedTime[i]
return startSorted, tManualEnd - max(tStart,startSorted)
def updateAvailTime(keyStart, reqTime, tStart, availTime):
# tStart e` tempo effettivo di inizio calcolato in precedenza come max(tStart,keyStart)
# print 'update', keyStart, reqTime, tStart
if reqTime <= dt.timedelta(seconds=0):
return availTime
......@@ -166,7 +162,6 @@ def updateAvailTime(keyStart, reqTime, tStart, availTime):
availTime[keyStart]['end'] = tStart
availTime[keyStart]['endMode'] = 'IS'
# print 'inizio', keyStart, availTime[keyStart]
# case of interval ending before previous end
if tStart+reqTime < tempSave['end']:
......@@ -220,7 +215,7 @@ def availableTime_Shift(tStart, tEnd, availTime):
print 'WARNING: beyond last interval'
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)
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):
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