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
a2cce60f
Commit
a2cce60f
authored
Oct 21, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BatchReassembly can output results
parent
c7ca01c8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
dream/simulation/BatchReassembly.py
dream/simulation/BatchReassembly.py
+35
-2
No files found.
dream/simulation/BatchReassembly.py
View file @
a2cce60f
...
@@ -41,10 +41,11 @@ from Batch import Batch
...
@@ -41,10 +41,11 @@ from Batch import Batch
# the Batch-Reassembly Object
# the Batch-Reassembly Object
# ===========================================================================
# ===========================================================================
class
BatchReassembly
(
CoreObject
):
class
BatchReassembly
(
CoreObject
):
family
=
'Server'
# =======================================================================
# =======================================================================
#initialize the id, the capacity of the object and the distribution
#initialize the id, the capacity of the object and the distribution
# =======================================================================
# =======================================================================
def
__init__
(
self
,
id
,
name
,
numberOfSubBatches
=
1
,
processingTime
=
None
,
operator
=
'None'
,
**
kw
):
def
__init__
(
self
,
id
,
name
,
numberOfSubBatches
=
1
,
processingTime
=
None
,
operator
=
'None'
,
outputResults
=
False
,
**
kw
):
CoreObject
.
__init__
(
self
,
id
,
name
)
CoreObject
.
__init__
(
self
,
id
,
name
)
self
.
type
=
"BatchRassembly"
#String that shows the type of object
self
.
type
=
"BatchRassembly"
#String that shows the type of object
if
not
processingTime
:
if
not
processingTime
:
...
@@ -62,6 +63,8 @@ class BatchReassembly(CoreObject):
...
@@ -62,6 +63,8 @@ class BatchReassembly(CoreObject):
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
from
Globals
import
G
from
Globals
import
G
G
.
BatchReassemblyList
.
append
(
self
)
G
.
BatchReassemblyList
.
append
(
self
)
# flag to show if the objects outputs results
self
.
outputResults
=
bool
(
int
(
outputResults
))
# =======================================================================
# =======================================================================
# initialize the internal resource of the object
# initialize the internal resource of the object
...
@@ -130,7 +133,7 @@ class BatchReassembly(CoreObject):
...
@@ -130,7 +133,7 @@ class BatchReassembly(CoreObject):
self
.
reassemble
()
self
.
reassemble
()
self
.
isProcessingInitialWIP
=
False
self
.
isProcessingInitialWIP
=
False
# signal the receiver that the activeObject has something to dispose of
# signal the receiver that the activeObject has something to dispose of
self
.
timeLastBlockageStarted
=
self
.
env
.
now
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
# if there was no available receiver, get into blocking control
# if there was no available receiver, get into blocking control
while
1
:
while
1
:
...
@@ -329,3 +332,33 @@ class BatchReassembly(CoreObject):
...
@@ -329,3 +332,33 @@ class BatchReassembly(CoreObject):
and
activeObjectQueue
[
0
].
type
!=
'Batch'
\
and
activeObjectQueue
[
0
].
type
!=
'Batch'
\
and
giverObjectQueue
[
0
].
batchId
==
activeObjectQueue
[
0
].
batchId
and
giverObjectQueue
[
0
].
batchId
==
activeObjectQueue
[
0
].
batchId
# =======================================================================
# outputs results to JSON File
# =======================================================================
def
outputResultsJSON
(
self
):
if
self
.
outputResults
:
from
Globals
import
G
from
Globals
import
getConfidenceIntervals
json
=
{
'_class'
:
'Dream.%s'
%
self
.
__class__
.
__name__
,
'id'
:
self
.
id
,
'family'
:
self
.
family
,
'results'
:
{}}
if
(
G
.
numberOfReplications
==
1
):
# if we had just one replication output the results as numbers
json
[
'results'
][
'failure_ratio'
]
=
100
*
self
.
totalFailureTime
/
G
.
maxSimTime
json
[
'results'
][
'working_ratio'
]
=
100
*
self
.
totalWorkingTime
/
G
.
maxSimTime
json
[
'results'
][
'blockage_ratio'
]
=
100
*
self
.
totalBlockageTime
/
G
.
maxSimTime
json
[
'results'
][
'waiting_ratio'
]
=
100
*
self
.
totalWaitingTime
/
G
.
maxSimTime
#output the off-shift time only if there is any
if
self
.
totalOffShiftTime
:
json
[
'results'
][
'off_shift_ratio'
]
=
100
*
self
.
totalOffShiftTime
/
G
.
maxSimTime
else
:
json
[
'results'
][
'failure_ratio'
]
=
getConfidenceIntervals
(
self
.
Failure
)
json
[
'results'
][
'working_ratio'
]
=
getConfidenceIntervals
(
self
.
Working
)
json
[
'results'
][
'blockage_ratio'
]
=
getConfidenceIntervals
(
self
.
Blockage
)
json
[
'results'
][
'waiting_ratio'
]
=
getConfidenceIntervals
(
self
.
Waiting
)
json
[
'results'
][
'off_shift_ratio'
]
=
getConfidenceIntervals
(
self
.
OffShift
)
G
.
outputJSON
[
'elementList'
].
append
(
json
)
\ 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