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
79508d88
Commit
79508d88
authored
Feb 04, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Feb 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MachinePreemptive code moved to Machine and MachineJobShop
parent
c9e1450a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
13 deletions
+75
-13
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+15
-2
dream/simulation/JSONInputs/Topology34.json
dream/simulation/JSONInputs/Topology34.json
+5
-3
dream/simulation/JSONInputs/Topology35.json
dream/simulation/JSONInputs/Topology35.json
+5
-3
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+12
-2
dream/simulation/Machine.py
dream/simulation/Machine.py
+5
-1
dream/simulation/MachineJobShop.py
dream/simulation/MachineJobShop.py
+33
-2
No files found.
dream/simulation/CoreObject.py
View file @
79508d88
...
...
@@ -44,6 +44,11 @@ class CoreObject(Process):
self
.
Working
=
[]
self
.
Blockage
=
[]
self
.
Waiting
=
[]
#default attributes set so that the CoreObject has them
self
.
isPreemptive
=
False
self
.
resetOnPreemption
=
False
def
initialize
(
self
):
...
...
@@ -178,8 +183,8 @@ class CoreObject(Process):
# perform preemption when required
# if the object is not Exit
if
activeObject
.
receiver
:
# if the obtained Entity is critical
if
activeEntity
.
isCritical
:
# if the obtained Entity is critical
and the receiver is preemptive
if
activeEntity
.
isCritical
and
activeObject
.
receiver
.
isPreemptive
:
#if the receiver is not empty
if
len
(
self
.
receiver
.
getActiveObjectQueue
())
>
0
:
#if the receiver does not hold an Entity that is also critical
...
...
@@ -376,3 +381,11 @@ class CoreObject(Process):
# =======================================================================
def
interruptionActions
(
self
):
pass
# =======================================================================
# method to execute preemption
# =======================================================================
def
preempt
(
self
):
#ToDO make a generic method
pass
dream/simulation/JSONInputs/Topology34.json
View file @
79508d88
...
...
@@ -20,15 +20,17 @@
"failures"
:
{}
},
"M2"
:
{
"_class"
:
"Dream.Machine
Preemptive
"
,
"_class"
:
"Dream.Machine
JobShop
"
,
"id"
:
"M2"
,
"name"
:
"Machine2"
,
"processingTime"
:
{
"distributionType"
:
"Fixed"
,
"mean"
:
"1.5"
},
"failures"
:
{},
"resetOnPreemption"
:
"0"
"preemption"
:
{
"isPreemptive"
:
"1"
,
"resetOnPreemption"
:
"0"
}
},
"Q1"
:
{
"_class"
:
"Dream.QueueJobShop"
,
...
...
dream/simulation/JSONInputs/Topology35.json
View file @
79508d88
...
...
@@ -20,15 +20,17 @@
"failures"
:
{}
},
"M2"
:
{
"_class"
:
"Dream.Machine
Preemptive
"
,
"_class"
:
"Dream.Machine
JobShop
"
,
"id"
:
"M2"
,
"name"
:
"Machine2"
,
"processingTime"
:
{
"distributionType"
:
"Fixed"
,
"mean"
:
"1.5"
},
"failures"
:
{},
"resetOnPreemption"
:
"1"
"preemption"
:
{
"isPreemptive"
:
"1"
,
"resetOnPreemption"
:
"1"
}
},
"Q1"
:
{
"_class"
:
"Dream.QueueJobShop"
,
...
...
dream/simulation/LineGenerationJSON.py
View file @
79508d88
...
...
@@ -286,6 +286,11 @@ def createObjects():
loadStdev
=
float
(
loadTime
.
get
(
'loadStdev'
,
'0'
))
loadMin
=
float
(
loadTime
.
get
(
'loadMin'
,
'0'
))
loadMax
=
float
(
loadTime
.
get
(
'loadMax'
,
'0'
))
preemption
=
element
.
get
(
'preemption'
,{})
isPreemptive
=
resetOnPreemption
=
False
if
len
(
preemption
)
>
0
:
isPreemptive
=
bool
(
int
(
preemption
.
get
(
'isPreemptive'
,
0
)))
resetOnPreemption
=
bool
(
int
(
preemption
.
get
(
'isPreemptive'
,
0
)))
if
len
(
G
.
OperatorPoolsList
)
>
0
:
for
operatorPool
in
G
.
OperatorPoolsList
:
# find the operatorPool assigned to the machine
...
...
@@ -314,7 +319,7 @@ def createObjects():
loadDistribution
=
loadDistribution
,
setupDistribution
=
setupDistribution
,
setupMean
=
setupMean
,
setupStdev
=
setupStdev
,
setupMin
=
setupMin
,
setupMax
=
setupMax
,
loadMean
=
loadMean
,
loadStdev
=
loadStdev
,
loadMin
=
loadMin
,
loadMax
=
loadMax
,
repairman
=
r
)
repairman
=
r
,
isPreemptive
=
isPreemptive
,
resetOnPreemption
=
resetOnPreemption
)
M
.
nextIds
=
getSuccessorList
(
id
)
# update the nextIDs list of the machine
G
.
MachineList
.
append
(
M
)
# add machine to global MachineList
if
M
.
operatorPool
!=
"None"
:
...
...
@@ -418,6 +423,11 @@ def createObjects():
loadStdev
=
float
(
loadTime
.
get
(
'loadStdev'
,
'0'
))
loadMin
=
float
(
loadTime
.
get
(
'loadMin'
,
'0'
))
loadMax
=
float
(
loadTime
.
get
(
'loadMax'
,
'0'
))
preemption
=
element
.
get
(
'preemption'
,{})
isPreemptive
=
resetOnPreemption
=
False
if
len
(
preemption
)
>
0
:
isPreemptive
=
bool
(
int
(
preemption
.
get
(
'isPreemptive'
,
0
)))
resetOnPreemption
=
bool
(
int
(
preemption
.
get
(
'resetOnPreemption'
,
0
)))
if
len
(
G
.
OperatorPoolsList
)
>
0
:
for
operatorPool
in
G
.
OperatorPoolsList
:
# find the operatorPool assigned to the machine
...
...
@@ -447,7 +457,7 @@ def createObjects():
loadDistribution
=
loadDistribution
,
setupDistribution
=
setupDistribution
,
setupMean
=
setupMean
,
setupStdev
=
setupStdev
,
setupMin
=
setupMin
,
setupMax
=
setupMax
,
loadMean
=
loadMean
,
loadStdev
=
loadStdev
,
loadMin
=
loadMin
,
loadMax
=
loadMax
,
repairman
=
r
)
repairman
=
r
,
isPreemptive
=
isPreemptive
,
resetOnPreemption
=
resetOnPreemption
)
M
.
nextIds
=
getSuccessorList
(
id
)
G
.
MachineJobShopList
.
append
(
M
)
G
.
MachineList
.
append
(
M
)
...
...
dream/simulation/Machine.py
View file @
79508d88
...
...
@@ -48,7 +48,8 @@ class Machine(CoreObject):
failureDistribution
=
'No'
,
MTTF
=
0
,
MTTR
=
0
,
availability
=
0
,
repairman
=
'None'
,
\
operatorPool
=
'None'
,
operationType
=
'None'
,
\
loadDistribution
=
"No"
,
loadMean
=
0
,
loadStdev
=
0
,
loadMin
=
0
,
loadMax
=
10
,
setupDistribution
=
"No"
,
setupMean
=
0
,
setupStdev
=
0
,
setupMin
=
0
,
setupMax
=
10
):
setupDistribution
=
"No"
,
setupMean
=
0
,
setupStdev
=
0
,
setupMin
=
0
,
setupMax
=
10
,
isPreemptive
=
False
,
resetOnPreemption
=
False
):
CoreObject
.
__init__
(
self
)
# hold the id, name, and type of the Machine instance
self
.
id
=
id
...
...
@@ -123,6 +124,9 @@ class Machine(CoreObject):
self
.
WaitingForLoadOperator
=
[]
self
.
Loading
=
[]
self
.
SettingUp
=
[]
self
.
isPreemptive
=
isPreemptive
self
.
resetOnPreemption
=
resetOnPreemption
# =======================================================================
# initialize the machine
...
...
dream/simulation/MachineJobShop.py
View file @
79508d88
...
...
@@ -26,7 +26,7 @@ extends the machine object so that it can act as a jobshop station. It reads the
'''
from
SimPy.Simulation
import
Process
,
Resource
from
SimPy.Simulation
import
activate
,
passivate
,
waituntil
,
now
,
hold
from
SimPy.Simulation
import
activate
,
passivate
,
waituntil
,
now
,
hold
,
reactivate
from
Machine
import
Machine
# ===========================================================================
...
...
@@ -136,6 +136,37 @@ class MachineJobShop(Machine):
and
activeObject
.
waitToDispose
\
and
activeObject
.
Up
\
and
(
thecaller
is
self
.
receiver
)
# =======================================================================
# method to execute preemption
# =======================================================================
def
preempt
(
self
):
activeObject
=
self
.
getActiveObject
()
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
#get the active Entity
#calculate the remaining processing time
#if it is reset then set it as the original processing time
if
self
.
resetOnPreemption
:
remainingProcessingTime
=
self
.
procTime
#else subtract the time that passed since the entity entered
#(may need also failure time if there was. TO BE MELIORATED)
else
:
remainingProcessingTime
=
self
.
procTime
-
(
now
()
-
self
.
timeLastEntityEntered
)
#update the remaining route of activeEntity
activeEntity
.
remainingRoute
.
insert
(
0
,
{
'stationIdsList'
:[
str
(
self
.
id
)],
\
'processingTime'
:
\
{
'distributionType'
:
'Fixed'
,
\
'mean'
:
str
(
remainingProcessingTime
)}})
# activeEntity.remainingRoute.insert(0, [self.id, remainingProcessingTime])
activeEntity
.
remainingRoute
.
insert
(
0
,
{
'stationIdsList'
:[
str
(
self
.
lastGiver
.
id
)],
\
'processingTime'
:
\
{
'distributionType'
:
'Fixed'
,
\
'mean'
:
'0'
}})
# activeEntity.remainingRoute.insert(0, [self.lastGiver.id, 0])
#set the receiver as the object where the active entity was preempted from
self
.
receiver
=
self
.
lastGiver
self
.
next
=
[
self
.
receiver
]
self
.
waitToDispose
=
True
#set that I have to dispose
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
reactivate
(
self
)
\ 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