Commit f1b8b2bd authored by Georgios Dagkakis's avatar Georgios Dagkakis

changes in frozen simulation

parent 6227d142
......@@ -18,6 +18,6 @@ class PostProcessingOfferPhase(plugin.OutputPreparationPlugin):
data['result']['result_list'][-1][self.configuration_dict['output_id']] = {
'name': 'Result.xlsx',
'mime_type': 'application/vnd.ms-excel',
'data': G.tabSchedule.xlsx.encode('base64')
'data': G.reportResults.xlsx.encode('base64')
}
return data
\ No newline at end of file
......@@ -10,10 +10,10 @@ class projTabular(plugin.OutputPreparationPlugin):
"""
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
for proj in G.completionDate.keys():
data['result']['result_list'][0]['exit_output'].append([proj, G.completionDate[proj]])
for proj in G.completionDate['Earliest'].keys():
data['result']['result_list'][0]['exit_output'].append([proj, G.completionDate['Earliest'][proj], G.completionDate['Latest'][proj]])
return data
......
......@@ -2,7 +2,7 @@
from dream.plugins import plugin
from operator import itemgetter
class schedTabular(plugin.OutputPreparationPlugin):
class schedTabularEarliest(plugin.OutputPreparationPlugin):
""" Output the schedule in a tab
"""
......@@ -11,7 +11,7 @@ class schedTabular(plugin.OutputPreparationPlugin):
from dream.simulation.applications.FrozenSimulation.Globals import G
# sort schedule items in start time ascending order
sList = []
for entry in G.tabSchedule:
for entry in G.tabSchedule['Earliest']:
if 'End Time' not in entry:
sList.append([x for x in entry])
sList = sorted(sList, key=itemgetter(5))
......@@ -19,3 +19,21 @@ class schedTabular(plugin.OutputPreparationPlugin):
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
\ No newline at end of file
......@@ -9,14 +9,25 @@ import tablib
class G:
Schedule={}
seqPrjDone = None
resAvailability = None
MachPool = None
PMPool = None
Projects = 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
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
......@@ -11,9 +11,6 @@ def findSequence(Projects, seqPrjDone, idDone):
opReady = []
print 'find sequence', Projects
print 'find sequence', seqPrjDone
for proj in seqPrjDone.keys():
for part in seqPrjDone[proj].keys():
......@@ -22,12 +19,11 @@ def findSequence(Projects, seqPrjDone, idDone):
possibleOp = True
print 'part', part, Projects[proj][part][seqPrjDone[proj][part]]['id']
if seqPrjDone[proj][part]==0 or Projects[proj][part][seqPrjDone[proj][part]-1]['id'] not in G.Schedule.keys():
# 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():
minStartTime = max(G.xlreftime, G.OrderDates[proj])
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
for preReq in Projects[proj][part][seqPrjDone[proj][part]]['preReq']:
......@@ -37,12 +33,11 @@ def findSequence(Projects, seqPrjDone, idDone):
break
else:
if minStartTime < G.Schedule[preReq]['endDate']:
minStartTime = G.Schedule[preReq]['endDate']
if minStartTime < G.Schedule[G.simMode][preReq]['endDate']:
minStartTime = G.Schedule[G.simMode][preReq]['endDate']
if possibleOp:
newOp = Projects[proj][part][seqPrjDone[proj][part]]
print newOp['id'], 'possible'
newOp['minStartTime'] = minStartTime
newOp['project'] = proj
newOp['part'] = part
......@@ -59,7 +54,6 @@ def findSequence(Projects, seqPrjDone, idDone):
seqPrjDone[proj][part] += 1
# verify that the operation is the same
print followOp['operation'], newOp['operation']
assert (followOp['operation'].split('-')[0] in newOp['operation'])
# update operation (erase set)
......@@ -91,10 +85,8 @@ def findSequence(Projects, seqPrjDone, idDone):
opReady.append(newOp)
print 'pre', opReady
opReady = sorted(opReady, key=itemgetter('sequence', 'manualTime', 'autoTime'))
print 'seq', seqPrjDone, G.seqPrjDone
return opReady
......@@ -114,22 +114,18 @@ def importInput(jInput, excelInput, algorithmAttributes):
part = item[0].encode('ascii', 'ignore')
#print 'startDate', startDate.date()
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'])
frozen[item[3]] = 'X'
G.tabSchedule.append([order,part, item[3],station,item[7],startDate,dateOut])
if station not in takenPeriods:
takenPeriods[station] = {}
G.tabScheduleOrig.append([order,part, item[3],station,item[7],startDate,dateOut])
takenPeriods[station][startDate] = {'endDate': dateOut, 'taskID':item[3]}
takenPeriods.setdefault(station,{})[startDate] = {'endDate': dateOut, 'taskID':item[3]}
# import PM schedule
PMschedule = dataJSON['result']['result_list'][selSol]['operator_gantt']['task_list']
# extract resource availability
for item in PMschedule:
if 'parent' in item.keys():
pm = item['parent']
......@@ -143,22 +139,17 @@ def importInput(jInput, excelInput, algorithmAttributes):
continue
if pt:
print pm, taskID
if pm not in takenPeriods:
takenPeriods[pm] = {}
takenPeriods[pm][startDate] = {'endDate': stopDate, 'taskID': taskID}
print 'frozen operations', forzenOpsData
print 'taken periods', takenPeriods
G.pmScheduleOrig.append([pm,startDate,stopDate,taskID])
#=================================
# Import Workplan from Excel file
#=================================
global numParts
WorkPlan = wb.sheet_by_index(0)
Projects = {}
......@@ -304,6 +295,15 @@ def importInput(jInput, excelInput, algorithmAttributes):
if 'INJM-MAN' in skills:
skills.remove('INJM-MAN')
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':''})
for sk in skills:
......@@ -348,11 +348,25 @@ def importInput(jInput, excelInput, algorithmAttributes):
resAvailability[mach] = availableTime_Shift(unavailDate,takenPeriods[mach][unavailDate]['endDate'],resAvailability[mach])
# set global variables
G.resAvailability = deepcopy(resAvailability)
G.seqPrjDone = deepcopy(seqPrjDone)
G.resAvailability = deepcopy(resAvailability)
G.seqPrjDoneOrig = deepcopy(seqPrjDone)
G.resAvailabilityOrig = deepcopy(resAvailability)
G.MachPool = deepcopy(MachPool)
print 'mach pool',G.MachPool
G.PMPool = deepcopy(PMPool)
G.Projects = deepcopy(Projects)
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)
......@@ -12,8 +12,10 @@ def availableTimeInterval_Manual(manualTime, tStart, availTime):
# suitable for manual operations...returns available time until the end
# sort time intervals according to ascending start date
sortedTime = sorted(availTime.keys())
# find the interval for which the start date is just above tStart
i = 0
while i<len(sortedTime) and sortedTime[i] <= tStart:
i += 1
......@@ -25,6 +27,7 @@ def availableTimeInterval_Manual(manualTime, tStart, availTime):
# if i == 0 and tStart + manualTime < sortedTime[i]:
# return None
# go to next interval if available time is null
if availTime[sortedTime[i]]['end'] - max(tStart,sortedTime[i]) <= dt.timedelta(seconds=0):
i += 1
......@@ -59,6 +62,10 @@ def availableTimeInterval_MM(manualTime, autoTime, tStart, availTime):
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':
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:
tCumulative = dt.timedelta(seconds=0)
......@@ -79,8 +86,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
sortedTime = sorted(availTime.keys())
print sortedTime
i = 0
while i<len(sortedTime) and sortedTime[i] <= tStart:
i += 1
......@@ -92,8 +97,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
# if i == 0 and tStart + autoTime + manualTime < sortedTime[i]:
# return None
print 'start', sortedTime[i]
while True:
tCumulative = dt.timedelta(seconds=0)
......@@ -104,6 +107,10 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
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':
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:
tCumulative = dt.timedelta(seconds=0)
......@@ -124,8 +131,6 @@ def availableTimeInterval_MA(manualTime, autoTime, tStart, availTime):
if i>=len(sortedTime):
return None
# print 'end manual', sortedTime[i]
if autoTime:
if availTime[sortedTime[i]]['end']- max(tManualEnd,sortedTime[i]) <= autoTime:
if availTime[sortedTime[i]]['endMode'] == 'EOS':
......@@ -181,7 +186,6 @@ def updateAvailTime(keyStart, reqTime, tStart, availTime):
print 'WARNING: beyond planning horizon'
return availTime
# print 'find next time', sortedTime[i], i
if tStart+reqTime > sortedTime[i]:
# repeat procedure
availTime = updateAvailTime(sortedTime[i], reqTime - (sortedTime[i]-tStart), sortedTime[i], availTime)
......@@ -198,8 +202,6 @@ def availableTime_Shift(tStart, tEnd, availTime):
i += 1
# print i, sortedTime[i], availTime[sortedTime[i]]['end'], tStart, tEnd
if i>=len(sortedTime):
print 'WARNING: time interval not found'
return 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)
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)
else:
return availTime
......
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