Commit c159762f authored by Georgios Dagkakis's avatar Georgios Dagkakis

Merge branch 'batchesBreaks'

parents bbeee29b 1690e1b8
from dream.plugins import plugin
from dream.plugins.TimeSupport import TimeSupportMixin
import datetime
class BatchesOperatorBreaks(plugin.InputPreparationPlugin, TimeSupportMixin):
""" Output the schedule of operators in an Excel file to be downloaded
"""
def preprocess(self, data):
strptime = datetime.datetime.strptime
# read the current date and define dateFormat from it
try:
now = strptime(data['general']['currentDate'], '%Y/%m/%d %H:%M')
data['general']['dateFormat']='%Y/%m/%d %H:%M'
except ValueError:
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
data['general']['dateFormat']='%Y/%m/%d'
self.initializeTimeSupport(data)
breakData=data['input']['operator_shift_spreadsheet']
for row in breakData:
if row[0] in ['Date', '', None]:
continue
date=strptime(row[0], '%Y/%m/%d')
operators=row[1].split(',')
i=4
while row[i] not in ['', None]:
breakStart=self.convertToSimulationTime(strptime("%s %s" % (row[0], row[i]), '%Y/%m/%d %H:%M'))
i+=1
breakEnd=self.convertToSimulationTime(strptime("%s %s" % (row[0], row[i]), '%Y/%m/%d %H:%M'))
i+=1
# if the end of break shift already finished we do not need to consider in simulation
if breakStart<0 and breakEnd<=0:
continue
# if the start of the shift is before now, set the start to 0
if breakStart<0:
breakStart=0
# sometimes the date may change (e.g. break from 23:00 to 01:00).
# these would be declared in the date of the start so add a date (self.timeUnitPerDay) to the end
if breakEnd<breakEnd:
breakEnd+=self.timeUnitPerDay
# add the break to the operator
for operator in operators:
PB=data['graph']['node'][operator]
interruptions=PB.get('interruptions',{})
scheduledBreaks=interruptions.get('scheduledBreak',{})
if scheduledBreaks:
scheduledBreaks['breakPattern'].append([breakStart,breakEnd])
else:
PB['interruptions']['scheduledBreak']={
"endUnfinished": 0,
"breakPattern": [
[
breakStart,
breakEnd
]
]
}
# import json
# outputJSONString=json.dumps(data['graph']['node'], indent=5)
# outputJSONFile=open('h.json', mode='w')
# outputJSONFile.write(outputJSONString)
return data
......@@ -28,10 +28,12 @@ class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
# loop in the results to find Operators
colorList=['blue','green','red',
'gold','black','Aqua',
'gold','Aqua',
'DarkRed','Fuchsia','Gray',
'magenta','yellow','Olive',
'orange','purple','pink']
'orange','purple','pink','BlanchedAlmond',
'BurlyWood','HotPink','LightGoldenRodYellow'
]
# create a dictionary so that all stations have their own color
colorDict={}
......@@ -45,6 +47,7 @@ class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
i=0
# set off-shift color to white
colorDict['off-shift']='white'
colorDict['on-break']='black'
for element in resultElements:
if element['_class']=="Dream.Operator":
......@@ -71,6 +74,10 @@ class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
k=0
for record in schedule:
for nextRecord in schedule[k+1:]:
# break on the first element with different stationId
if not (nextRecord['stationId']==record['stationId']):
break
# if the stationId is the same break
if nextRecord['stationId']==record['stationId']\
and not record is schedule[-1]:
nextExitTime=nextRecord.get('exitTime',maxSimTime)
......
......@@ -126,30 +126,53 @@
},
"view_operator_shift_spreadsheet": {
"configuration": {
"columns": [
{
"format": "date-time",
"name": "Date",
"type": "string"
},
{
"name": "Product Builder",
"type": "string"
},
{
"name": "Start",
"type": "string"
},
{
"name": "Stop",
"type": "string"
}
]
},
"gadget": "Input_viewSpreadsheet",
"title": "Product Builder Shifts Spreadsheet",
"type": "object_view"
},
"extend": [
"x",
"y"
],
"columns": [
{
"format": "date-time",
"name": "Date",
"type": "string"
},
{
"name": "Product Builder",
"type": "string"
},
{
"name": "Start",
"type": "string"
},
{
"name": "Stop",
"type": "string"
},
{
"name": "Break1 Start",
"type": "string"
},
{
"name": "Break1 Stop",
"type": "string"
},
{
"name": "Break2 Start",
"type": "string"
},
{
"name": "Break2 Stop",
"type": "string"
}
],
"handsontable_options": {
"minSpareCols": 1
}
},
"gadget": "Input_viewSpreadsheet",
"title": "Product Builder Shifts Spreadsheet",
"type": "object_view"
},
"view_operator_skill_spreadsheet": {
"configuration": {
"columns": [
......@@ -1174,64 +1197,7 @@
"edge": {},
"node": {}
},
"input": {
"machine_shift_spreadsheet": [
[
"Date",
"Machines",
"Start",
"Stop"
],
[
"",
"",
"",
""
]
],
"operator_shift_spreadsheet": [
[
"Date",
"Product Builder",
"Start",
"Stop"
],
[
null,
null,
null,
null
]
],
"operator_skill_spreadsheet": [
[
"Product Builder",
"Skills"
],
[
null,
null
]
],
"wip_spreadsheet": [
[
"ID",
"StationID",
"Number of Units",
"Remaining Units",
"Type",
"Batch ID"
],
[
null,
null,
null,
null,
null,
null
]
]
},
"input": {},
"result": {
"result_list": []
}
......
......@@ -162,30 +162,53 @@
"type": "object_view"
},
"view_operator_shift_spreadsheet": {
"configuration": {
"columns": [
{
"format": "date-time",
"name": "Date",
"type": "string"
},
{
"name": "Product Builder",
"type": "string"
},
{
"name": "Start",
"type": "string"
},
{
"name": "Stop",
"type": "string"
}
]
},
"gadget": "Input_viewSpreadsheet",
"title": "Product Builder Shifts Spreadsheet",
"type": "object_view"
"configuration": {
"extend": [
"x",
"y"
],
"columns": [
{
"format": "date-time",
"name": "Date",
"type": "string"
},
{
"name": "Product Builder",
"type": "string"
},
{
"name": "Start",
"type": "string"
},
{
"name": "Stop",
"type": "string"
},
{
"name": "Break1 Start",
"type": "string"
},
{
"name": "Break1 Stop",
"type": "string"
},
{
"name": "Break2 Start",
"type": "string"
},
{
"name": "Break2 Stop",
"type": "string"
}
],
"handsontable_options": {
"minSpareCols": 1
}
},
"gadget": "Input_viewSpreadsheet",
"title": "Product Builder Shifts Spreadsheet",
"type": "object_view"
},
"view_operator_skill_spreadsheet": {
"configuration": {
......@@ -2193,20 +2216,6 @@
null
]
],
"operator_shift_spreadsheet": [
[
"Date",
"Product Builder",
"Start",
"Stop"
],
[
null,
null,
null,
null
]
],
"operator_skill_spreadsheet": [
[
"Product Builder",
......@@ -2217,6 +2226,30 @@
null
]
],
"operator_shift_spreadsheet": [
[
"Date",
"Product Builder",
"Start",
"Stop",
"Break1 Start",
"Break1 Stop",
"Break2 Start",
"Break2 Stop",
null
],
[
null,
null,
null,
null,
null,
null,
null,
null,
null
]
],
"wip_spreadsheet": [
[
"ID",
......
......@@ -162,30 +162,53 @@
"type": "object_view"
},
"view_operator_shift_spreadsheet": {
"configuration": {
"columns": [
{
"format": "date-time",
"name": "Date",
"type": "string"
},
{
"name": "Product Builder",
"type": "string"
},
{
"name": "Start",
"type": "string"
},
{
"name": "Stop",
"type": "string"
}
]
},
"gadget": "Input_viewSpreadsheet",
"title": "Product Builder Shifts Spreadsheet",
"type": "object_view"
"configuration": {
"extend": [
"x",
"y"
],
"columns": [
{
"format": "date-time",
"name": "Date",
"type": "string"
},
{
"name": "Product Builder",
"type": "string"
},
{
"name": "Start",
"type": "string"
},
{
"name": "Stop",
"type": "string"
},
{
"name": "Break1 Start",
"type": "string"
},
{
"name": "Break1 Stop",
"type": "string"
},
{
"name": "Break2 Start",
"type": "string"
},
{
"name": "Break2 Stop",
"type": "string"
}
],
"handsontable_options": {
"minSpareCols": 1
}
},
"gadget": "Input_viewSpreadsheet",
"title": "Product Builder Shifts Spreadsheet",
"type": "object_view"
},
"view_operator_skill_spreadsheet": {
"configuration": {
......@@ -368,6 +391,10 @@
{
"_class": "dream.plugins.Batches.BatchesShift.BatchesShift",
"input_id": "ShiftSpreadsheet"
},
{
"_class": "dream.plugins.Batches.BatchesOperatorBreaks.BatchesOperatorBreaks",
"input_id": "BreakSpreadsheet"
}
]
},
......@@ -2145,7 +2172,7 @@
0.1
],
[
"Static weight value",
"Static weight value",
"1.6",
"1.3",
"0",
......@@ -2213,56 +2240,68 @@
""
]
],
"operator_shift_spreadsheet": [
"operator_shift_spreadsheet": [
[
"Date",
"Product Builder",
"Start",
"Stop"
],
"Date",
"Product Builder",
"Start",
"Stop",
"Break1 Start",
"Break1 Stop",
"Break2 Start",
"Break2 Stop",
null
],
[
"2015/02/16",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_16,PB_15,PB_17,PB_25,PB_30,PB_12",
"07:00",
"16:00"
],
"2015/02/16",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_16,PB_15,PB_17,PB_25,PB_30,PB_12",
"07:00",
"16:00",
null
],
[
"2015/02/16",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_10,PB_20,PB_21,PB_16,PB_15,PB_17,PB_25",
"16:00",
"01:00"
],
"2015/02/16",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_10,PB_20,PB_21,PB_16,PB_15,PB_17,PB_25",
"16:00",
"01:00",
null
],
[
"2015/02/17",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_16,PB_15,PB_17,PB_25,PB_30,PB_12",
"07:00",
"16:00"
],
"2015/02/17",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_16,PB_15,PB_17,PB_25,PB_30,PB_12",
"07:00",
"16:00",
null
],
[
"2015/02/17",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_10,PB_20,PB_21,PB_16,PB_15,PB_17,PB_25",
"16:00",
"01:00"
],
"2015/02/17",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_10,PB_20,PB_21,PB_16,PB_15,PB_17,PB_25",
"16:00",
"01:00",
null
],
[
"2015/02/18",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_16,PB_15,PB_17,PB_25,PB_30,PB_12",
"07:00",
"16:00"
],
"2015/02/18",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_16,PB_15,PB_17,PB_25,PB_30,PB_12",
"07:00",
"16:00",
null
],
[
"2015/02/18",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_10,PB_20,PB_21,PB_16,PB_15,PB_17,PB_25",
"16:00",
"01:00"
],
"2015/02/18",
"PB_1,PB_2,PB_3,PB_4,PB_7,PB_9,PB_10,PB_20,PB_21,PB_16,PB_15,PB_17,PB_25",
"16:00",
"01:00",
null
],
[
null,
null,
null,
null,
null,
null,
null,
null
]
],
],
"operator_skill_spreadsheet": [
[
"Product Builder",
......
{
"graph": {
"node": {
"E1": {
"interruptions": {},
"top": 0.05688622754491013,
"_class": "Dream.Exit",
"left": 0.7083333333333333
},
"S1": {
"name": "Source",
"top": 0.9431137724550899,
"entity": "Dream.Part",
"interArrivalTime": {
"Fixed": {
"distributionType": "Fixed",
"mean": 6
}
},
"interruptions": {},
"_class": "Dream.Source",
"left": 0.30208333333333337
},
"M1": {
"name": "Machine1",
"top": 0.5,
"processingTime": {
"Fixed": {
"mean": 3.0
}
},
"operationType": "MT-Load-Processing",
"interruptions": {},
"_class": "Dream.Machine",
"left": 0.5625
},
"O1": {
"capacity": 1,
"name": "Operator1",
"top": 0.721556886227545,
"interruptions": {
"scheduledBreak": {
"endUnfinished": 0,
"breakPattern": [
[
4,
6.5
]
]
}
},
"skills": [
"M1"
],
"_class": "Dream.Operator",
"left": 0.8489583333333334
}
},
"edge": {
"1": {
"source": "O1",
"destination": "M2",
"data": {},
"_class": "Dream.Edge"
},
"0": {
"source": "O1",
"destination": "M1",
"data": {},
"_class": "Dream.Edge"
},
"3": {
"source": "M1",
"destination": "E1",
"data": {},
"_class": "Dream.Edge"
},
"2": {
"source": "S1",
"destination": "M1",
"data": {},
"_class": "Dream.Edge"
}
}
},
"_class": "Dream.Simulation",
"general": {
"console": "No",
"numberOfReplications": "1",
"trace": "No",
"confidenceLevel": "0.95",
"maxSimTime": "10",
"_class": "Dream.Configuration"
}
}
\ No newline at end of file
......@@ -1198,7 +1198,7 @@ class Machine(CoreObject):
if station:
if issubclass(station.__class__, CoreObject):
operator.schedule[-1]["exitTime"] = self.env.now
elif not operator.schedule[-1]["station"].get("id", None)== "off-shift":
elif not operator.schedule[-1]["station"].get("id", None) in ["off-shift","on-break"]:
operator.schedule[-1]["exitTime"] = self.env.now
# if the operator becomes unavailable
if (not self.currentOperator.onShift) or self.currentOperator.onBreak:
......@@ -1208,6 +1208,7 @@ class Machine(CoreObject):
operator.timeLastBreakStarted=self.env.now
operator.unAssign() # set the flag operatorAssignedTo to None
operator.workingStation=None
operator.operatorDedicatedTo=None
self.toBeOperated = False
self.outputTrace(operator.name, "released from "+ self.objName)
# XXX in case of skilled operators which stay at the same station should that change
......
......@@ -107,7 +107,7 @@ class ScheduledBreak(ObjectInterruption):
self.victim.onBreak=False
self.victim.totalBreakTime+=self.env.now-self.victim.timeLastBreakStarted
self.victim.timeLastBreakEnded=self.env.now
self.outputTrace(self.victim.name,"rerurned from break")
self.outputTrace(self.victim.name,"returned from break")
if self.victim.schedule:
if not self.victim.schedule[-1].get("exitTime", None):
self.victim.schedule[-1]["exitTime"] = self.env.now
......
......@@ -180,7 +180,7 @@ class SkilledRouter(Router):
#===================================================================
self.availableOperatorList=[]
for operator in G.OperatorsList:
if operator.available and operator.onShift:
if operator.available and operator.onShift and not operator.onBreak:
self.availableOperatorList.append(operator.id)
......
......@@ -1575,7 +1575,7 @@
"type": "operator"
},
{
"color": "Olive",
"color": "orange",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_1St1M02",
......@@ -1586,7 +1586,7 @@
"text": "St1M0"
},
{
"color": "DarkRed",
"color": "Fuchsia",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_12St2M02",
......@@ -1608,7 +1608,7 @@
"text": "St7M0"
},
{
"color": "yellow",
"color": "Olive",
"duration": 2.0,
"entranceTime": 0.0,
"id": "PB_16St8M02",
......@@ -1619,7 +1619,7 @@
"text": "St8M0"
},
{
"color": "black",
"color": "Aqua",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_17St6M02",
......@@ -1630,7 +1630,7 @@
"text": "St6M0"
},
{
"color": "Aqua",
"color": "DarkRed",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_2St2M12",
......@@ -1641,7 +1641,7 @@
"text": "St2M1"
},
{
"color": "magenta",
"color": "yellow",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_25St8M12",
......@@ -1652,7 +1652,7 @@
"text": "St8M1"
},
{
"color": "pink",
"color": "BlanchedAlmond",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_3St1M12",
......@@ -1663,7 +1663,7 @@
"text": "St1M1"
},
{
"color": "Fuchsia",
"color": "Gray",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_30St3M02",
......@@ -1674,7 +1674,7 @@
"text": "St3M0"
},
{
"color": "orange",
"color": "purple",
"duration": 2.0,
"entranceTime": 0,
"id": "PB_4St0M12",
......
{
"_class": "Dream.Simulation",
"elementList": [
{
"_class": "Dream.Exit",
"family": "Exit",
"id": "E1",
"results": {
"lifespan": [
3.25
],
"takt_time": [
4.75
],
"throughput": [
2
]
}
},
{
"_class": "Dream.Machine",
"family": "Server",
"id": "M1",
"results": {
"blockage_ratio": [
0.0
],
"break_ratio": [
0.0
],
"failure_ratio": [
0.0
],
"loading_ratio": [
0.0
],
"off_shift_ratio": [
0.0
],
"setup_ratio": [
0.0
],
"waiting_ratio": [
40.0
],
"working_ratio": [
60.0
]
}
},
{
"_class": "Dream.Operator",
"family": "Operator",
"id": "O1",
"results": {
"off_shift_ratio": [
0.0
],
"on_break_ratio": [
25.0
],
"waiting_ratio": [
15.0
],
"working_ratio": [
60.0
]
}
},
{
"_class": "Dream.SkilledRouter",
"id": "SkilledRouter01",
"results": {
"solutionList": [
{
"allocation": {
"O1": "M1"
},
"time": 0
},
{
"allocation": {},
"time": 4.0
},
{
"allocation": {
"O1": "M1"
},
"time": 6.5
},
{
"allocation": {},
"time": 10.0
}
]
}
}
],
"general": {
"_class": "Dream.Configuration"
}
}
\ 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