Commit ceee1158 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

cherry-pick from readWIPseperatelly. printRoute methods added to Job and...

cherry-pick from readWIPseperatelly. printRoute methods added to Job and Operator, printRoute static method updated
parent 4947a2ef
......@@ -50,6 +50,8 @@ class Job(Entity): # inherits from the Entity c
self.extraPropertyDict = extraPropertyDict
# variable used to differentiate entities with and entities without routes
self.family='Job'
# used by printRoute
self.alias='J'+str(len(G.JobList))
# =======================================================================
# outputs results to JSON File
......@@ -149,4 +151,58 @@ class Job(Entity): # inherits from the Entity c
if not self in router.conflictingEntities:
router.conflictingEntities.append(self)
return availableReceiver
#===========================================================================
# print the route (the different stations the entity moved through)
#===========================================================================
def printRoute(self):
if self.schedule:
for record in self.schedule:
# find the station of this step
station=record[0] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine
# XXX each machine should have at least 3 columns, 2 for the jobs and one for operators
if station in G.MachineList:
machine_index=G.MachineList.index(station)
# find the entrance time of this step
entrance_time=record[1] # the time entity entered station
# find the row corresponding to the event and start placing the name of the Job in the cells
entrance_time_index=G.events_list.index(entrance_time)
# find the exit time of this step
if len(record)==3:
exit_time=record[2] # the time the entity exited the station
# find the row corresponding to the event and place the name of the Job in the cell, this is the last cell of this processing
exit_time_index=G.events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(G.events_list)
# for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index
for step in range(entrance_time_index,exit_time_index+1, 1):
col_to_write=station.station_col_inds[0] # XXX
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not G.cells_to_write:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'job':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
continue
for cell in G.cells_to_write:
if cell['row']==step+1 and cell['col']==col_to_write:
next_col=station.station_col_inds[1] # XXX
if not next_col in [x['col'] for x in G.cells_to_write if x['row']==step+1]: # XXX
G.cells_to_write.append({'row':step+1, # XXX
'col':next_col, # XXX
'job':self.alias}) # XXX
G.routeTraceSheet.write(step+1, next_col, self.alias) # XXX
stepDone=True # XXX
break # XXX
cell['job']=cell['job']+','+self.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['job'])
stepDone=True
break
if not stepDone:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'job':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
......@@ -72,6 +72,8 @@ class Operator(ObjectResource):
self.candidateStations=[] # list of candidateStations of the stations (those stations that can receive an entity)
self.schedule=[] # the working schedule of the resource, the objects the resource was occupied by and the corresponding times
# alias used by printRoute
self.alias=self.id
@staticmethod
def getSupportedSchedulingRules():
......@@ -350,7 +352,7 @@ class Operator(ObjectResource):
G.outputIndex+=1
G.outputIndex+=1
# =======================================================================
# =======================================================================
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
......@@ -367,4 +369,50 @@ class Operator(ObjectResource):
json['results']['working_ratio'] = getConfidenceIntervals(self.Working)
json['results']['waiting_ratio'] = getConfidenceIntervals(self.Waiting)
G.outputJSON['elementList'].append(json)
\ No newline at end of file
#===========================================================================
# print the route (the different stations the resource was occupied by)
#===========================================================================
def printRoute(self):
if self.schedule:
for record in self.schedule:
# find the station of this step
station=record[0] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine
from Globals import G
# XXX each machine should have at least 3 columns, 2 for the jobs and one for operators
if station in G.MachineList:
machine_index=G.MachineList.index(station)
# find the entrance time of this step
entrance_time=record[1] # the time entity entered station
# find the row corresponding to the event and start placing the name of the Job in the G.cells_to_write
entrance_time_index=G.events_list.index(entrance_time)
# find the exit time of this step
if len(record)==3:
exit_time=record[2] # the time the entity exited the station
# find the row corresponding to the event and place the name of the Job in the cell, this is the last cell of this processing
exit_time_index=G.events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(G.events_list)
# for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index
for step in range(entrance_time_index,exit_time_index+1, 1):
col_to_write=station.op_col_indx
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not G.cells_to_write:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'worker':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
continue
for cell in G.cells_to_write:
if cell['row']==step+1 and cell['col']==col_to_write:
cell['worker']=cell['worker']+','+self.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['worker'])
stepDone=True
break
if not stepDone:
G.cells_to_write.append({'row':step+1,
'col':col_to_write,
'worker':self.alias})
G.routeTraceSheet.write(step+1, col_to_write, self.alias)
\ No newline at end of file
......@@ -61,150 +61,35 @@ def outputRoute():
number_of_machines=len(G.MachineList)
sortMachines() # sort the machines according to the priority specified in JOB_SHOP_TECHNOLOGY_SEQ
# get the events list
events_list=getEventsList(G.JobList+G.OperatorsList)
events_list.sort(cmp=None, key=None, reverse=False) # sort the events
number_of_events=len(events_list) # keep the total number of events
G.events_list=getEventsList(G.JobList+G.OperatorsList)
G.events_list.sort(cmp=None, key=None, reverse=False) # sort the events
number_of_events=len(G.events_list) # keep the total number of events
# create a table number_of_events X number_of_machines
G.routeTraceSheet.write(0,0, 'Time/Machines')
# write the events in the first column and the machineIDs in the first row
for j, event in enumerate(events_list):
for j, event in enumerate(G.events_list):
G.routeTraceSheet.write(j+1,0,float(event))
# XXX create 3 times as many columns as the number of machines
for j, machine in enumerate(G.MachineList):
machine.cell_ids=range(j*3+1,j*3+3)
machine.op_cel=j*3+3
machine.station_col_inds=range(j*3+1,j*3+3)
machine.op_col_indx=j*3+3
G.routeTraceSheet.write_merge(0,0,j*3+1,j*3+3,str(machine.id))
# sort the jobs according to their name
G.JobList.sort(key=lambda x:x.id)
# list of cells to be written
cells=[]
# orders that have aliases
order_aliases=[]
# indices of orders
order_index=1
# indices of jobs
job_index=0
# for every job in the JobList
for job in G.JobList:
job_index+=1
# choose alias for the job
try:
if not job.order in order_aliases:
job.order.alias='O'+str(order_index)
order_index+=1
order_aliases.append(job.order)
job.alias=job.order.alias+'J'+str(job_index)
except:
job.alias='J'+str(job_index)
if job.schedule:
for record in job.schedule:
# find the station of this step
station=record[0] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine
# XXX each machine should have at least 3 columns, 2 for the jobs and one for operators
if station in G.MachineList:
machine_index=G.MachineList.index(station)
# find the entrance time of this step
entrance_time=record[1] # the time entity entered station
# find the row corresponding to the event and start placing the name of the Job in the cells
entrance_time_index=events_list.index(entrance_time)
# find the exit time of this step
if len(record)==3:
exit_time=record[2] # the time the entity exited the station
# find the row corresponding to the event and place the name of the Job in the cell, this is the last cell of this processing
exit_time_index=events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(events_list)
# for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index
for step in range(entrance_time_index,exit_time_index+1, 1):
col_to_write=station.cell_ids[0]
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not cells:
cells.append({'row':step+1,
'col':col_to_write,
'job':job.alias})
G.routeTraceSheet.write(step+1, col_to_write, job.alias)
continue
for cell in cells:
if cell['row']==step+1 and cell['col']==col_to_write:
next_col=station.cell_ids[1]
if not next_col in [x['col'] for x in cells if x['row']==step+1]:
cells.append({'row':step+1,
'col':next_col,
'job':job.alias})
G.routeTraceSheet.write(step+1, next_col, job.alias)
stepDone=True
break
cell['job']=cell['job']+','+job.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['job'])
stepDone=True
break
if not stepDone:
cells.append({'row':step+1,
'col':col_to_write,
'job':job.alias})
G.routeTraceSheet.write(step+1, col_to_write, job.alias)
G.cells_to_write=[]
for job in G.JobList:
job.printRoute()
# list of cells to be written
cells=[]
G.cells_to_write=[]
# for every job in the JobList
for worker in G.OperatorsList:
# choose alias for the worker
worker.alias=worker.id
if worker.schedule:
for record in worker.schedule:
# find the station of this step
station=record[0] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine
# XXX each machine should have at least 3 columns, 2 for the jobs and one for operators
if station in G.MachineList:
machine_index=G.MachineList.index(station)
# find the entrance time of this step
entrance_time=record[1] # the time entity entered station
# find the row corresponding to the event and start placing the name of the Job in the cells
entrance_time_index=events_list.index(entrance_time)
# find the exit time of this step
if len(record)==3:
exit_time=record[2] # the time the entity exited the station
# find the row corresponding to the event and place the name of the Job in the cell, this is the last cell of this processing
exit_time_index=events_list.index(exit_time)
elif len(record)!=3:
exit_time_index=len(events_list)
# for the rows with indices entrance_time_index to exit_time_index print the id of the Job in the column of the machine_index
for step in range(entrance_time_index,exit_time_index+1, 1):
col_to_write=station.op_cel
stepDone=False
# check if the cell is already written, if yes, then modify it adding the new jobs but not overwrite it
if not cells:
cells.append({'row':step+1,
'col':col_to_write,
'worker':worker.alias})
G.routeTraceSheet.write(step+1, col_to_write, worker.alias)
continue
for cell in cells:
if cell['row']==step+1 and cell['col']==col_to_write:
cell['worker']=cell['worker']+','+worker.alias
G.routeTraceSheet.write(cell['row'], cell['col'], cell['worker'])
stepDone=True
break
if not stepDone:
cells.append({'row':step+1,
'col':col_to_write,
'worker':worker.alias})
G.routeTraceSheet.write(step+1, col_to_write, worker.alias)
worker.printRoute()
# reset list of cells to be written
del G.cells_to_write[:]
del G.events_list[:]
# print aliases
try:
......@@ -217,4 +102,4 @@ def outputRoute():
if job.schedule:
G.routeTraceSheet.write(number_of_events+2+j, 0, job.id)
G.routeTraceSheet.write(number_of_events+2+j, 1, job.alias)
\ 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