Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
bd6cb0dc
Commit
bd6cb0dc
authored
Dec 05, 2013
by
Ioannis Papagiannopoulos
Committed by
Sebastien Robin
Dec 11, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
major modifications to OperatedMachine.py. OperatorPool and OperatedPoolBroker added
parent
ff79aaa1
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
662 additions
and
137 deletions
+662
-137
dream/simulation/OperatedMachine.py
dream/simulation/OperatedMachine.py
+422
-137
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+121
-0
dream/simulation/OperatorPool.py
dream/simulation/OperatorPool.py
+119
-0
No files found.
dream/simulation/OperatedMachine.py
View file @
bd6cb0dc
This diff is collapsed.
Click to expand it.
dream/simulation/OperatedPoolBroker.py
0 → 100644
View file @
bd6cb0dc
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 27 Nov 2013
@author: Ioannis
'''
'''
Models an Interruption that handles the operating of a Station by an ObjectResource
'''
from
SimPy.Simulation
import
Process
,
Resource
from
ObjectInterruption
import
ObjectInterruption
from
SimPy.Simulation
import
waituntil
,
now
,
hold
,
request
,
release
# ===========================================================================
# Class that handles the Operator Behavior
# ===========================================================================
class
Broker
(
ObjectInterruption
):
# =======================================================================
# according to this implementation one machine per broker is allowed
# The Broker is initiated within the Machine and considered as
# black box for the ManPy end Developer
# =======================================================================
def
__init__
(
self
,
operatedMachine
):
ObjectInterruption
.
__init__
(
self
,
operatedMachine
)
self
.
type
=
"Broker"
# variable used to hand in control to the Broker
self
.
call
=
False
# variables that have to do with timing
self
.
timeOperationStarted
=
0
self
.
timeLastOperationEnded
=
0
self
.
timeWaitForOperatorStarted
=
0
# =======================================================================
# the run method
# =======================================================================
def
run
(
self
):
while
1
:
yield
waituntil
,
self
,
self
.
brokerIsCalled
# wait until the broker is called
# ======= request a resource
if
self
.
victim
.
isOperated
()
\
and
any
(
type
==
"Load"
or
type
==
"Setup"
or
type
==
"Processing"
\
for
type
in
self
.
victim
.
multOperationTypeList
):
# update the time that the station is waiting for the operator
self
.
timeWaitForOperatorStarted
=
now
()
# # update the currentObject of the operatorPool
# self.victim.operatorPool.currentObject = self.victim
# wait until a resource is available
yield
waituntil
,
self
,
self
.
victim
.
operatorPool
.
checkIfResourceIsAvailable
# set the available resource as the currentOperator
self
.
victim
.
currentOperator
=
self
.
victim
.
operatorPool
.
findAvailableOperator
()
yield
request
,
self
,
self
.
victim
.
operatorPool
.
getResource
(
self
.
victim
.
currentOperator
)
# self.victim.totalTimeWaitingForOperator+=now()-self.timeWaitForOperatorStarted
# clear the timeWaitForOperatorStarted variable
self
.
timeWaitForOperatorStarted
=
0
# update the time that the operation started
self
.
timeOperationStarted
=
now
()
self
.
victim
.
currentOperator
.
timeLastOperationStarted
=
now
()
# ======= release a resource
elif
not
self
.
victim
.
isOperated
():
self
.
victim
.
currentOperator
.
totalWorkingTime
+=
now
()
-
self
.
victim
.
currentOperator
.
timeLastOperationStarted
yield
release
,
self
,
self
.
victim
.
operatorPool
.
getResource
(
self
.
victim
.
currentOperator
)
# the victim current operator must be cleared after the operator is released
self
.
victim
.
currentOperator
=
'None'
self
.
timeLastOperationEnded
=
now
()
else
:
pass
# return the control the machine.run
self
.
exitBroker
()
# =======================================================================
# call the broker
# filter for Broker - yield waituntil brokerIsCalled
# =======================================================================
def
brokerIsCalled
(
self
):
return
self
.
call
# =======================================================================
# the broker returns control to OperatedMachine.Run
# filter for Machine - yield request/release operator
# =======================================================================
def
brokerIsSet
(
self
):
return
not
self
.
call
# =======================================================================
# hand in the control to the Broker.run
# to be called by the machine
# =======================================================================
def
invokeBroker
(
self
):
self
.
call
=
True
# =======================================================================
# return control to the Machine.run
# =======================================================================
def
exitBroker
(
self
):
self
.
call
=
False
\ No newline at end of file
dream/simulation/OperatorPool.py
0 → 100644
View file @
bd6cb0dc
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 22 Nov 2012
@author: Ioannis
'''
'''
models a Broker that organizes the dispatch of operators/repairmen
'''
from
SimPy.Simulation
import
Resource
,
now
import
xlwt
import
scipy.stats
as
stat
from
ObjectResource
import
ObjectResource
from
Operator
import
Operator
# ===========================================================================
# the resource that handles multiple operators
# ===========================================================================
class
OperatorPool
(
ObjectResource
):
def
__init__
(
self
,
id
,
name
,
capacity
=
1
,
operatorsList
=
'None'
):
self
.
id
=
id
self
.
objName
=
name
self
.
type
=
"OperatorPool"
# self.Res=Resource(self.capacity)
# lists to hold statistics of multiple runs
# self.Waiting=[] # holds the percentage of waiting time
# self.Working=[] # holds the percentage of working time
# list with the coreObjects IDs that the Operators operate
self
.
coreObjectIds
=
[]
# list with the coreObjects that the Operators operate
self
.
coreObjects
=
[]
# holds the object/Machine that currently handles the operator pool
self
.
currentObject
=
'None'
# check if an operatorsList is 'None'
if
operatorsList
==
'None'
or
(
operatorsList
!=
'None'
and
len
(
operatorsList
)
==
0
):
# list of operators that the OperatorPool holds
self
.
operators
=
[]
# the capacity of the OperatorPool in Operators
self
.
capacity
=
capacity
# populate the the operators list and initiate the operators
for
index
in
range
(
self
.
capacity
):
id
=
'O_'
+
str
(
index
)
name
=
self
.
objName
+
str
(
index
)
operators
.
append
(
Operator
(
id
,
name
))
# if a list of operators is given then update accordingly the self.operators variable
else
:
assert
type
(
operatorsList
)
is
list
,
"operatorsList is not a List"
self
.
operators
=
operatorsList
self
.
capacity
=
len
(
self
.
operators
)
# =======================================================================
# initialize the object
# =======================================================================
def
initialize
(
self
):
# self.totalWorkingTime=0 #holds the total working time
# self.totalWaitingTime=0 #holds the total waiting time
# self.timeLastOperationStarted=0 #holds the time that the last operation was started
# initialize the operators
for
operator
in
self
.
operators
:
operator
.
initialize
()
# =======================================================================
# checks if there are operators available
# =======================================================================
def
checkIfResourceIsAvailable
(
self
):
# maxTimeWaiting = 0
# for operator in self.operators:
# for machine in operator.coreObjects:
# timeWaiting = now()-machine.broker.timeWaitForOperatorStarted
# if (timeWaiting>=maxTimeWaiting):
# maxTimeWaiting=timeWaiting
return
any
(
operator
.
checkIfResourceIsAvailable
()
==
True
for
operator
in
self
.
operators
)
# =======================================================================
# find the first available operator and return it
# =======================================================================
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
return
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
# =======================================================================
# returns the resource
# =======================================================================
def
getResource
(
self
,
operator
):
# have to return the resource of the first operator available
return
operator
.
getResource
()
# =======================================================================
# returns the active queue of the resource
# needs refining
# =======================================================================
def
getResourceQueue
(
self
,
operator
):
return
operator
.
getResourceQueue
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment