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
957b9edd
Commit
957b9edd
authored
Aug 20, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BatchScrapMachine to read in the same fashion
parent
fc01c77b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
91 deletions
+72
-91
dream/simulation/BatchScrapMachine.py
dream/simulation/BatchScrapMachine.py
+40
-18
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+21
-70
dream/simulation/Machine.py
dream/simulation/Machine.py
+11
-3
No files found.
dream/simulation/BatchScrapMachine.py
View file @
957b9edd
...
...
@@ -43,28 +43,50 @@ class BatchScrapMachine(Machine):
# calls the Machine constructor, but also reads attributes for
# scraping distribution
# =======================================================================
def
__init__
(
self
,
id
,
name
,
capacity
=
1
,
\
def
__init__
(
self
,
id
=
''
,
name
=
''
,
capacity
=
1
,
\
processingTime
=
None
,
failureDistribution
=
'No'
,
MTTF
=
0
,
MTTR
=
0
,
availability
=
0
,
repairman
=
'None'
,
\
scrapDistribution
=
'Fixed'
,
scrMean
=
1
,
scrStdev
=
0
,
scrMin
=
0
,
scrMax
=
10
):
if
not
processingTime
:
processingTime
=
{
'distribution'
:
'Fixed'
,
'mean'
:
1
}
# initialize using the default method of the object
Machine
.
__init__
(
self
,
id
=
id
,
name
=
name
,
\
capacity
=
capacity
,
\
processingTime
=
processingTime
,
failureDistribution
=
failureDistribution
,
MTTF
=
MTTF
,
MTTR
=
MTTR
,
\
availability
=
availability
,
repairman
=
repairman
)
scrapDistribution
=
'Fixed'
,
scrMean
=
1
,
scrStdev
=
0
,
scrMin
=
0
,
scrMax
=
10
,
inputsDict
=
{}):
# if input is given in a dictionary
if
inputsDict
:
Machine
.
__init__
(
self
,
inputsDict
=
inputsDict
)
# else read the separate ones
else
:
if
not
processingTime
:
processingTime
=
{
'distribution'
:
'Fixed'
,
'mean'
:
1
}
# initialize using the default method of the object
Machine
.
__init__
(
self
,
id
=
id
,
name
=
name
,
\
capacity
=
capacity
,
\
processingTime
=
processingTime
,
failureDistribution
=
failureDistribution
,
MTTF
=
MTTF
,
MTTR
=
MTTR
,
\
availability
=
availability
,
repairman
=
repairman
)
self
.
scrapDistType
=
scrapDistribution
#the distribution that the failure follows
# set the attributes of the scrap quantity distribution
self
.
scrapRng
=
RandomNumberGenerator
(
self
,
self
.
scrapDistType
)
self
.
scrapRng
.
mean
=
scrMean
self
.
scrapRng
.
stdev
=
scrStdev
self
.
scrapRng
.
min
=
scrMin
self
.
scrapRng
.
max
=
scrMax
self
.
scrapDistType
=
scrapDistribution
#the distribution that the failure follows
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def
parseInputs
(
self
,
inputsDict
):
Machine
.
parseInputs
(
self
,
inputsDict
)
# set the attributes of the scrap quantity distribution
scrapQuantity
=
inputsDict
.
get
(
'scrapQuantity'
,
{})
self
.
scrapDistType
=
scrapQuantity
.
get
(
'distributionType'
,
'Fixed'
)
self
.
scrapRng
=
RandomNumberGenerator
(
self
,
self
.
scrapDistType
)
self
.
scrapRng
.
mean
=
scrMean
self
.
scrapRng
.
stdev
=
scrStdev
self
.
scrapRng
.
min
=
scrMin
self
.
scrapRng
.
max
=
scrMax
self
.
scrapRng
.
mean
=
float
(
scrapQuantity
.
get
(
'mean'
)
or
0
)
self
.
scrapRng
.
stdev
=
float
(
scrapQuantity
.
get
(
'stdev'
)
or
0
)
self
.
scrapRng
.
min
=
float
(
scrapQuantity
.
get
(
'min'
)
or
0
)
self
.
scrapRng
.
max
=
float
(
scrapQuantity
.
get
(
'max'
)
or
self
.
scrapRng
.
mean
+
5
*
self
.
scrapRng
.
stdev
)
from
Globals
import
G
G
.
BatchScrapMachineList
.
append
(
self
)
# =======================================================================
# removes an Entity from the Object the Entity to be removed is passed
...
...
@@ -74,7 +96,7 @@ class BatchScrapMachine(Machine):
# =======================================================================
def
removeEntity
(
self
,
entity
=
None
):
activeEntity
=
Machine
.
removeEntity
(
self
,
entity
)
scrapQuantity
=
self
.
scrapRng
.
generateNumber
()
scrapQuantity
=
self
.
scrapRng
.
generateNumber
()
activeEntity
.
numberOfUnits
-=
int
(
scrapQuantity
)
# the scrapQuantity should be integer at whatever case
if
activeEntity
.
numberOfUnits
<
0
:
activeEntity
.
numberOfUnits
==
0
...
...
dream/simulation/LineGenerationJSON.py
View file @
957b9edd
...
...
@@ -291,89 +291,40 @@ def createObjects():
G
.
SourceList
.
append
(
S
)
G
.
ObjList
.
append
(
S
)
elif
objClass
==
'Dream.Machine'
:
elif
objClass
in
[
'Dream.Machine'
]:
M
=
Machine
(
inputsDict
=
element
)
M
.
nextIds
=
getSuccessorList
(
element
[
'id'
])
# update the nextIDs list of the machine
elif
objClass
==
'Dream.BatchScrapMachine'
:
# id=element.get('id', 'not found')
# name=element.get('name', 'not found')
# processingTime=element.get('processingTime',{})
# canDeliverOnInterruption=bool(element.get('canDeliverOnInterruption') or 0)
# scrapQuantity=element.get('scrapQuantity', {})
# scrapDistributionType=scrapQuantity.get('distributionType', 'not found')
# scrMean=float(scrapQuantity.get('mean') or 0)
# scrStdev=float(scrapQuantity.get('stdev') or 0)
# scrMin=float(scrapQuantity.get('min') or 0)
# scrMax=float(scrapQuantity.get('max') or scrMean+5*scrStdev)
# 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=BatchScrapMachine(id, name, 1, processingTime, failureDistribution=failureDistribution,
# MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
# scrMean=scrMean,
# scrStdev=scrStdev,scrMin=scrMin,scrMax=scrMax)
# M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
# G.MachineList.append(M) # add machine to global MachineList
# G.BatchScrapMachineList.append(M)
# G.ObjList.append(M) # add machine to ObjList
M
=
BatchScrapMachine
(
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
G
.
ObjList
.
append
(
M
)
# add machine to ObjList
elif
objClass
==
'Dream.BatchScrapMachine'
:
id
=
element
.
get
(
'id'
,
'not found'
)
name
=
element
.
get
(
'name'
,
'not found'
)
processingTime
=
element
.
get
(
'processingTime'
,{})
scrapQuantity
=
element
.
get
(
'scrapQuantity'
,
{})
scrapDistributionType
=
scrapQuantity
.
get
(
'distributionType'
,
'not found'
)
scrMean
=
float
(
scrapQuantity
.
get
(
'mean'
)
or
0
)
scrStdev
=
float
(
scrapQuantity
.
get
(
'stdev'
)
or
0
)
scrMin
=
float
(
scrapQuantity
.
get
(
'min'
)
or
0
)
scrMax
=
float
(
scrapQuantity
.
get
(
'max'
)
or
scrMean
+
5
*
scrStdev
)
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
)
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
=
BatchScrapMachine
(
id
,
name
,
1
,
processingTime
,
failureDistribution
=
failureDistribution
,
MTTF
=
MTTF
,
MTTR
=
MTTR
,
availability
=
availability
,
repairman
=
r
,
scrMean
=
scrMean
,
scrStdev
=
scrStdev
,
scrMin
=
scrMin
,
scrMax
=
scrMax
)
M
.
nextIds
=
getSuccessorList
(
id
)
# update the nextIDs list of the machine
G
.
MachineList
.
append
(
M
)
# add machine to global MachineList
G
.
BatchScrapMachineList
.
append
(
M
)
G
.
ObjList
.
append
(
M
)
# add machine to ObjList
elif
objClass
==
'Dream.M3'
:
id
=
element
.
get
(
'id'
,
'not found'
)
...
...
dream/simulation/Machine.py
View file @
957b9edd
...
...
@@ -126,8 +126,10 @@ class Machine(CoreObject):
self
.
assignedOperator
=
True
# flag notifying the the station can deliver entities that ended their processing while interrupted
self
.
canDeliverOnInterruption
=
canDeliverOnInterruption
# =======================================================================
# parses inputs if they are given in a dictionary
# =======================================================================
def
parseInputs
(
self
,
inputsDict
):
from
Globals
import
G
id
=
inputsDict
.
get
(
'id'
)
...
...
@@ -221,7 +223,13 @@ class Machine(CoreObject):
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
G
.
MachineList
.
append
(
self
)
# add machine to global MachineList
if
self
.
operatorPool
!=
"None"
:
G
.
OperatedMachineList
.
append
(
self
)
# add the machine to the operatedMachines List
G
.
ObjList
.
append
(
self
)
# add machine to ObjList
# =======================================================================
# 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