Commit 3bc88530 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Batches: implementation of where-to (max WIP) rule

parent 43791a98
......@@ -73,7 +73,8 @@ class ReadSkilledOperators(plugin.InputPreparationPlugin):
"name": "SkilledRouter01",
"outputSolutions":1,
"twoPhaseSearch": int(data['general'].get('twoPhaseSearch',0)),
"checkCondition":1
"checkCondition":1,
"whereToMaxWIP": data['general'].get('whereToMaxWIP',0) == 'Yes',
}
return data
......@@ -30,6 +30,8 @@ import simpy
from OperatorRouter import Router
from opAss_LPmethod import opAss_LP
import Globals
import logging
from copy import deepcopy
# ===========================================================================
# Class that handles the Operator Behavior
......@@ -57,6 +59,8 @@ class SkilledRouter(Router):
self.tool=tool
self.checkCondition=checkCondition
self.twoPhaseSearch=twoPhaseSearch
self.whereToMaxWIP = kw.get('whereToMaxWIP', False)
self.logger = logging.getLogger("dream.platform")
#===========================================================================
# the initialize method
......@@ -212,6 +216,55 @@ class SkilledRouter(Router):
import time
startLP=time.time()
if LPFlag:
# XXX if the solution is empty, how do we allocate?
if self.whereToMaxWIP and self.previousSolution:
self.logger.info('------> %s' % self.env.now)
solution={}
maxWIP=-1
minWIP=float('inf')
machineWithMaxWIP=None
operatorToMove=None
# first, find the machine with max wip
for stationId, stationDict in self.availableStationsDict.iteritems():
wip = stationDict['WIP']
assignedOperatorList=[
x for x in self.previousSolution \
if self.previousSolution[x] == stationId \
and x in self.availableOperatorList
]
assert len(assignedOperatorList) in (0, 1), assignedOperatorList
if wip > maxWIP and not assignedOperatorList:
machineWithMaxWIP=stationId
solution={}
# First, search for an operator that was not
# previously assigned, and can handle the maxWIP station
for operatorId in self.availableOperatorList:
if operatorId not in self.previousSolution \
and self.availableStationsDict[machineWithMaxWIP]['stationID'] in self.operators.get('operatorId', []):
operatorToMove = operatorId
# Then, search for the machine with Min WIP that has skill for
# maxWIP station
if not operatorToMove:
for stationId, stationDict in self.availableStationsDict.iteritems():
wip = stationDict['WIP']
assignedOperatorList=[
x for x in self.previousSolution \
if self.previousSolution[x] == stationId \
and x in self.availableOperatorList
]
if wip < minWIP and assignedOperatorList \
and self.availableStationsDict[machineWithMaxWIP]['stationID']:
operatorToMove=assignedOperatorList[0]
# Copy previous solution for available operators
for operatorId, stationId in self.previousSolution.iteritems():
if operatorId in self.availableOperatorList:
solution[operatorId]=self.previousSolution[operatorId]
# move the operator that was identified to be moved to maxWIP
if operatorToMove and machineWithMaxWIP:
solution[operatorToMove]=machineWithMaxWIP
self.logger.info('moved %s to %s' % (operatorToMove, machineWithMaxWIP))
self.logger.info(solution)
else:
if self.twoPhaseSearch:
# remove all the blocked machines from the available stations
# and create another dict only with them
......
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