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
f4d99470
Commit
f4d99470
authored
Dec 22, 2014
by
Georgios Dagkakis
Committed by
Ioannis Papagiannopoulos
Jan 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes to create random numbers based on the new format
parent
38044eb6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
45 deletions
+34
-45
dream/simulation/Machine.py
dream/simulation/Machine.py
+7
-19
dream/simulation/RandomNumberGenerator.py
dream/simulation/RandomNumberGenerator.py
+17
-15
dream/simulation/Source.py
dream/simulation/Source.py
+10
-11
No files found.
dream/simulation/Machine.py
View file @
f4d99470
...
@@ -70,7 +70,7 @@ class Machine(CoreObject):
...
@@ -70,7 +70,7 @@ class Machine(CoreObject):
# sets the repairman resource of the Machine
# sets the repairman resource of the Machine
self
.
repairman
=
repairman
self
.
repairman
=
repairman
# Sets the attributes of the processing (and failure) time(s)
# Sets the attributes of the processing (and failure) time(s)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
processingTime
)
# check whether the operators are provided with a skills set
# check whether the operators are provided with a skills set
# check whether the operators are provided with a skills set
# check whether the operators are provided with a skills set
self
.
dedicatedOperator
=
self
.
checkForDedicatedOperators
()
self
.
dedicatedOperator
=
self
.
checkForDedicatedOperators
()
...
@@ -102,11 +102,11 @@ class Machine(CoreObject):
...
@@ -102,11 +102,11 @@ class Machine(CoreObject):
# boolean to check whether the machine is being operated
# boolean to check whether the machine is being operated
self
.
toBeOperated
=
False
self
.
toBeOperated
=
False
# define the load times
# define the load times
self
.
loadRng
=
RandomNumberGenerator
(
self
,
**
loadTime
)
self
.
loadRng
=
RandomNumberGenerator
(
self
,
loadTime
)
# XX variable that informs on the need for setup
# XX variable that informs on the need for setup
self
.
setUp
=
True
self
.
setUp
=
True
# define the setup times
# define the setup times
self
.
stpRng
=
RandomNumberGenerator
(
self
,
**
setupTime
)
self
.
stpRng
=
RandomNumberGenerator
(
self
,
setupTime
)
# examine if there are multiple operation types performed by the operator
# examine if there are multiple operation types performed by the operator
# there can be Setup/Processing operationType
# there can be Setup/Processing operationType
# or the combination of both (MT-Load-Setup-Processing)
# or the combination of both (MT-Load-Setup-Processing)
...
@@ -192,25 +192,13 @@ class Machine(CoreObject):
...
@@ -192,25 +192,13 @@ class Machine(CoreObject):
@
staticmethod
@
staticmethod
def
getOperationTime
(
time
):
def
getOperationTime
(
time
):
def
refactorTime
(
time
):
if
time
:
if
time
[
"distribution"
]:
time
[
"distributionType"
]
=
time
[
"distribution"
]
for
key
in
time
[
time
[
"distribution"
]]:
time
[
key
]
=
time
[
time
[
"distribution"
]][
key
]
del
time
[
time
[
"distribution"
]]
del
time
[
"distribution"
]
return
time
# XXX update time to comply with old definition
# XXX update time to comply with old definition
time
=
refactorTime
(
time
)
'''returns the dictionary updated'''
'''returns the dictionary updated'''
if
not
time
:
if
not
time
:
time
=
{
'distributionType'
:
'Fixed'
,
time
=
{
'Fixed'
:{
'mean'
:
0
}}
'mean'
:
0
}
if
'Normal'
in
time
.
keys
()
and
\
if
time
[
'distributionType'
]
==
'Normal'
and
\
time
[
'Normal'
].
get
(
'max'
,
None
)
is
None
:
time
.
get
(
'max'
,
None
)
is
None
:
time
[
'Normal'
][
'max'
]
=
float
(
time
[
'Normal'
][
'mean'
])
+
5
*
float
(
time
[
'Normal'
][
'stdev'
])
time
[
'max'
]
=
float
(
time
[
'mean'
])
+
5
*
float
(
time
[
'stdev'
])
return
time
return
time
#===========================================================================
#===========================================================================
...
...
dream/simulation/RandomNumberGenerator.py
View file @
f4d99470
...
@@ -29,22 +29,24 @@ holds methods for generations of numbers from different distributions
...
@@ -29,22 +29,24 @@ holds methods for generations of numbers from different distributions
import
math
import
math
class
RandomNumberGenerator
(
object
):
class
RandomNumberGenerator
(
object
):
def
__init__
(
self
,
obj
,
distribution
Type
,
mean
=
0
,
stdev
=
0
,
min
=
0
,
max
=
0
,
alpha
=
0
,
beta
=
0
,
def
__init__
(
self
,
obj
,
distribution
,
mean
=
0
,
stdev
=
0
,
min
=
0
,
max
=
0
,
alpha
=
0
,
beta
=
0
,
logmean
=
0
,
logsd
=
0
,
probability
=
0
,
shape
=
0
,
scale
=
0
,
location
=
0
,
rate
=
0
,
**
kw
):
logmean
=
0
,
logsd
=
0
,
probability
=
0
,
shape
=
0
,
scale
=
0
,
location
=
0
,
rate
=
0
,
**
kw
):
self
.
distributionType
=
distributionType
self
.
distribution
=
distribution
self
.
mean
=
float
(
mean
or
0
)
self
.
distributionType
=
distribution
.
keys
()[
0
]
self
.
stdev
=
float
(
stdev
or
0
)
parameters
=
distribution
[
self
.
distributionType
]
self
.
min
=
float
(
min
or
0
)
self
.
mean
=
float
(
parameters
.
get
(
'mean'
,
0
))
self
.
max
=
float
(
max
or
0
)
self
.
stdev
=
float
(
parameters
.
get
(
'stdev'
,
0
))
self
.
alpha
=
float
(
alpha
or
0
)
self
.
min
=
float
(
parameters
.
get
(
'min'
,
0
))
self
.
beta
=
float
(
beta
or
0
)
self
.
max
=
float
(
parameters
.
get
(
'max'
,
0
))
self
.
logmean
=
float
(
logmean
or
0
)
self
.
alpha
=
float
(
parameters
.
get
(
'alpha'
,
0
))
self
.
logsd
=
float
(
logsd
or
0
)
self
.
beta
=
float
(
parameters
.
get
(
'beta'
,
0
))
self
.
probability
=
float
(
probability
or
0
)
self
.
logmean
=
float
(
parameters
.
get
(
'logmean'
,
0
))
self
.
shape
=
float
(
shape
or
0
)
self
.
logsd
=
float
(
parameters
.
get
(
'logsd'
,
0
))
self
.
scale
=
float
(
scale
or
0
)
self
.
probability
=
float
(
parameters
.
get
(
'probability'
,
0
))
self
.
location
=
float
(
location
or
0
)
self
.
shape
=
float
(
parameters
.
get
(
'shape'
,
0
))
self
.
rate
=
float
(
rate
or
0
)
self
.
scale
=
float
(
parameters
.
get
(
'scale'
,
0
))
self
.
location
=
float
(
parameters
.
get
(
'location'
,
0
))
self
.
rate
=
float
(
parameters
.
get
(
'rate'
,
0
))
self
.
obj
=
obj
self
.
obj
=
obj
def
generateNumber
(
self
):
def
generateNumber
(
self
):
...
...
dream/simulation/Source.py
View file @
f4d99470
...
@@ -72,7 +72,7 @@ class EntityGenerator(object):
...
@@ -72,7 +72,7 @@ class EntityGenerator(object):
entityCounter
=
G
.
numberOfEntities
+
len
(
self
.
victim
.
scheduledEntities
)
# this is used just ot output the trace correctly
entityCounter
=
G
.
numberOfEntities
+
len
(
self
.
victim
.
scheduledEntities
)
# this is used just ot output the trace correctly
self
.
victim
.
scheduledEntities
.
append
(
self
.
env
.
now
)
self
.
victim
.
scheduledEntities
.
append
(
self
.
env
.
now
)
self
.
victim
.
outputTrace
(
self
.
victim
.
item
.
type
+
str
(
entityCounter
),
"generated"
)
# output the trace
self
.
victim
.
outputTrace
(
self
.
victim
.
item
.
type
+
str
(
entityCounter
),
"generated"
)
# output the trace
yield
self
.
env
.
timeout
(
self
.
victim
.
calculateInter
a
rrivalTime
())
# wait until the next arrival
yield
self
.
env
.
timeout
(
self
.
victim
.
calculateInter
A
rrivalTime
())
# wait until the next arrival
#============================================================================
#============================================================================
# The Source object is a Process
# The Source object is a Process
...
@@ -81,22 +81,21 @@ class Source(CoreObject):
...
@@ -81,22 +81,21 @@ class Source(CoreObject):
#===========================================================================
#===========================================================================
# the __init__method of the Source class
# the __init__method of the Source class
#===========================================================================
#===========================================================================
def
__init__
(
self
,
id
,
name
,
inter
a
rrivalTime
=
None
,
entity
=
'Dream.Part'
,
**
kw
):
def
__init__
(
self
,
id
,
name
,
inter
A
rrivalTime
=
None
,
entity
=
'Dream.Part'
,
**
kw
):
# Default values
# Default values
if
not
inter
a
rrivalTime
:
if
not
inter
A
rrivalTime
:
inter
a
rrivalTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
}
inter
A
rrivalTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
}
if
interarrivalTime
[
'distributionType'
]
==
'Normal'
and
\
if
'Normal'
in
interArrivalTime
.
keys
()
and
\
inter
arrivalTime
.
get
(
'max'
,
None
)
is
None
:
inter
ArrivalTime
[
'Normal'
]
.
get
(
'max'
,
None
)
is
None
:
inter
arrivalTime
[
'max'
]
=
interarrivalTime
[
'mean'
]
+
5
*
interarrivalTime
[
'stdev'
]
inter
ArrivalTime
[
'Normal'
][
'max'
]
=
interArrivalTime
[
'Normal'
][
'mean'
]
+
5
*
interArrivalTime
[
'Normal'
]
[
'stdev'
]
CoreObject
.
__init__
(
self
,
id
,
name
)
CoreObject
.
__init__
(
self
,
id
,
name
)
# properties used for statistics
# properties used for statistics
self
.
total
I
nterArrivalTime
=
0
# the total interarrival time
self
.
total
i
nterArrivalTime
=
0
# the total interarrival time
self
.
numberOfArrivals
=
0
# the number of entities that were created
self
.
numberOfArrivals
=
0
# the number of entities that were created
self
.
type
=
"Source"
#String that shows the type of object
self
.
type
=
"Source"
#String that shows the type of object
self
.
rng
=
RandomNumberGenerator
(
self
,
interArrivalTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
interarrivalTime
)
self
.
item
=
Globals
.
getClassFromName
(
entity
)
#the type of object that the Source will generate
self
.
item
=
Globals
.
getClassFromName
(
entity
)
#the type of object that the Source will generate
...
@@ -186,7 +185,7 @@ class Source(CoreObject):
...
@@ -186,7 +185,7 @@ class Source(CoreObject):
#============================================================================
#============================================================================
# calculates the processing time
# calculates the processing time
#============================================================================
#============================================================================
def
calculateInter
a
rrivalTime
(
self
):
def
calculateInter
A
rrivalTime
(
self
):
return
self
.
rng
.
generateNumber
()
#this is if we have a default interarrival time for all the entities
return
self
.
rng
.
generateNumber
()
#this is if we have a default interarrival time for all the entities
# =======================================================================
# =======================================================================
...
...
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