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
51ec5791
Commit
51ec5791
authored
Jan 30, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let errors propagate when something is wrong in input
parent
e01aea1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+10
-10
dream/simulation/RandomNumberGenerator.py
dream/simulation/RandomNumberGenerator.py
+5
-4
No files found.
dream/simulation/LineGenerationJSON.py
View file @
51ec5791
...
...
@@ -180,9 +180,9 @@ def createObjects():
element
[
'id'
]
=
element_id
# create a new entry for the element (dictionary)
# with key 'id' and value the the element_id
resourceClass
=
element
.
get
(
'_class'
,
'not found'
)
# get the class type of the element
if
resourceClass
==
'Dream.Repairman'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element
/ default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
if
resourceClass
==
'Dream.Repairman'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element
name
=
element
.
get
(
'name'
,
id
)
# get the name of the element / default 'not_found'
capacity
=
int
(
element
.
get
(
'capacity'
,
'1'
))
# get the capacity of the el. / defautl '1'
R
=
Repairman
(
element_id
,
name
,
capacity
)
# create a repairman object
R
.
coreObjectIds
=
getSuccessorList
(
id
)
# update the list of objects that the repairman repairs
...
...
@@ -226,7 +226,7 @@ def createObjects():
interarrivalTime
=
element
.
get
(
'interarrivalTime'
,{})
distributionType
=
interarrivalTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
interarrivalTime
.
get
(
'mean'
,
'0'
))
entity
=
str_to_class
(
element
.
get
(
'entity'
,
'not found'
)
)
# initialize entity
entity
=
str_to_class
(
element
[
'entity'
]
)
# initialize entity
S
=
Source
(
id
,
name
,
distributionType
,
mean
,
entity
)
# initialize Source
S
.
nextIds
=
getSuccessorList
(
id
)
G
.
SourceList
.
append
(
S
)
...
...
@@ -238,7 +238,7 @@ def createObjects():
interarrivalTime
=
element
.
get
(
'interarrivalTime'
,{})
distributionType
=
interarrivalTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
interarrivalTime
.
get
(
'mean'
,
'0'
))
entity
=
str_to_class
(
element
.
get
(
'entity'
,
'not found'
)
)
entity
=
str_to_class
(
element
[
'entity'
]
)
batchNumberOfUnits
=
int
(
element
.
get
(
'batchNumberOfUnits'
,
'not found'
))
S
=
BatchSource
(
id
,
name
,
distributionType
,
mean
,
entity
,
batchNumberOfUnits
)
S
.
nextIds
=
getSuccessorList
(
id
)
...
...
@@ -506,11 +506,11 @@ def createObjects():
elif
objClass
==
'Dream.BatchDecomposition'
:
id
=
element
.
get
(
'id'
,
'not found'
)
name
=
element
.
get
(
'name'
,
'not found'
)
processingTime
=
element
.
get
(
'processingTime'
,
{})
distributionType
=
processingTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
processingTime
.
get
(
'mean'
,
'0'
))
stdev
=
float
(
processingTime
.
get
(
'stdev'
,
'0'
))
min
=
float
(
processingTime
.
get
(
'min'
,
'0'
))
processingTime
=
element
[
'processingTime'
]
distributionType
=
processingTime
[
'distributionType'
]
mean
=
float
(
processingTime
.
get
(
'mean'
,
'0'
))
stdev
=
float
(
processingTime
.
get
(
'stdev'
,
'0'
))
min
=
float
(
processingTime
.
get
(
'min'
,
'0'
))
max
=
float
(
processingTime
.
get
(
'max'
,
'0'
))
numberOfSubBatches
=
int
(
element
.
get
(
'numberOfSubBatches'
,
'0'
))
BD
=
BatchDecomposition
(
id
,
name
,
distribution
=
distributionType
,
numberOfSubBatches
=
numberOfSubBatches
,
...
...
dream/simulation/RandomNumberGenerator.py
View file @
51ec5791
...
...
@@ -36,7 +36,7 @@ class RandomNumberGenerator(object):
self
.
alpha
=
0
self
.
beta
=
0
self
.
object
=
obj
def
generateNumber
(
self
):
from
Globals
import
G
number
=
0
...
...
@@ -54,7 +54,8 @@ class RandomNumberGenerator(object):
elif
self
.
distType
==
"Erlang"
:
#if the distribution is erlang
number
=
G
.
Rnd
.
gammavariate
(
self
.
alpha
,
self
.
beta
)
else
:
print
"unknown distribution error in "
+
str
(
self
.
object
.
type
)
+
str
(
self
.
object
.
id
)
raise
ValueError
(
"Unknown distribution %r used in %s %s"
%
(
self
.
distType
,
self
.
object
.
type
,
self
.
object
.
id
))
return
number
\ 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