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
ac80de3e
Commit
ac80de3e
authored
Aug 29, 2014
by
Ioannis Papagiannopoulos
Committed by
Georgios Dagkakis
Oct 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new ConditionalBuffer that complies with the requirements of the required parts
parent
46971633
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
0 deletions
+136
-0
dream/simulation/ConditionalBuffer.py
dream/simulation/ConditionalBuffer.py
+136
-0
No files found.
dream/simulation/ConditionalBuffer.py
0 → 100644
View file @
ac80de3e
# ===========================================================================
# 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 26 Aug 2014
@author: Ioannis
'''
'''
Inherits from QueueJobShop. Checks the condition of (a) order component(s) before it can dispose them/it
'''
from
QueueJobShop
import
QueueJobShop
# ===========================================================================
# Error in the setting up of the WIP
# ===========================================================================
class
NoCallerError
(
Exception
):
def
__init__
(
self
,
callerError
):
Exception
.
__init__
(
self
,
callerError
)
# ===========================================================================
# the ConditionalBuffer object
# ===========================================================================
class
ConditionalBuffer
(
QueueJobShop
):
# =======================================================================
# the default __init__ method of the QueueManagedJob class
# whereas the default capacity is set to infinity
# =======================================================================
def
__init__
(
self
,
id
,
name
,
capacity
=-
1
,
isDummy
=
False
,
schedulingRule
=
"FIFO"
,
**
kw
):
QueueJobShop
.
__init__
(
self
,
id
=
id
,
name
=
name
,
capacity
=
capacity
,
isDummy
=
isDummy
,
schedulingRule
=
schedulingRule
)
#===========================================================================
# getEntity method
# ass soon as the buffer receives an entity it controls if the entity is requested elsewhere,
# then it checks if there other requested entities by the same requesting entity.
# Finally, it is controlled whether all the requested parts have concluded
# their sequences for the requesting entity
#===========================================================================
def
getEntity
(
self
):
activeEntity
=
QueueJobShop
.
getEntity
(
self
)
import
Globals
# for all the entities in the EntityList
for
entity
in
G
.
EntityList
:
requiredParts
=
entity
.
getRequiredParts
()
if
requiredParts
:
# if the activeEntity is in the requierdParts of the entity
if
activeEntity
in
requiredParts
:
# if the entity is blocked
if
not
entity
.
checkIfRequiredPartsReady
():
# concluded flag to signal that the required parts have concluded their sequence
allConcluded
=
False
# figure out if the all required parts have concluded their sequences
for
part
in
requiredParts
:
# if the requiredParts have concluded its sequence then the flag must be set to True
# 1. the requiredPart hasn't reached the last step sequence before the requiring entity's sequence
# 2. The requiredPart has reached the last step sequence but not yet finished its current processing
if
(
part
.
nextStepSequence
()
<
entity
.
nextStepSequence
()
\
and
part
.
nextStepSequence
()
>
0
)
\
or
(
part
.
nextStepSequence
()
>=
entity
.
currentStepSequence
()
\
and
part
.
currentStepSequence
()
):
allConcluded
=
False
break
# if all the requiredParts completed the required sequence
if
allConcluded
:
# signal the current station of the blocked entity requesting the parts that it can proceed
# with delivering the blocked entity
entity
.
currentStation
.
canDispose
.
succeed
(
self
.
env
.
now
)
break
return
activeEntity
# =======================================================================
# checks if the Buffer can dispose an entity.
# Returns True only to the potential receiver
# If it holds components with requiredParts, checks first if the requiredParts
# have concluded their route steps with sequence smaller than the sequence
# of the activeEntity's next step
# =======================================================================
def
haveToDispose
(
self
,
callerObject
=
None
):
# get active object and its queue
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
# and then perform the default behaviour
if
QueueJobShop
.
haveToDispose
(
self
,
callerObject
):
# sort the activeObjectQueue to brink the entities that can proceed to front
activeObject
.
sortEntities
()
# return True if the first object of the queue can proceed
return
activeObjectQueue
[
0
].
mayProceed
return
False
# =======================================================================
# sort the entities of the activeQ
# bring to the front the entities that have no requestedParts for the following step in their route
# or their requestedParts have concluded the step with sequence no bigger than the sequence of their next step
# =======================================================================
def
sortEntities
(
self
):
activeObject
=
self
.
getActiveObject
()
# (run the default behaviour - loan from Queue)
# if we have sorting according to multiple criteria we have to call the sorter many times
if
self
.
schedulingRule
==
"MC"
:
for
criterion
in
reversed
(
self
.
multipleCriterionList
):
self
.
activeQSorter
(
criterion
=
criterion
)
#else we just use the default scheduling rule
else
:
self
.
activeQSorter
()
# and in the end sort according to the ConditionalBuffer sorting rule
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
# for every entity in the activeObjectQueue
for
entity
in
activeObjectQueue
:
# check if the requiredParts (if any) have concluded the steps with sequence smaller
# than the sequence of the entity next step
entity
.
mayProceed
=
entity
.
checkIfRequiredPartsReady
()
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
mayProceed
,
reverse
=
True
)
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