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
fc01c77b
Commit
fc01c77b
authored
Aug 20, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Machine to be able to read inputs from dict
parent
73edfef0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
163 additions
and
65 deletions
+163
-65
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+48
-47
dream/simulation/Machine.py
dream/simulation/Machine.py
+115
-18
No files found.
dream/simulation/LineGenerationJSON.py
View file @
fc01c77b
...
...
@@ -292,53 +292,54 @@ def createObjects():
G
.
ObjList
.
append
(
S
)
elif
objClass
==
'Dream.Machine'
:
id
=
element
.
get
(
'id'
,
'not found'
)
name
=
element
.
get
(
'name'
,
'not found'
)
processingTime
=
element
.
get
(
'processingTime'
,{})
canDeliverOnInterruption
=
bool
(
element
.
get
(
'canDeliverOnInterruption'
)
or
0
)
failures
=
element
.
get
(
'failures'
,
{})
failureDistribution
=
failures
.
get
(
'failureDistribution'
,
'not found'
)
MTTF
=
float
(
failures
.
get
(
'MTTF'
)
or
0
)
MTTR
=
float
(
failures
.
get
(
'MTTR'
)
or
0
)
availability
=
float
(
failures
.
get
(
'availability'
)
or
0
)
# type of operation and related times
operationType
=
element
.
get
(
'operationType'
,
'not found'
)
setupTime
=
element
.
get
(
'setupTime'
,
None
)
loadTime
=
element
.
get
(
'loadTime'
,
None
)
preemption
=
element
.
get
(
'preemption'
,{})
isPreemptive
=
resetOnPreemption
=
False
if
len
(
preemption
)
>
0
:
isPreemptive
=
bool
(
int
(
preemption
.
get
(
'isPreemptive'
)
or
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
if
(
id
in
operatorPool
.
coreObjectIds
):
# and add it to the machine's operatorPool
machineOperatorPoolList
=
operatorPool
# there must only one operator pool assigned to the machine,
# otherwise only one of them will be taken into account
else
:
machineOperatorPoolList
=
[]
# if there is no operatorPool assigned to the machine
else
:
# then machineOperatorPoolList/operatorPool is a list
machineOperatorPoolList
=
[]
# if there are no operatorsPool created then the
# then machineOperatorPoolList/operatorPool is a list
if
(
type
(
machineOperatorPoolList
)
is
list
):
# if the machineOperatorPoolList is a list
# find the operators assigned to it and add them to the list
for
operator
in
G
.
OperatorsList
:
# check which operator in the G.OperatorsList
if
(
id
in
operator
.
coreObjectIds
):
# (if any) is assigned to operate
machineOperatorPoolList
.
append
(
operator
)
# the machine with ID equal to id
# if there is no operator assigned then the list will be empty
r
=
'None'
for
repairman
in
G
.
RepairmanList
:
# check which repairman in the G.RepairmanList
if
(
id
in
repairman
.
coreObjectIds
):
# (if any) is assigned to repair
r
=
repairman
# the machine with ID equal to id
M
=
Machine
(
id
,
name
,
1
,
processingTime
,
failureDistribution
=
failureDistribution
,
MTTF
=
MTTF
,
MTTR
=
MTTR
,
availability
=
availability
,
#repairman=r,
operatorPool
=
machineOperatorPoolList
,
operationType
=
operationType
,
setupTime
=
setupTime
,
loadTime
=
loadTime
,
repairman
=
r
,
isPreemptive
=
isPreemptive
,
resetOnPreemption
=
resetOnPreemption
,
canDeliverOnInterruption
=
canDeliverOnInterruption
)
M
.
nextIds
=
getSuccessorList
(
id
)
# update the nextIDs list of the machine
# id=element.get('id', 'not found')
# name=element.get('name', 'not found')
# processingTime=element.get('processingTime',{})
# canDeliverOnInterruption=bool(element.get('canDeliverOnInterruption') or 0)
# failures=element.get('failures', {})
# failureDistribution=failures.get('failureDistribution', 'not found')
# MTTF=float(failures.get('MTTF') or 0)
# MTTR=float(failures.get('MTTR') or 0)
# availability=float(failures.get('availability') or 0)
# # type of operation and related times
# operationType=element.get('operationType','not found')
# setupTime = element.get('setupTime', None)
# loadTime = element.get('loadTime', None)
# preemption=element.get('preemption',{})
# isPreemptive=resetOnPreemption=False
# if len(preemption)>0:
# isPreemptive=bool(int(preemption.get('isPreemptive') or 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
# if(id in operatorPool.coreObjectIds): # and add it to the machine's operatorPool
# machineOperatorPoolList=operatorPool # there must only one operator pool assigned to the machine,
# # otherwise only one of them will be taken into account
# else:
# machineOperatorPoolList=[] # if there is no operatorPool assigned to the machine
# else: # then machineOperatorPoolList/operatorPool is a list
# machineOperatorPoolList=[] # if there are no operatorsPool created then the
# # then machineOperatorPoolList/operatorPool is a list
# if (type(machineOperatorPoolList) is list): # if the machineOperatorPoolList is a list
# # find the operators assigned to it and add them to the list
# for operator in G.OperatorsList: # check which operator in the G.OperatorsList
# if(id in operator.coreObjectIds): # (if any) is assigned to operate
# machineOperatorPoolList.append(operator) # the machine with ID equal to id
# # if there is no operator assigned then the list will be empty
# r='None'
# for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
# if(id in repairman.coreObjectIds): # (if any) is assigned to repair
# r=repairman # the machine with ID equal to id
# M=Machine(id, name, 1, processingTime, failureDistribution=failureDistribution,
# MTTF=MTTF, MTTR=MTTR, availability=availability, #repairman=r,
# operatorPool=machineOperatorPoolList, operationType=operationType,
# setupTime=setupTime,
# loadTime=loadTime,
# repairman=r, isPreemptive=isPreemptive, resetOnPreemption=resetOnPreemption,
# canDeliverOnInterruption=canDeliverOnInterruption)
M
=
Machine
(
inputsDict
=
element
)
M
.
nextIds
=
getSuccessorList
(
element
[
'id'
])
# update the nextIDs list of the machine
G
.
MachineList
.
append
(
M
)
# add machine to global MachineList
if
M
.
operatorPool
!=
"None"
:
G
.
OperatedMachineList
.
append
(
M
)
# add the machine to the operatedMachines List
...
...
dream/simulation/Machine.py
View file @
fc01c77b
...
...
@@ -49,15 +49,17 @@ class Machine(CoreObject):
# =======================================================================
# initialise the id the capacity, of the resource and the distribution
# =======================================================================
def
__init__
(
self
,
id
,
name
,
capacity
=
1
,
processingTime
=
None
,
def
__init__
(
self
,
id
=
''
,
name
=
''
,
capacity
=
1
,
processingTime
=
None
,
failureDistribution
=
'No'
,
MTTF
=
0
,
MTTR
=
0
,
availability
=
0
,
repairman
=
'None'
,
\
operatorPool
=
'None'
,
operationType
=
'None'
,
\
setupTime
=
None
,
loadTime
=
None
,
isPreemptive
=
False
,
resetOnPreemption
=
False
,
canDeliverOnInterruption
=
False
):
CoreObject
.
__init__
(
self
,
id
,
name
)
canDeliverOnInterruption
=
False
,
inputsDict
=
{}):
self
.
type
=
"Machine"
#String that shows the type of object
if
inputsDict
:
self
.
parseInputs
(
inputsDict
)
else
:
CoreObject
.
__init__
(
self
,
id
,
name
)
if
not
processingTime
:
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
,
}
...
...
@@ -125,6 +127,101 @@ class Machine(CoreObject):
# flag notifying the the station can deliver entities that ended their processing while interrupted
self
.
canDeliverOnInterruption
=
canDeliverOnInterruption
def
parseInputs
(
self
,
inputsDict
):
from
Globals
import
G
id
=
inputsDict
.
get
(
'id'
)
name
=
inputsDict
.
get
(
'name'
)
processingTime
=
inputsDict
.
get
(
'processingTime'
,{})
CoreObject
.
__init__
(
self
,
id
,
name
)
if
not
processingTime
:
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
,
}
if
processingTime
[
'distributionType'
]
==
'Normal'
and
\
processingTime
.
get
(
'max'
,
None
)
is
None
:
processingTime
[
'max'
]
=
float
(
processingTime
[
'mean'
])
+
5
*
float
(
processingTime
[
'stdev'
])
setupTime
=
inputsDict
.
get
(
'setupTime'
,{})
if
not
setupTime
:
setupTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
,
}
if
setupTime
[
'distributionType'
]
==
'Normal'
and
\
setupTime
.
get
(
'max'
,
None
)
is
None
:
setupTime
[
'max'
]
=
float
(
setupTime
[
'mean'
])
+
5
*
float
(
setupTime
[
'stdev'
])
loadTime
=
inputsDict
.
get
(
'loadTime'
,{})
if
not
loadTime
:
loadTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
,
}
if
loadTime
[
'distributionType'
]
==
'Normal'
and
\
loadTime
.
get
(
'max'
,
None
)
is
None
:
loadTime
[
'max'
]
=
float
(
loadTime
[
'mean'
])
+
5
*
float
(
loadTime
[
'stdev'
])
# holds the capacity of the machine
self
.
capacity
=
inputsDict
.
get
(
'capacity'
,
1
)
# define the distribution types of the processing and failure times respectively
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
# check whether the operators are provided with a skills set
self
.
dedicatedOperator
=
self
.
checkForDedicatedOperators
()
if
len
(
G
.
OperatorPoolsList
)
>
0
:
for
operatorPool
in
G
.
OperatorPoolsList
:
# find the operatorPool assigned to the machine
if
(
id
in
operatorPool
.
coreObjectIds
):
# and add it to the machine's operatorPool
machineOperatorPoolList
=
operatorPool
# there must only one operator pool assigned to the machine,
# otherwise only one of them will be taken into account
else
:
machineOperatorPoolList
=
[]
# if there is no operatorPool assigned to the machine
else
:
# then machineOperatorPoolList/operatorPool is a list
machineOperatorPoolList
=
[]
# if there are no operatorsPool created then the
# then machineOperatorPoolList/operatorPool is a list
if
(
type
(
machineOperatorPoolList
)
is
list
):
# if the machineOperatorPoolList is a list
# find the operators assigned to it and add them to the list
for
operator
in
G
.
OperatorsList
:
# check which operator in the G.OperatorsList
if
(
id
in
operator
.
coreObjectIds
):
# (if any) is assigned to operate
machineOperatorPoolList
.
append
(
operator
)
# the machine with ID equal to id
self
.
operatorPool
=
machineOperatorPoolList
# create an operatorPool if needed
self
.
createOperatorPool
(
self
.
operatorPool
)
# holds the Operator currently processing the Machine
self
.
currentOperator
=
None
# define if load/setup/removal/processing are performed by the operator
self
.
operationType
=
inputsDict
.
get
(
'operationType'
,
'None'
)
# boolean to check whether the machine is being operated
self
.
toBeOperated
=
False
# define the load times
self
.
loadRng
=
RandomNumberGenerator
(
self
,
**
loadTime
)
# variable that informs on the need for setup
self
.
setUp
=
True
# define the setup times
self
.
stpRng
=
RandomNumberGenerator
(
self
,
**
setupTime
)
# examine if there are multiple operation types performed by the operator
# there can be Setup/Processing operationType
# or the combination of both (MT-Load-Setup-Processing)
self
.
multOperationTypeList
=
[]
if
self
.
operationType
.
startswith
(
"MT"
):
OTlist
=
self
.
operationType
.
split
(
'-'
)
self
.
operationType
=
OTlist
.
pop
(
0
)
self
.
multOperationTypeList
=
OTlist
else
:
self
.
multOperationTypeList
.
append
(
self
.
operationType
)
# flags used for preemption purposes
preemption
=
inputsDict
.
get
(
'preemption'
,{})
self
.
isPreemptive
=
False
self
.
resetOnPreemption
=
False
if
len
(
preemption
)
>
0
:
self
.
isPreemptive
=
bool
(
int
(
preemption
.
get
(
'isPreemptive'
)
or
0
))
self
.
resetOnPreemption
=
bool
(
int
(
preemption
.
get
(
'resetOnPreemption'
,
0
)))
# flag notifying that there is operator assigned to the actievObject
self
.
assignedOperator
=
True
# flag notifying the the station can deliver entities that ended their processing while interrupted
self
.
canDeliverOnInterruption
=
bool
(
inputsDict
.
get
(
'canDeliverOnInterruption'
)
or
0
)
self
.
repairman
=
'None'
for
repairman
in
G
.
RepairmanList
:
# check which repairman in the G.RepairmanList
if
(
self
.
id
in
repairman
.
coreObjectIds
):
# (if any) is assigned to repair
self
.
repairman
=
repairman
# the machine with ID equal to id
# =======================================================================
# initialize the machine
# =======================================================================
...
...
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