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
b242d7a5
Commit
b242d7a5
authored
May 27, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Failure, Operator, and ObjectResource updated
parent
f1d38927
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
17 deletions
+42
-17
dream/simulation/Failure.py
dream/simulation/Failure.py
+28
-7
dream/simulation/ObjectResource.py
dream/simulation/ObjectResource.py
+7
-4
dream/simulation/Operator.py
dream/simulation/Operator.py
+5
-5
dream/simulation/Repairman.py
dream/simulation/Repairman.py
+2
-1
No files found.
dream/simulation/Failure.py
View file @
b242d7a5
...
@@ -96,19 +96,40 @@ class Failure(ObjectInterruption):
...
@@ -96,19 +96,40 @@ class Failure(ObjectInterruption):
failTime
=
self
.
env
.
now
failTime
=
self
.
env
.
now
if
(
self
.
repairman
and
self
.
repairman
!=
"None"
):
#if the failure needs a resource to be fixed, the machine waits until the
if
(
self
.
repairman
and
self
.
repairman
!=
"None"
):
#if the failure needs a resource to be fixed, the machine waits until the
#resource is available
#resource is available
yield
self
.
repairman
.
getResource
().
request
()
# print self.env.now, self.repairman.id, 'will be requested by', self.victim.id
# update the time that the repair started
# yield self.repairman.getResource().request()
timeOperationStarted
=
self
.
env
.
now
# print self.repairman.Res.users
self
.
repairman
.
timeLastOperationStarted
=
self
.
env
.
now
# # update the time that the repair started
# timeOperationStarted=self.env.now
# self.repairman.timeLastOperationStarted=self.env.now
with
self
.
repairman
.
getResource
().
request
()
as
request
:
yield
request
# update the time that the repair started
timeOperationStarted
=
self
.
env
.
now
self
.
repairman
.
timeLastOperationStarted
=
self
.
env
.
now
yield
self
.
env
.
timeout
(
self
.
rngTTR
.
generateNumber
())
# wait until the repairing process is over
self
.
victim
.
totalFailureTime
+=
self
.
env
.
now
-
failTime
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
victim
.
Up
=
True
self
.
outputTrace
(
"is up"
)
self
.
repairman
.
totalWorkingTime
+=
self
.
env
.
now
-
timeOperationStarted
continue
yield
self
.
env
.
timeout
(
self
.
rngTTR
.
generateNumber
())
# wait until the repairing process is over
yield
self
.
env
.
timeout
(
self
.
rngTTR
.
generateNumber
())
# wait until the repairing process is over
self
.
victim
.
totalFailureTime
+=
self
.
env
.
now
-
failTime
self
.
victim
.
totalFailureTime
+=
self
.
env
.
now
-
failTime
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
victim
.
Up
=
True
self
.
victim
.
Up
=
True
self
.
outputTrace
(
"is up"
)
self
.
outputTrace
(
"is up"
)
if
(
self
.
repairman
and
self
.
repairman
!=
"None"
):
#if a resource was used, it is now released
# if(self.repairman and self.repairman!="None"): #if a resource was used, it is now released
self
.
repairman
.
getResource
().
release
()
# print self.repairman.Res.users
self
.
repairman
.
totalWorkingTime
+=
self
.
env
.
now
-
timeOperationStarted
# print self.env.now, self.repairman.id, 'about to be release from', self.victim.id
# self.repairman.Res.release()
# self.repairman.totalWorkingTime+=self.env.now-timeOperationStarted
# #===========================================================================
# #===========================================================================
# # interrupts the victim
# # interrupts the victim
...
...
dream/simulation/ObjectResource.py
View file @
b242d7a5
...
@@ -24,7 +24,8 @@ Created on 18 Aug 2013
...
@@ -24,7 +24,8 @@ Created on 18 Aug 2013
'''
'''
Class that acts as an abstract. It should have no instances. All the Resources should inherit from it
Class that acts as an abstract. It should have no instances. All the Resources should inherit from it
'''
'''
from
SimPy.Simulation
import
Resource
# from SimPy.Simulation import Resource
import
simpy
# ===========================================================================
# ===========================================================================
# the resource that repairs the machines
# the resource that repairs the machines
...
@@ -32,13 +33,15 @@ from SimPy.Simulation import Resource
...
@@ -32,13 +33,15 @@ from SimPy.Simulation import Resource
class
ObjectResource
(
object
):
class
ObjectResource
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
from
Globals
import
G
self
.
env
=
G
.
env
self
.
initialized
=
False
self
.
initialized
=
False
def
initialize
(
self
):
def
initialize
(
self
):
self
.
totalWorkingTime
=
0
#holds the total working time
self
.
totalWorkingTime
=
0
#holds the total working time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
timeLastOperationStarted
=
0
#holds the time that the last repair was started
self
.
timeLastOperationStarted
=
0
#holds the time that the last repair was started
self
.
Res
=
Resource
(
self
.
capacity
)
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
capacity
=
self
.
capacity
)
# variable that checks whether the resource is already initialized
# variable that checks whether the resource is already initialized
self
.
initialized
=
True
self
.
initialized
=
True
# list with the coreObjects IDs that the resource services
# list with the coreObjects IDs that the resource services
...
@@ -50,7 +53,7 @@ class ObjectResource(object):
...
@@ -50,7 +53,7 @@ class ObjectResource(object):
# checks if the worker is available
# checks if the worker is available
# =======================================================================
# =======================================================================
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
return
len
(
self
.
Res
.
users
)
<
self
.
capacity
# =======================================================================
# =======================================================================
# actions to be taken after the simulation ends
# actions to be taken after the simulation ends
...
@@ -86,7 +89,7 @@ class ObjectResource(object):
...
@@ -86,7 +89,7 @@ class ObjectResource(object):
# returns the active queue of the resource
# returns the active queue of the resource
# =======================================================================
# =======================================================================
def
getResourceQueue
(
self
):
def
getResourceQueue
(
self
):
return
self
.
Res
.
activeQ
return
self
.
Res
.
users
# =======================================================================
# =======================================================================
# check if the resource is already initialized
# check if the resource is already initialized
...
...
dream/simulation/Operator.py
View file @
b242d7a5
...
@@ -26,7 +26,8 @@ Created on 22 Nov 2012
...
@@ -26,7 +26,8 @@ Created on 22 Nov 2012
models an operator that operates a machine
models an operator that operates a machine
'''
'''
from
SimPy.Simulation
import
Resource
,
now
# from SimPy.Simulation import Resource, now
import
simpy
import
xlwt
import
xlwt
import
scipy.stats
as
stat
import
scipy.stats
as
stat
from
ObjectResource
import
ObjectResource
from
ObjectResource
import
ObjectResource
...
@@ -49,7 +50,6 @@ class Operator(ObjectResource):
...
@@ -49,7 +50,6 @@ class Operator(ObjectResource):
self
.
Working
=
[]
# holds the percentage of working time
self
.
Working
=
[]
# holds the percentage of working time
# the following attributes are not used by the Repairman
# the following attributes are not used by the Repairman
# self.activeCallersList=[] # the list of object that request the operator
self
.
schedulingRule
=
schedulingRule
#the scheduling rule that the Queue follows
self
.
schedulingRule
=
schedulingRule
#the scheduling rule that the Queue follows
self
.
multipleCriterionList
=
[]
#list with the criteria used to sort the Entities in the Queue
self
.
multipleCriterionList
=
[]
#list with the criteria used to sort the Entities in the Queue
SRlist
=
[
schedulingRule
]
SRlist
=
[
schedulingRule
]
...
@@ -173,9 +173,9 @@ class Operator(ObjectResource):
...
@@ -173,9 +173,9 @@ class Operator(ObjectResource):
for
machine
in
candidateMachines
:
for
machine
in
candidateMachines
:
machine
.
critical
=
False
machine
.
critical
=
False
if
machine
.
broker
.
waitForOperator
:
if
machine
.
broker
.
waitForOperator
:
machine
.
timeWaiting
=
now
()
-
machine
.
broker
.
timeWaitForOperatorStarted
machine
.
timeWaiting
=
self
.
env
.
now
-
machine
.
broker
.
timeWaitForOperatorStarted
else
:
else
:
machine
.
timeWaiting
=
now
()
-
machine
.
timeLastEntityLeft
machine
.
timeWaiting
=
self
.
env
.
now
-
machine
.
timeLastEntityLeft
# find the stations that hold critical entities
# find the stations that hold critical entities
if
self
in
router
.
preemptiveOperators
:
if
self
in
router
.
preemptiveOperators
:
for
entity
in
station
.
getActiveObjectQueue
():
for
entity
in
station
.
getActiveObjectQueue
():
...
@@ -297,7 +297,7 @@ class Operator(ObjectResource):
...
@@ -297,7 +297,7 @@ class Operator(ObjectResource):
# if the repairman is currently working we have to count the time of this work
# if the repairman is currently working we have to count the time of this work
# if len(self.getResourceQueue())>0:
# if len(self.getResourceQueue())>0:
if
not
self
.
checkIfResourceIsAvailable
():
if
not
self
.
checkIfResourceIsAvailable
():
self
.
totalWorkingTime
+=
now
()
-
self
.
timeLastOperationStarted
self
.
totalWorkingTime
+=
self
.
env
.
now
-
self
.
timeLastOperationStarted
# Repairman was idle when he was not in any other state
# Repairman was idle when he was not in any other state
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
...
...
dream/simulation/Repairman.py
View file @
b242d7a5
...
@@ -26,7 +26,8 @@ Created on 14 Nov 2012
...
@@ -26,7 +26,8 @@ Created on 14 Nov 2012
models a repairman that can fix a machine when it gets failures
models a repairman that can fix a machine when it gets failures
'''
'''
from
SimPy.Simulation
import
Resource
,
now
# from SimPy.Simulation import Resource, now
import
simpy
from
Operator
import
Operator
from
Operator
import
Operator
# ===========================================================================
# ===========================================================================
...
...
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