Commit 44488617 authored by Georgios Dagkakis's avatar Georgios Dagkakis

class G changed to class ManPyEnv that inherits from object

parent d332d203
......@@ -7,7 +7,7 @@ Created on 21 Aug 2013
import math
import numpy
import random
from Globals import G
from Globals import ManPyEnvironment
class Allocation():
def __init__(self, itemList, week, altRoutes, excBuffer):
......
......@@ -13,7 +13,7 @@ import xlwt
import xlrd
from AllocationRoutine import AllocationRoutine
from CoreObject import CoreObject
from Globals import G
from Globals import ManPyEnvironment
from ObjectInterruption import ObjectInterruption
from FutureDemandCreator import FutureDemandCreator
......@@ -29,7 +29,7 @@ class AllocationManagement(ObjectInterruption):
ObjectInterruption.initialize(self)
self.readData()
self.FDC=FutureDemandCreator()
from Globals import G
from Globals import ManPyEnvironment
G.AllocationManagementList.append(self)
def run(self):
......
......@@ -4,7 +4,7 @@ Created on 5 Sep 2013
@author: Anna
'''
from Globals import G
from Globals import ManPyEnvironment
from Allocation import Allocation
from JobMA import JobMA
......
......@@ -69,7 +69,7 @@ class Assembly(CoreObject):
# when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
from Globals import G
from Globals import ManPyEnvironment
G.AssemblyList.append(self)
# =======================================================================
......@@ -95,7 +95,7 @@ class Assembly(CoreObject):
# when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
from Globals import G
from Globals import ManPyEnvironment
G.AssemblyList.append(self)
#===========================================================================
......@@ -388,7 +388,7 @@ class Assembly(CoreObject):
# outputs results to JSON File
#===========================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': self.class_name,
'id': self.id,
'results': {}}
......
......@@ -30,7 +30,7 @@ BatchDecomposition is a Core Object that takes a batch and decomposes to sub-bat
# from SimPy.Simulation import waituntil, now, hold, waitevent
import simpy
from Globals import G
from Globals import ManPyEnvironment
from CoreObject import CoreObject
from RandomNumberGenerator import RandomNumberGenerator
......@@ -61,14 +61,14 @@ class BatchDecomposition(CoreObject):
self.operator=operator
# Sets the attributes of the processing (and failure) time(s)
self.rng=RandomNumberGenerator(self, processingTime)
from Globals import G
from Globals import ManPyEnvironment
G.BatchDecompositionList.append(self)
# =======================================================================
# initialize the internal resource of the object
# =======================================================================
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
G.BatchWaitingList = [] # batches waiting to be reassembled
CoreObject.initialize(self) # using the default CoreObject Functionality
self.Res=simpy.Resource(self.env, self.numberOfSubBatches) # initialize the Internal resource (Queue) functionality
......
......@@ -29,7 +29,7 @@ BatchReassembly is a Core Object that takes a number of subBatches and reassembl
# from SimPy.Simulation import activate, waituntil, now, hold, waitevent
import simpy
from Globals import G
from Globals import ManPyEnvironment
from RandomNumberGenerator import RandomNumberGenerator
from CoreObject import CoreObject
# from Entity import Entity
......@@ -60,7 +60,7 @@ class BatchReassembly(CoreObject):
self.operator=operator
# Sets the attributes of the processing (and failure) time(s)
self.rng=RandomNumberGenerator(self, processingTime)
from Globals import G
from Globals import ManPyEnvironment
G.BatchReassemblyList.append(self)
# flag to show if the objects outputs results
self.outputResults=bool(int(outputResults))
......@@ -335,7 +335,7 @@ class BatchReassembly(CoreObject):
# =======================================================================
def outputResultsJSON(self):
if self.outputResults:
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
'family': self.family,
......
......@@ -56,7 +56,7 @@ class BatchReassemblyBlocking(BatchReassembly):
def addBlockage(self):
# find the previous station
station=self.previous[0]
from Globals import G
from Globals import ManPyEnvironment
from ShiftScheduler import ShiftScheduler
if self.timeLastBlockageStarted:
# calculate how much time the previous station was offShift
......
......@@ -68,7 +68,7 @@ class BatchScrapMachine(Machine):
scrapQuantity = {'Fixed':{'mean': 0}}
self.scrapRng=RandomNumberGenerator(self, scrapQuantity)
from Globals import G
from Globals import ManPyEnvironment
G.BatchScrapMachineList.append(self)
# =======================================================================
......
......@@ -25,7 +25,7 @@ Created on 29 Oct 2013
models the source object that generates the Batches Entities
'''
from Source import Source
from Globals import G
from Globals import ManPyEnvironment
# from SimPy.Simulation import Process
import simpy
from RandomNumberGenerator import RandomNumberGenerator
......@@ -36,7 +36,7 @@ class BatchSource(Source):
Source.__init__(self, id=id, name=name,
interArrivalTime=interArrivalTime, entity=entity)
self.numberOfUnits = int(batchNumberOfUnits)
from Globals import G
from Globals import ManPyEnvironment
G.BatchSourceList.append(self)
......
......@@ -76,7 +76,7 @@ class ConditionalBuffer(QueueJobShop):
#===========================================================================
def getEntity(self):
activeEntity=QueueJobShop.getEntity(self)
from Globals import G
from Globals import ManPyEnvironment
# for all the entities in the EntityList
for entity in G.EntityList:
requiredParts=entity.getRequiredParts()
......
......@@ -55,7 +55,7 @@ class Conveyer(CoreObject):
# when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
from Globals import G
from Globals import ManPyEnvironment
G.ConveyerList.append(self)
#===========================================================================
......@@ -427,7 +427,7 @@ class Conveyer(CoreObject):
#===========================================================================
def postProcessing(self, MaxSimtime=None):
if MaxSimtime==None:
from Globals import G
from Globals import ManPyEnvironment
MaxSimtime=G.maxSimTime
self.moveEntities() #move the entities to count the working time
#if the conveyer is full count the blockage time
......@@ -446,7 +446,7 @@ class Conveyer(CoreObject):
# outputs results to JSON File
#===========================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': self.class_name,
'id': self.id,
'results': {}}
......@@ -466,7 +466,7 @@ class ConveyerMover(object):
#===========================================================================
def __init__(self, conveyer):
# Process.__init__(self)
from Globals import G
from Globals import ManPyEnvironment
self.env=G.env
self.conveyer=conveyer #the conveyer that owns the mover
self.timeToWait=0 #the time to wait every time. This is calculated by the conveyer and corresponds
......
......@@ -70,7 +70,7 @@ class CoreObject(ManPyObject):
self.station_col_inds=[]
self.op_col_indx=None
# if there is input in a dictionary parse from it
from Globals import G
from Globals import ManPyEnvironment
G.ObjList.append(self) # add object to ObjList
# list of expected signals of a station (values can be used as flags to inform on which signals is the station currently yielding)
self.expectedSignals={
......@@ -93,7 +93,7 @@ class CoreObject(ManPyObject):
self.WipStat=[]
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
self.env=G.env
self.Up=True #Boolean that shows if the object is in failure ("Down") or not ("up")
self.onShift=True
......@@ -262,7 +262,7 @@ class CoreObject(ManPyObject):
# XXX: there may be a case where one object is not assigned an operator, in that case we do not want to invoke the allocation routine
if self.checkForDedicatedOperators():
allocationNeeded=False
from Globals import G
from Globals import ManPyEnvironment
for obj in G.MachineList:
if obj.operatorPool!='None':
if obj.operatorPool.operators:
......@@ -392,7 +392,7 @@ class CoreObject(ManPyObject):
# # then it checks if there other requested entities by the same requesting entity.
# # Finally, it is controlled whether all the requested parts have concluded
# # their sequences for the requesting entity
# from Globals import G
# from Globals import ManPyEnvironment
# # for all the entities in the EntityList
# for entity in G.EntityList:
# requiredParts=entity.getRequiredParts()
......@@ -540,7 +540,7 @@ class CoreObject(ManPyObject):
# dummy variables that help prioritize the objects requesting to give objects to the object (activeObject)
maxTimeWaiting=0 # dummy variable counting the time a successor is waiting
receiver=None
from Globals import G
from Globals import ManPyEnvironment
for object in candidates:
timeWaiting=G.env.now-object.timeLastEntityLeft # the time it has been waiting is updated and stored in dummy variable timeWaiting
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):# if the timeWaiting is the maximum among the ones of the successors
......@@ -603,7 +603,7 @@ class CoreObject(ManPyObject):
# dummy variables that help prioritize the objects requesting to give objects to the object (activeObject)
maxTimeWaiting=0 # dummy variable counting the time a predecessor is blocked
giver=None
from Globals import G
from Globals import ManPyEnvironment
# loop through the possible givers to see which have to dispose and which is the one blocked for longer
for object in candidates:
# calculate how much the giver is waiting
......@@ -618,7 +618,7 @@ class CoreObject(ManPyObject):
# =======================================================================
def postProcessing(self, MaxSimtime=None):
if MaxSimtime==None:
from Globals import G
from Globals import ManPyEnvironment
MaxSimtime=G.maxSimTime
activeObject=self.getActiveObject()
......
......@@ -65,7 +65,7 @@ class Dismantle(CoreObject):
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
CoreObject.__init__(self, id, name)
from Globals import G
from Globals import ManPyEnvironment
if not processingTime:
processingTime = {'Fixed':{'mean': 0 }}
if 'Normal' in processingTime.keys() and\
......@@ -307,7 +307,7 @@ class Dismantle(CoreObject):
# Format is (Simulation Time | Entity or Frame Name | message)
#===========================================================================
def outputTrace(self, name, message):
from Globals import G
from Globals import ManPyEnvironment
if(G.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(self.env.now))
......@@ -325,7 +325,7 @@ class Dismantle(CoreObject):
# outputs results to JSON File
#===========================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': self.class_name,
'id': self.id,
'results': {}}
......
......@@ -49,7 +49,7 @@ class EventGenerator(ObjectInterruption):
if isinstance(self.argumentDict, basestring):
import ast
self.argumentDict=ast.literal_eval(self.argumentDict)
from Globals import G
from Globals import ManPyEnvironment
G.EventGeneratorList.append(self)
self.method=method
if isinstance(method, basestring):
......
......@@ -26,7 +26,7 @@ auxiliary script to handle excel related methods
'''
from Globals import G
from Globals import ManPyEnvironment
import xlwt
import xlrd
......@@ -34,31 +34,31 @@ import xlrd
#outputs the trace of the simulation run
def outputTrace(fileName='Trace'):
G.traceFile.save(str(fileName)+'.xls')
#outputs the log of the Entities given
#the format is (Entity Name | Station ID | Station Name| time)
def outputLog(fileName='Log', entityList=G.EntityList):
sheetIndex=1 #index that shows in which sheet we are
logIndex=0 #index that shows in what row we are
logFile = xlwt.Workbook() #create excel file
logSheet = logFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True) #create excel sheet
#post processing for outputting the Log
for entity in entityList:
for stop in entity.schedule:
logSheet.write(logIndex,0,entity.name)
logSheet.write(logIndex,1,stop["station"].id)
logSheet.write(logIndex,2,stop["station"].objName)
logSheet.write(logIndex,3,stop["entranceTime"])
logIndex+=1 #increment the row
#if we reach row 65536 we need to create a new sheet (excel limitation)
if(logIndex==65536):
logIndex=0
sheetIndex+=1
logSheet=logFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True)
logFile.save(str(fileName)+'.xls')
#
# #outputs the log of the Entities given
# #the format is (Entity Name | Station ID | Station Name| time)
# def outputLog(fileName='Log', entityList=G.EntityList):
# sheetIndex=1 #index that shows in which sheet we are
# logIndex=0 #index that shows in what row we are
# logFile = xlwt.Workbook() #create excel file
# logSheet = logFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True) #create excel sheet
#
# #post processing for outputting the Log
# for entity in entityList:
# for stop in entity.schedule:
# logSheet.write(logIndex,0,entity.name)
# logSheet.write(logIndex,1,stop["station"].id)
# logSheet.write(logIndex,2,stop["station"].objName)
# logSheet.write(logIndex,3,stop["entranceTime"])
# logIndex+=1 #increment the row
# #if we reach row 65536 we need to create a new sheet (excel limitation)
# if(logIndex==65536):
# logIndex=0
# sheetIndex+=1
# logSheet=logFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True)
#
# logFile.save(str(fileName)+'.xls')
#
def resetTrace():
# data for the trace output in excel
# -----------------------------------------------------------------------
......
......@@ -46,7 +46,7 @@ class Exit(CoreObject):
self.TaktTime=[]
# if input is given in a dictionary
CoreObject.__init__(self, id, name)
from Globals import G
from Globals import ManPyEnvironment
G.ExitList.append(self)
self.cancelCondition=cancelCondition
......@@ -107,7 +107,7 @@ class Exit(CoreObject):
def getEntity(self):
activeEntity = CoreObject.getEntity(self) #run the default method
# if the entity is in the G.pendingEntities list then remove it from there
from Globals import G
from Globals import ManPyEnvironment
# G.pendingEntities[:]=(entity for entity in G.pendingEntities if not entity is activeEntity)
if G.RouterList:
if activeEntity in G.pendingEntities:
......@@ -132,7 +132,7 @@ class Exit(CoreObject):
@staticmethod
def clear(entity):
from Globals import G
from Globals import ManPyEnvironment
def deleteEntityfromlist(entity, list):
if entity in list:
list.remove(entity)
......@@ -153,7 +153,7 @@ class Exit(CoreObject):
# actions to be taken after the simulation ends
# =======================================================================
def postProcessing(self, MaxSimtime=None):
from Globals import G
from Globals import ManPyEnvironment
if MaxSimtime==None:
MaxSimtime=G.maxSimTime
# hold the numberOfExits of each replication
......@@ -172,7 +172,7 @@ class Exit(CoreObject):
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = { '_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
'family': self.family,
......
......@@ -39,7 +39,7 @@ class ExitJobShop(Exit):
# set all the objects in previous
# =======================================================================
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
self.previous=G.ObjList
Exit.initialize(self) #run default behaviour
......
......@@ -27,7 +27,7 @@ models a frame entity. This can flow through the system and carry parts
'''
from simpy import Resource
from Globals import G
from Globals import ManPyEnvironment
from Entity import Entity
#The entity object
......
......@@ -29,7 +29,7 @@ import xlrd
import json
import urllib
from Globals import G
from Globals import ManPyEnvironment
from JobMA import JobMA
class FutureDemandCreator():
......
......@@ -35,94 +35,88 @@ from random import Random, expovariate, gammavariate, normalvariate
import simpy
# ===========================================================================
# globals
# ManPyEnvironment
# ===========================================================================
class G:
seed=1450 #the seed of the random number generator
Rnd = Random(seed) #random number generator
import numpy
numpyRnd=numpy
ObjList=[] #a list that holds all the CoreObjects
EntityList=[] #a list that holds all the Entities
ObjectResourceList=[]
ObjectInterruptionList=[]
RouterList=[]
numberOfReplications=1 #the number of replications default=1git
confidenceLevel=0.9 #the confidence level default=90%
Base=1 #the Base time unit. Default =1 minute
maxSimTime=0 #the total simulation time
# flag for printing in console
console=""
# data for the trace output in excel
trace="" #this is written from input. If it is "Yes" then you write to trace, else we do not
traceIndex=0 #index that shows in what row we are
sheetIndex=1 #index that shows in what sheet we are
traceFile = xlwt.Workbook() #create excel file
traceSheet = traceFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True) #create excel sheet
# variables for excel output
outputIndex=0 #index that shows in what row we are
sheetIndex=1 #index that shows in what sheet we are
outputFile = xlwt.Workbook() #create excel file
outputSheet = outputFile.add_sheet('sheet '+str(sheetIndex), cell_overwrite_ok=True) #create excel sheet
#variables for json output
outputJSON={}
outputJSONFile=None
class ManPyEnvironment(object):
def __init__(self,seed=1):
self.seed=seed #the seed of the random number generator
self.Rnd = Random(self.seed) #random number generator
import numpy
self.numpyRnd=numpy
numberOfEntities = 0
# define the lists of each object type
SourceList=[]
MachineList=[]
ExitList=[]
QueueList=[]
RepairmanList=[]
AssemblyList=[]
DismantleList=[]
ConveyerList=[]
MachineJobShopList=[]
QueueJobShopList=[]
ExitJobShopList=[]
BatchDecompositionList=[]
BatchSourceList=[]
BatchReassemblyList=[]
LineClearanceList=[]
EventGeneratorList=[]
OperatorsList = []
OperatorManagedJobsList = []
OperatorPoolsList = []
BrokersList = []
OperatedMachineList = []
BatchScrapMachineList=[]
OrderDecompositionList=[]
ConditionalBufferList=[]
MouldAssemblyBufferList=[]
MouldAssemblyList=[]
MachineManagedJobList=[]
QueueManagedJobList=[]
ModelResourceList=[]
self.ObjList=[] #a list that holds all the CoreObjects
self.EntityList=[] #a list that holds all the Entities
self.ObjectResourceList=[]
self.ObjectInterruptionList=[]
self.RouterList=[]
self.numberOfReplications=1 #the number of replications default=1git
self.confidenceLevel=0.9 #the confidence level default=90%
self.Base=1 #the Base time unit. Default =1 minute
self.maxSimTime=0 #the total simulation time
# flag for printing in console
self.console=""
# data for the trace output in excel
self.trace="" #this is written from input. If it is "Yes" then you write to trace, else we do not
self.traceIndex=0 #index that shows in what row we are
self.sheetIndex=1 #index that shows in what sheet we are
self.traceFile = xlwt.Workbook() #create excel file
self.traceSheet = self.traceFile.add_sheet('sheet '+str(self.sheetIndex), cell_overwrite_ok=True) #create excel sheet
#variables for json output
self.outputJSON={}
self.outputJSONFile=None
self.numberOfEntities = 0
# define the lists of each object type
self.SourceList=[]
self.MachineList=[]
self.ExitList=[]
self.QueueList=[]
self.RepairmanList=[]
self.AssemblyList=[]
self.DismantleList=[]
self.ConveyerList=[]
self.MachineJobShopList=[]
self.QueueJobShopList=[]
self.ExitJobShopList=[]
self.BatchDecompositionList=[]
self.BatchSourceList=[]
self.BatchReassemblyList=[]
self.LineClearanceList=[]
self.EventGeneratorList=[]
self.OperatorsList = []
self.OperatorManagedJobsList = []
self.OperatorPoolsList = []
self.BrokersList = []
self.OperatedMachineList = []
self.BatchScrapMachineList=[]
self.OrderDecompositionList=[]
self.ConditionalBufferList=[]
self.MouldAssemblyBufferList=[]
self.MouldAssemblyList=[]
self.MachineManagedJobList=[]
self.QueueManagedJobList=[]
self.ModelResourceList=[]
self.JobList=[]
self.WipList=[]
self.EntityList=[]
self.PartList=[]
self.OrderComponentList=[]
self.OrderList=[]
self.MouldList=[]
self.BatchList=[]
self.SubBatchList=[]
# entities that just finished processing in a station
# and have to enter the next machine
self.pendingEntities=[]
self.env=simpy.Environment()
JobList=[]
WipList=[]
EntityList=[]
PartList=[]
OrderComponentList=[]
OrderList=[]
MouldList=[]
BatchList=[]
SubBatchList=[]
# entities that just finished processing in a station
# and have to enter the next machine
pendingEntities=[]
env=simpy.Environment()
totalPulpTime=0 # temporary to track how much time PuLP needs to run
self.totalPulpTime=0 # temporary to track how much time PuLP needs to run
# =======================================================================
# method to move entities exceeding a certain safety stock
......@@ -315,7 +309,7 @@ def countIntervalThroughput(**kw):
# #===========================================================================
# def printTrace(entity='',station='', **kw):
# assert len(kw)==1, 'only one phrase per printTrace supported for the moment'
# from Globals import G
# from Globals import ManPyEnvironment
# time=G.env.now
# charLimit=60
# remainingChar=charLimit-len(entity)-len(str(time))
......
......@@ -26,7 +26,7 @@ Job is an Entity that implements the logic of a job shop. Job carries attributes
in the system and also in the processing times at each station
'''
from Globals import G
from Globals import ManPyEnvironment
from Entity import Entity
# =======================================================================
......@@ -77,7 +77,7 @@ class Job(Entity): # inherits from the Entity c
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
if(G.numberOfReplications==1): #if we had just one replication output the results to excel
json = { '_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
......@@ -307,7 +307,7 @@ class Job(Entity): # inherits from the Entity c
# method that finds a receiver for a candidate entity
#===========================================================================
def findCandidateReceiver(self):
from Globals import G
from Globals import ManPyEnvironment
router=G.RouterList[0]
# initiate the local list variable available receivers
availableReceivers=[x for x in self.candidateReceivers\
......
......@@ -31,7 +31,7 @@ logger = logging.getLogger("dream.platform")
from SimPy.Simulation import activate, initialize, simulate, now, infinity
from Globals import G
from Globals import ManPyEnvironment
from Source import Source
from Machine import Machine
from Exit import Exit
......
......@@ -38,7 +38,7 @@ logger = logging.getLogger("dream.platform")
import numpy
numpy.seterr(all='raise')
import simpy
from dream.simulation.Globals import G
from dream.simulation.Globals import ManPyEnvironment
from dream.simulation.Order import Order
from dream.simulation.OrderDesign import OrderDesign
from dream.simulation.Mould import Mould
......@@ -610,7 +610,9 @@ def activateObjects():
# ===========================================================================
def main(argv=[], input_data=None):
argv = argv or sys.argv[1:]
environment=ManPyEnvironment()
print environment
#create an empty list to store all the objects in
G.ObjList=[]
G.RouterList=[]
......
......@@ -57,7 +57,7 @@ class Machine(CoreObject):
canDeliverOnInterruption=False, **kw):
self.type="Machine" #String that shows the type of object
CoreObject.__init__(self, id, name)
from Globals import G
from Globals import ManPyEnvironment
processingTime=self.getOperationTime(time=processingTime)
......@@ -214,7 +214,7 @@ class Machine(CoreObject):
the list of operators provided
if the list is empty create operator pool with empty list
'''
from Globals import G
from Globals import ManPyEnvironment
# XXX operatorPool is not None ?
# if a list of operators is provided as argument
if (type(operatorPool) is list) and len(operatorPool)>0:
......@@ -255,7 +255,7 @@ class Machine(CoreObject):
def createRouter(self):
# initiate the Broker and the router
if (self.operatorPool!='None'):
from Globals import G
from Globals import ManPyEnvironment
# if there is no router
if not G.RouterList:
# TODO if the dedicatedOperator flag is raised then create a SkilledRouter (temp)
......@@ -362,7 +362,7 @@ class Machine(CoreObject):
else:
methodsNotRequired.append(tup)
required = True
from Globals import getMethodFromName
from Globals import ManPyEnvironmentetMethodFromName
if methodsRequired:
for methodTup in methodsRequired:
method, func = methodTup
......@@ -520,7 +520,7 @@ class Machine(CoreObject):
#===========================================================
self.currentOperator.totalWorkingTime+=self.env.now-self.currentOperator.timeLastOperationStarted
yield self.env.process(self.release())
from Globals import G
from Globals import ManPyEnvironment
# append the entity that was stopped to the pending ones
if G.RouterList:
G.pendingEntities.append(self.currentEntity)
......@@ -560,7 +560,7 @@ class Machine(CoreObject):
# =======================================================================
def run(self):
# request for allocation if needed
from Globals import G
from Globals import ManPyEnvironment
self.initialAllocationRequest()
# execute all through simulation time
while 1:
......@@ -911,7 +911,7 @@ class Machine(CoreObject):
self.outputTrace(activeObjectQueue[0].name,"ended processing in "+self.objName)
except IndexError:
pass
from Globals import G
from Globals import ManPyEnvironment
if G.RouterList:
# the just processed entity is added to the list of entities
# pending for the next processing
......@@ -1120,7 +1120,7 @@ class Machine(CoreObject):
if self.currentOperator:
self.currentOperator.schedule[-1]["entity"] = activeEntity
# after the machine receives an entity, it must be removed from the pendingEntities list
from Globals import G
from Globals import ManPyEnvironment
if G.RouterList:
if activeEntity in G.pendingEntities:
G.pendingEntities.remove(activeEntity)
......@@ -1166,7 +1166,7 @@ class Machine(CoreObject):
assert self.isInActiveQueue(entity), entity.id +' not in the internalQueue of'+ self.id
activeEntity=entity
from Globals import G
from Globals import ManPyEnvironment
router = G.RouterList[0]
# if the entity is in a machines who's broker waits for operator then
if self in router.pendingMachines:
......@@ -1212,7 +1212,7 @@ class Machine(CoreObject):
operator.workingStation=None
self.outputTrace(operator.name, "released from "+ self.objName)
# if the Router is expecting for signal send it
from Globals import G
from Globals import ManPyEnvironment
from SkilledOperatorRouter import SkilledRouter
self.toBeOperated = False
if G.RouterList[0].__class__ is SkilledRouter:
......@@ -1233,7 +1233,7 @@ class Machine(CoreObject):
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
'family': self.family,
......
......@@ -36,7 +36,7 @@ class MachineJobShop(Machine):
# set all the objects in previous and next
# =======================================================================
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
self.previous=G.ObjList
self.next=[]
Machine.initialize(self) #run default behaviour
......
......@@ -56,7 +56,7 @@ class MachineManagedJob(MachineJobShop):
id = self.id+'_OP'
name=self.objName+'_operatorPool'
self.operatorPool=OperatorPool(id, name, operatorsList=[])
from Globals import G
from Globals import ManPyEnvironment
G.OperatorPoolsList.append(self.operatorPool)
......@@ -65,7 +65,7 @@ class MachineManagedJob(MachineJobShop):
#===========================================================================
def createRouter(self):
#create a Router
from Globals import G
from Globals import ManPyEnvironment
if not G.RouterList:
self.router=RouterManaged()
G.RouterList[0]=self.router
......
......@@ -52,7 +52,7 @@ class ManPyObject(object):
@staticmethod
def requestAllocation():
# TODO: signal the Router, skilled operators must be assigned to operatorPools
from Globals import G
from Globals import ManPyEnvironment
G.RouterList[0].allocation=True
G.RouterList[0].waitEndProcess=False
if not G.RouterList[0].invoked and G.RouterList[0].expectedSignals['isCalled']:
......@@ -66,7 +66,7 @@ class ManPyObject(object):
#===========================================================================
@staticmethod
def signalRouter(receiver=None):
from Globals import G
from Globals import ManPyEnvironment
# if an operator is not assigned to the receiver then do not signal the receiver but the Router
try:
# in the case of skilled router there is no need to signal
......@@ -95,7 +95,7 @@ class ManPyObject(object):
#===========================================================================
@staticmethod
def checkForDedicatedOperators():
from Globals import G
from Globals import ManPyEnvironment
# XXX this can also be global
# flag used to inform if the operators assigned to the station are skilled (skillsList)
return any(operator.skillsList for operator in G.OperatorsList)
......@@ -103,7 +103,7 @@ class ManPyObject(object):
@staticmethod
def printTrace(entity='', **kw):
assert len(kw)==1, 'only one phrase per printTrace supported for the moment'
from Globals import G
from Globals import ManPyEnvironment
import Globals
time=G.env.now
charLimit=60
......@@ -135,7 +135,7 @@ class ManPyObject(object):
# =======================================================================
@staticmethod
def outputTrace(entityName, message):
from Globals import G
from Globals import ManPyEnvironment
if(G.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(G.env.now))
......@@ -182,7 +182,7 @@ class ManPyObject(object):
@staticmethod
def endSimulation():
# cancel all the scheduled events
from Globals import G
from Globals import ManPyEnvironment
from copy import copy
scheduledEvents=copy(G.env._queue)
for scheduledEvent in scheduledEvents:
......@@ -194,7 +194,7 @@ class ManPyObject(object):
# ======================================================================
@staticmethod
def checkIfSystemEmpty():
from Globals import G
from Globals import ManPyEnvironment
for object in G.ObjList:
if len(object.getActiveObjectQueue()):
return False
......
......@@ -25,7 +25,7 @@ Created on 17 Jan 2014
Mould is an Entity that assembled out of OrderComponents and has a parent Order
'''
from Globals import G
from Globals import ManPyEnvironment
from Job import Job
# ===========================================================================
......
......@@ -63,7 +63,7 @@ TODOs: check the case when a mould is already in the WIP by the beginning of the
'''
from MachineJobShop import MachineJobShop
import simpy
from Globals import G
from Globals import ManPyEnvironment
from RandomNumberGenerator import RandomNumberGenerator
# =======================================================================
......@@ -82,7 +82,7 @@ class MouldAssembly(MachineJobShop):
# parses inputs if they are given in a dictionary
# =======================================================================
def parseInputs(self, **kw):
from Globals import G
from Globals import ManPyEnvironment
G.MouldAssemblyList.append(self)
# =======================================================================
......
......@@ -64,7 +64,7 @@ class MouldAssemblyBuffer(ConditionalBuffer):
are present in other MouldAssemblyBuffers
'''
# execute default behaviour
from Globals import G
from Globals import ManPyEnvironment
activeObject = self.getActiveObject()
activeObjectQueue = activeObject.getActiveObjectQueue()
activeEntity=ConditionalBuffer.getEntity(self)
......
......@@ -64,7 +64,7 @@ TODOs: check the case when a mould is already in the WIP by the beginning of the
from MachineManagedJob import MachineManagedJob
# from SimPy.Simulation import Resource, reactivate, now
import simpy
from Globals import G
from Globals import ManPyEnvironment
# =======================================================================
# Error in the assembling of the mould
......
......@@ -46,7 +46,7 @@ class NonStarvingEntry(Queue):
# extend to create the initial WIP in the given level
def initialize(self):
Queue.initialize(self)
from Globals import G
from Globals import ManPyEnvironment
import Globals
for i in range(self.initialWIPLevel):
self.createEntity()
......@@ -64,7 +64,7 @@ class NonStarvingEntry(Queue):
# ToDo we could apply similar methodology to source.CreateEntity.
# Source JSON schema may change though.
def createEntity(self):
from Globals import G
from Globals import ManPyEnvironment
import Globals
entityType=self.entityData.get('_class', None)
extraArgs=dict(self.entityData)
......
......@@ -40,7 +40,7 @@ class ObjectInterruption(ManPyObject):
self.victim=victim
# variable used to hand in control to the objectInterruption
self.call=False
from Globals import G
from Globals import ManPyEnvironment
# G.ObjectInterruptionList.append(self)
# append the interruption to the list that victim (if any) holds
if self.victim:
......@@ -60,7 +60,7 @@ class ObjectInterruption(ManPyObject):
}
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
self.env=G.env
self.call=False
# events that are send by one interruption to all the other interruptions that might wait for them
......@@ -150,6 +150,6 @@ class ObjectInterruption(ManPyObject):
#===========================================================================
#print message in the console. Format is (Simulation Time | Entity or Frame Name | message)
def printTrace(self, entityName, message):
from Globals import G
from Globals import ManPyEnvironment
if(G.console=="Yes"): #output only if the user has selected to
print self.env.now, entityName, message
\ No newline at end of file
......@@ -42,11 +42,11 @@ class ObjectResource(ManPyObject):
self.alias=None
# list with the coreObjects IDs that the resource services
self.coreObjectIds=[]
from Globals import G
from Globals import ManPyEnvironment
G.ObjectResourceList.append(self)
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
# flag that shows if the resource is on shift
self.onShift=True
# flag that shows if the resource is on break
......
......@@ -90,7 +90,7 @@ class Broker(ObjectInterruption):
# update the time that the station is waiting for the operator
self.timeWaitForOperatorStarted=self.env.now
#===============================================================
from Globals import G
from Globals import ManPyEnvironment
# if the victim already holds an entity that means that the machine's operation type
# is no Load or setup, in that case the router is already invoked and the machine is already assigned an operator
......
......@@ -91,7 +91,7 @@ class Operator(ObjectResource):
self.coreObjectIds.append(station)
# flag to show if the resource is available at the start of simulation
self.available=available
from Globals import G
from Globals import ManPyEnvironment
G.OperatorsList.append(self)
# flag to show if the operator will output his schedule in the results
self.ouputSchedule=ouputSchedule
......@@ -136,7 +136,7 @@ class Operator(ObjectResource):
# sort candidate stations
#===========================================================================
def sortStations(self):
from Globals import G
from Globals import ManPyEnvironment
router=G.RouterList[0]
candidateMachines=self.candidateStations
# for the candidateMachines
......@@ -244,7 +244,7 @@ class Operator(ObjectResource):
activeObjectQ.sort(key=lambda x: (x.dueDate-x.totalRemainingProcessingTime))
#if the schedulingRule is to sort Entities based on the length of the following Queue
elif criterion=="WINQ":
from Globals import G
from Globals import ManPyEnvironment
for entity in activeObjectQ:
if len(entity.remainingRoute)>1:
nextObjIds=entity.remainingRoute[1].get('stationIdsList',[])
......@@ -263,7 +263,7 @@ class Operator(ObjectResource):
# =======================================================================
def postProcessing(self, MaxSimtime=None):
if MaxSimtime==None:
from Globals import G
from Globals import ManPyEnvironment
MaxSimtime=G.maxSimTime
# if the Operator is currently working we have to count the time of this work
......@@ -299,7 +299,7 @@ class Operator(ObjectResource):
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
'family': self.family,
......@@ -337,7 +337,7 @@ class Operator(ObjectResource):
# find the station of this step
station=record["station"] # XXX should also hold a list with all the machines G.MachineList?
# find the column corresponding to the machine
from Globals import G
from Globals import ManPyEnvironment
# 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)
......
......@@ -37,7 +37,7 @@ class OperatorManagedJob(Operator):
def __init__(self, id, name, capacity=1,schedulingRule="FIFO",**kw):
Operator.__init__(self,id=id,name=name,capacity=capacity,schedulingRule=schedulingRule)
from Globals import G
from Globals import ManPyEnvironment
G.OperatorManagedJobsList.append(self)
# =======================================================================
......@@ -83,7 +83,7 @@ class OperatorManagedJob(Operator):
# recursive method that searches for entities with available receivers
#===========================================================================
def findAvailableEntity(self):
from Globals import G
from Globals import ManPyEnvironment
router=G.RouterList[0]
# if the candidateEntities and the entitiesWithOccupiedReceivers lists are identical then return None
if len(set(self.candidateEntities).intersection(router.entitiesWithOccupiedReceivers))==len(self.candidateEntities):
......@@ -105,7 +105,7 @@ class OperatorManagedJob(Operator):
# method that finds a candidate entity for an operator
#===========================================================================
def findCandidateEntity(self):
from Globals import G
from Globals import ManPyEnvironment
router=G.RouterList[0]
# pick a candidateEntity
candidateEntity=self.findAvailableEntity()
......
......@@ -54,7 +54,7 @@ class Router(ObjectInterruption):
self.pending=[] # list of entities that require operators now
self.id=id
self.name=name
from Globals import G
from Globals import ManPyEnvironment
G.RouterList.append(self)
#===========================================================================
......@@ -178,7 +178,7 @@ class Router(ObjectInterruption):
# entry actions
#===========================================================================
def entryActions(self):
from Globals import G
from Globals import ManPyEnvironment
for operator in G.OperatorsList:
operator.candidateEntity=None
......@@ -186,7 +186,7 @@ class Router(ObjectInterruption):
# return control to the Machine.run
# =======================================================================
def exitActions(self):
from Globals import G
from Globals import ManPyEnvironment
# reset the variables that are used from the Router
for operator in self.candidateOperators:
operator.candidateEntities=[]
......@@ -210,7 +210,7 @@ class Router(ObjectInterruption):
# signal stations that wait for load operators
#===========================================================================
def signalOperatedStations(self):
from Globals import G
from Globals import ManPyEnvironment
for operator in self.candidateOperators:
station=operator.isAssignedTo()
if station:
......@@ -245,7 +245,7 @@ class Router(ObjectInterruption):
# find the stations that can be signalled by the router and the entities that are requesting operators now
#===========================================================================
def findPending(self):
from Globals import G
from Globals import ManPyEnvironment
# first sort the queues according to their sorting rule
for object in G.ObjList:
object.sortEntities()
......
......@@ -182,7 +182,7 @@ class RouterManaged(Router):
# signal stations that wait for load operators
#===========================================================================
def signalOperatedStations(self):
from Globals import G
from Globals import ManPyEnvironment
for operator in self.candidateOperators:
station=operator.isAssignedTo()
if station:
......@@ -208,7 +208,7 @@ class RouterManaged(Router):
# find the stations that can be signalled by the router
#===========================================================================
def findPendingObjects(self):
from Globals import G
from Globals import ManPyEnvironment
for entity in G.pendingEntities:
if entity.currentStation in G.MachineList:
if entity.currentStation.broker.waitForOperator:
......@@ -228,7 +228,7 @@ class RouterManaged(Router):
# finding the entities that require manager now
#===========================================================================
def findPendingEntities(self):
from Globals import G
from Globals import ManPyEnvironment
self.pending=[] # list of entities that are pending
for machine in self.pendingMachines:
self.pending.append(machine.currentEntity)
......@@ -280,7 +280,7 @@ class RouterManaged(Router):
# and by which machines
#=======================================================================
def sortCandidateEntities(self):
from Globals import G
from Globals import ManPyEnvironment
# TODO: the operator here actually chooses entity. This may pose a problem as two entities may be equivalent
# and as the operators chooses the sorting of the queue (if they do reside in the same queue is not taken into account)
......
......@@ -25,7 +25,7 @@ Created on 06 Jan 2013
Order is an Entity that can have its design, get broken to sub-components
'''
from Globals import G
from Globals import ManPyEnvironment
from Job import Job
# =======================================================================
......
......@@ -25,7 +25,7 @@ Created on 20 Dec 2013
OrderComponent is an Entity that is a component of a broader order
'''
from Globals import G
from Globals import ManPyEnvironment
from Job import Job
# ===========================================================================
......
......@@ -30,7 +30,7 @@ dummy object: infinite capacity no processing time
# from SimPy.Simulation import waituntil, now, hold, infinity, waitevent
import simpy
from Globals import G
from Globals import ManPyEnvironment
from CoreObject import CoreObject
from RandomNumberGenerator import RandomNumberGenerator
from Entity import Entity
......
......@@ -26,7 +26,7 @@ OrderDesign is an Entity that is a component of a broader order,
and is processed before it gets broken down into other components
'''
from Globals import G
from Globals import ManPyEnvironment
from Job import Job
# ===========================================================================
......
......@@ -27,7 +27,7 @@ models a part entity that flows through the system
'''
from Globals import G
from Globals import ManPyEnvironment
from Entity import Entity
#The part object
......
import Globals
import xlwt
from Globals import G
from Globals import ManPyEnvironment
import OrderComponent
import Mould
......
......@@ -66,7 +66,7 @@ class Queue(CoreObject):
if level:
assert level<=self.capacity, "the level cannot be bigger than the capacity of the queue"
self.level=level
from Globals import G
from Globals import ManPyEnvironment
G.QueueList.append(self)
@staticmethod
......@@ -307,7 +307,7 @@ class Queue(CoreObject):
activeObjectQ.sort(key=lambda x: (x.dueDate-x.totalRemainingProcessingTime))
#if the schedulingRule is to sort Entities based on the length of the following Queue
elif criterion=="WINQ":
from Globals import G
from Globals import ManPyEnvironment
for entity in activeObjectQ:
if len(entity.remainingRoute)>1:
nextObjIds=entity.remainingRoute[1].get('stationIdsList',[])
......@@ -322,7 +322,7 @@ class Queue(CoreObject):
assert False, "Unknown scheduling criterion %r" % (criterion, )
def outputResultsJSON(self):
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': str(self.id),
'family': self.family,
......
......@@ -37,7 +37,7 @@ class QueueJobShop(Queue):
# set all the objects in previous and next
# =======================================================================
def initialize(self):
from Globals import G
from Globals import ManPyEnvironment
self.previous=G.ObjList
self.next=[]
Queue.initialize(self) #run default behaviour
......@@ -173,7 +173,7 @@ class QueueJobShop(Queue):
def sortEntitiesForReceiver(self, receiver=None):
# TODO: if the receiver is already assigned an operator then the giver should sort for that manager
activeObject=self.getActiveObject()
from Globals import G
from Globals import ManPyEnvironment
for operator in G.OperatorsList:
if operator.isAssignedTo()==receiver:
activeObject.sortEntitiesForOperator(operator)
......
......@@ -104,7 +104,7 @@ class QueueManagedJob(QueueJobShop):
if receiver.isLoadRequested():
if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver:
try:
from Globals import G
from Globals import ManPyEnvironment
if not G.RouterList[0].invoked and G.RouterList[0].expectedSignals['isCalled']:
# self.printTrace(self.id, signal='router')
G.RouterList[0].invoked=True
......
......@@ -85,7 +85,7 @@ class RandomNumberGenerator(object):
self.obj = obj
def generateNumber(self):
from Globals import G
from Globals import ManPyEnvironment
if(self.distributionType=="Fixed"): #if the distribution is Fixed
return self.mean
elif(self.distributionType=="Exp"): #if the distribution is Exponential
......
......@@ -37,6 +37,6 @@ class Repairman(Operator):
def __init__(self, id, name, capacity=1,**kw):
Operator.__init__(self,id=id, name=name, capacity=capacity)
self.type="Repairman"
from Globals import G
from Globals import ManPyEnvironment
G.RepairmanList.append(self)
......@@ -98,7 +98,7 @@ class SkilledRouter(Router):
break
self.printTrace('','=-'*15)
from Globals import G
from Globals import ManPyEnvironment
if self.allocation:
#===================================================================
......@@ -327,7 +327,7 @@ class SkilledRouter(Router):
self.waitEndProcess=False
def checkIfAllocationShouldBeCalled(self):
from Globals import G
from Globals import ManPyEnvironment
# loop through the operators and the machines.
# If for one the shift ended or started right now allocation is needed
for obj in G.OperatorsList+G.MachineList:
......@@ -355,7 +355,7 @@ class SkilledRouter(Router):
def outputResultsJSON(self):
if self.outputSolutions:
from Globals import G
from Globals import ManPyEnvironment
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
'results': {}}
......
......@@ -30,7 +30,7 @@ models the source object that generates the entities
import simpy
from RandomNumberGenerator import RandomNumberGenerator
from CoreObject import CoreObject
from Globals import G
from Globals import ManPyEnvironment
import Globals
......@@ -100,7 +100,7 @@ class Source(CoreObject):
self.item=Globals.getClassFromName(entity) #the type of object that the Source will generate
self.scheduledEntities=[] # list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter]
from Globals import G
from Globals import ManPyEnvironment
G.SourceList.append(self)
#===========================================================================
......@@ -164,7 +164,7 @@ class Source(CoreObject):
# add newly created entity to pendingEntities
#===========================================================================
def appendEntity(self, entity):
from Globals import G
from Globals import ManPyEnvironment
assert entity, 'cannot append None entity'
activeEntity=entity
if G.RouterList:
......
......@@ -43,7 +43,7 @@ class SubBatch(Entity):
# check if the parent batch is already created. If not, then create it
batch=None
from Batch import Batch
from Globals import G
from Globals import ManPyEnvironment
for b in G.EntityList:
if b.id==parentBatchId:
batch=b
......
......@@ -32,7 +32,7 @@ from Source import Source
from Exit import Exit
from Part import Part
from Queue import Queue
from Globals import G
from Globals import ManPyEnvironment
import ExcelHandler
import Globals
......
......@@ -12,7 +12,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}, weightFactors
import glob
import os
import time
from Globals import G
from Globals import ManPyEnvironment
startPulp=time.time()
machines = machineList.keys()
......
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