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
ab2fca44
Commit
ab2fca44
authored
Feb 22, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove obsolete GUI folder now everything is plugin
parent
737a19f5
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
1512 deletions
+0
-1512
dream/simulation/GUI/ACO.py
dream/simulation/GUI/ACO.py
+0
-170
dream/simulation/GUI/Batches.py
dream/simulation/GUI/Batches.py
+0
-84
dream/simulation/GUI/CapacityProject.py
dream/simulation/GUI/CapacityProject.py
+0
-179
dream/simulation/GUI/Default.py
dream/simulation/GUI/Default.py
+0
-394
dream/simulation/GUI/DemandPlanning.py
dream/simulation/GUI/DemandPlanning.py
+0
-397
dream/simulation/GUI/PartJobShop.py
dream/simulation/GUI/PartJobShop.py
+0
-215
dream/simulation/GUI/Shifts.py
dream/simulation/GUI/Shifts.py
+0
-49
dream/simulation/GUI/__init__.py
dream/simulation/GUI/__init__.py
+0
-24
No files found.
dream/simulation/GUI/ACO.py
deleted
100644 → 0
View file @
737a19f5
from
copy
import
copy
import
json
import
time
import
random
import
operator
import
xmlrpclib
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
from
dream.simulation.Queue
import
Queue
from
dream.simulation.Globals
import
getClassFromName
class
Simulation
(
DefaultSimulation
):
def
getConfigurationDict
(
self
):
conf
=
DefaultSimulation
.
getConfigurationDict
(
self
)
conf
[
"Dream-Configuration"
][
"property_list"
].
append
(
{
"id"
:
"numberOfGenerations"
,
"type"
:
"number"
,
"name"
:
"Number of generations"
,
"_class"
:
"Dream.Property"
,
"_default"
:
10
}
)
conf
[
"Dream-Configuration"
][
"property_list"
].
append
(
{
"id"
:
"numberOfAntsPerGenerations"
,
"type"
:
"number"
,
"name"
:
"Number of ants per generation"
,
"_class"
:
"Dream.Property"
,
"_default"
:
20
}
)
conf
[
"Dream-Configuration"
][
"property_list"
].
append
(
{
"id"
:
"numberOfSolutions"
,
"type"
:
"number"
,
"name"
:
"Number of solutions"
,
"_class"
:
"Dream.Property"
,
"_default"
:
4
}
)
conf
[
"Dream-Configuration"
][
"property_list"
].
append
(
{
"id"
:
"distributorURL"
,
"type"
:
"string"
,
"name"
:
"Distributor URL"
,
"description"
:
"URL of an ERP5 Distributor, see "
"https://github.com/erp5/erp5/tree/dream_distributor"
,
"_class"
:
"Dream.Property"
,
"_default"
:
''
}
)
return
conf
def
_preprocess
(
self
,
data
):
"""Override in subclass to preprocess data.
"""
return
data
def
_calculateAntScore
(
self
,
ant
):
"""Calculate the score of this ant.
"""
totalDelay
=
0
#set the total delay to 0
jsonData
=
ant
[
'result'
]
#read the result as JSON
elementList
=
jsonData
[
'elementList'
]
#find the route of JSON
#loop through the elements
for
element
in
elementList
:
elementClass
=
element
[
'_class'
]
#get the class
#id the class is Job
if
elementClass
==
'Dream.Job'
:
results
=
element
[
'results'
]
delay
=
float
(
results
.
get
(
'delay'
,
"0"
))
# A negative delay would mean we are ahead of schedule. This
# should not be considered better than being on time.
totalDelay
+=
max
(
delay
,
0
)
return
totalDelay
def
run
(
self
,
data
):
data
=
self
.
_preprocess
(
data
)
distributor_url
=
data
[
'general'
][
'distributorURL'
]
distributor
=
None
if
distributor_url
:
distributor
=
xmlrpclib
.
Server
(
distributor_url
)
tested_ants
=
set
()
start
=
time
.
time
()
# start counting execution time
# the list of options collated into a dictionary for ease of referencing in
# ManPy
collated
=
dict
()
for
node_id
,
node
in
data
[
'nodes'
].
items
():
node_class
=
getClassFromName
(
node
[
'_class'
])
if
issubclass
(
node_class
,
Queue
):
collated
[
node_id
]
=
list
(
node_class
.
getSupportedSchedulingRules
())
max_results
=
data
[
'general'
][
'numberOfSolutions'
]
ants
=
[]
#list of ants for keeping track of their performance
# Number of times new ants are to be created, i.e. number of generations (a
# generation can have more than 1 ant)
for
i
in
range
(
data
[
"general"
][
"numberOfGenerations"
]):
scenario_list
=
[]
# for the distributor
# number of ants created per generation
for
j
in
range
(
data
[
"general"
][
"numberOfAntsPerGenerations"
]):
# an ant dictionary to contain rule to queue assignment information
ant
=
{}
# for each of the machines, rules are randomly picked from the
# options list
for
k
in
collated
.
keys
():
ant
[
k
]
=
random
.
choice
(
collated
[
k
])
# TODO: function to calculate ant id. Store ant id in ant dict
ant_key
=
repr
(
ant
)
# if the ant was not already tested, only then test it
if
ant_key
not
in
tested_ants
:
tested_ants
.
add
(
ant_key
)
# set scheduling rule on queues based on ant data
ant_data
=
copy
(
data
)
for
k
,
v
in
ant
.
items
():
ant_data
[
"nodes"
][
k
][
'schedulingRule'
]
=
v
ant
[
'key'
]
=
ant_key
ant
[
'input'
]
=
ant_data
scenario_list
.
append
(
ant
)
if
distributor
is
None
:
# synchronous
for
ant
in
scenario_list
:
ant
[
'result'
]
=
DefaultSimulation
.
runOneScenario
(
self
,
ant
[
'input'
])
else
:
# asynchronous
job_id
=
distributor
.
requestSimulationRun
(
[
json
.
dumps
(
x
)
for
x
in
scenario_list
])
print
"Job registered"
,
job_id
while
True
:
time
.
sleep
(
1.
)
result_list
=
distributor
.
getJobResult
(
job_id
)
# The distributor returns None when calculation is still ongoing,
# or the list of result in the same order.
if
result_list
is
not
None
:
print
"Job terminated"
break
for
ant
,
result
in
zip
(
scenario_list
,
result_list
):
ant
[
'result'
]
=
json
.
loads
(
result
)
for
ant
in
scenario_list
:
ant
[
'score'
]
=
self
.
_calculateAntScore
(
ant
)
ants
.
extend
(
scenario_list
)
# remove ants that outputs the same schedules
ants_without_duplicates
=
dict
()
for
ant
in
ants
:
ant_result
=
copy
(
ant
[
'result'
])
ant_result
[
'general'
].
pop
(
'totalExecutionTime'
,
None
)
ant_result
=
json
.
dumps
(
ant_result
,
sort_keys
=
True
)
ants_without_duplicates
[
ant_result
]
=
ant
# The ants in this generation are ranked based on their scores and the
# best (max_results) are selected
ants
=
sorted
(
ants_without_duplicates
.
values
(),
key
=
operator
.
itemgetter
(
'score'
))[:
max_results
]
for
l
in
ants
:
# update the options list to ensure that good performing queue-rule
# combinations have increased representation and good chance of
# being selected in the next generation
for
m
in
collated
.
keys
():
# e.g. if using EDD gave good performance for Q1, then another
# 'EDD' is added to Q1 so there is a higher chance that it is
# selected by the next ants.
collated
[
m
].
append
(
l
[
m
])
print
"ACO finished, execution time %0.2fs"
%
(
time
.
time
()
-
start
)
return
ants
dream/simulation/GUI/Batches.py
deleted
100644 → 0
View file @
737a19f5
import
copy
import
json
import
time
import
random
import
operator
from
dream.simulation.GUI.Shifts
import
Simulation
as
ShiftsSimulation
from
dream.simulation.GUI.Default
import
schema
class
Simulation
(
ShiftsSimulation
):
def
getConfigurationDict
(
self
):
conf
=
ShiftsSimulation
.
getConfigurationDict
(
self
)
conf
[
'Dream-LineClearance'
]
=
{
"_class"
:
"Dream.LineClearance"
,
"name"
:
"Clearance"
,
"short_id"
:
"C"
,
"property_list"
:
conf
[
'Dream-Queue'
][
'property_list'
]}
batch_source_entity
=
copy
.
deepcopy
(
schema
[
"entity"
])
batch_source_entity
[
'_default'
]
=
"Dream.Batch"
conf
[
'Dream-BatchSource'
]
=
{
"_class"
:
"Dream.BatchSource"
,
"name"
:
"Source"
,
"short_id"
:
"S"
,
"property_list"
:
[
schema
[
'interarrivalTime'
],
batch_source_entity
,
schema
[
'batchNumberOfUnits'
]]
}
zeroProcessingTime
=
copy
.
deepcopy
(
schema
[
'processingTime'
])
for
prop
in
zeroProcessingTime
[
'property_list'
]:
if
prop
[
'id'
]
==
'mean'
:
prop
[
'_default'
]
=
0.0
perUnitProcessingTime
=
copy
.
deepcopy
(
schema
[
'processingTime'
])
for
prop
in
perUnitProcessingTime
[
'property_list'
]:
if
prop
[
'id'
]
==
'mean'
:
prop
[
'description'
]
=
"Processing time per unit"
conf
[
'Dream-BatchDecompositionStartTime'
]
=
{
"_class"
:
"Dream.BatchDecompositionStartTime"
,
"name"
:
"Decomposition"
,
"short_id"
:
"D"
,
"property_list"
:
[
zeroProcessingTime
,
schema
[
'numberOfSubBatches'
]
]
}
conf
[
'Dream-BatchReassembly'
]
=
{
"_class"
:
"Dream.BatchReassembly"
,
"name"
:
"Reassembly"
,
"short_id"
:
"R"
,
"property_list"
:
[
zeroProcessingTime
,
schema
[
'numberOfSubBatches'
]
]
}
conf
[
'Dream-BatchScrapMachine'
]
=
{
"_class"
:
"Dream.BatchScrapMachine"
,
"name"
:
"Station"
,
"short_id"
:
"St"
,
"property_list"
:
[
perUnitProcessingTime
,
schema
[
'failures'
]
]
}
conf
[
'Dream-EventGenerator'
]
=
{
"_class"
:
"Dream.EventGenerator"
,
"name"
:
"Attainment"
,
"short_id"
:
"A"
,
"property_list"
:
[
schema
[
'start'
],
schema
[
'stop'
],
schema
[
'duration'
],
schema
[
'interval'
],
schema
[
'method'
],
schema
[
'argumentDict'
]]
}
conf
[
"Dream-Configuration"
][
"gui"
][
"exit_stat"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"debug_json"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"shift_spreadsheet"
]
=
1
# some more global properties
conf
[
"Dream-Configuration"
][
"property_list"
].
append
(
{
"id"
:
"throughputTarget"
,
"name"
:
"Daily Throughput Target"
,
"description"
:
"The daily throughput target in units."
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
10
})
# remove tools that does not make sense here
conf
.
pop
(
'Dream-Machine'
)
conf
.
pop
(
'Dream-Repairman'
)
conf
.
pop
(
'Dream-Source'
)
return
conf
dream/simulation/GUI/CapacityProject.py
deleted
100644 → 0
View file @
737a19f5
from
copy
import
copy
import
json
import
time
import
random
import
operator
from
datetime
import
datetime
from
collections
import
defaultdict
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
from
dream.simulation.GUI.Default
import
schema
class
Simulation
(
DefaultSimulation
):
def
getConfigurationDict
(
self
):
conf
=
DefaultSimulation
.
getConfigurationDict
(
self
)
conf
[
"Dream-AbstractCapacityStation"
]
=
{
"property_list"
:
[
{
"id"
:
"isAssembly"
,
"name"
:
"Is an assembly station ?"
,
"description"
:
"Is this station an assembly ? Yes: 1, No: 0"
,
"type"
:
"number"
,
"_class"
:
"Dream.Property"
,
"_default"
:
0
},
],
"_class"
:
'Dream.AbstractCapacityStation'
,
"name"
:
'Station'
,
"short_id"
:
"CS"
,
}
conf
[
"Dream-Configuration"
][
"gui"
][
"capacity_by_project_spreadsheet"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"capacity_by_station_spreadsheet"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"station_utilisation_graph"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"capacity_utilisation_graph"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"job_schedule_spreadsheet"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"job_gantt"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"queue_stat"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"exit_stat"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"debug_json"
]
=
1
# remove tools that does not make sense here
conf
.
pop
(
'Dream-Machine'
)
conf
.
pop
(
'Dream-Queue'
)
conf
.
pop
(
'Dream-Exit'
)
conf
.
pop
(
'Dream-Repairman'
)
conf
.
pop
(
'Dream-Source'
)
conf
.
pop
(
'Dream-EventGenerator'
)
return
conf
def
_preprocess
(
self
,
in_data
):
data
=
copy
(
DefaultSimulation
.
_preprocess
(
self
,
in_data
))
new_data
=
copy
(
data
)
# remove not needed spreadsheet not to polute json
new_data
.
pop
(
'shift_spreadsheet'
,
None
)
new_data
.
pop
(
'wip_part_spreadsheet'
,
None
)
# read the spreadsheets
# a mapping station id -> list of interval capacity
available_capacity_by_station
=
defaultdict
(
list
)
capacity_by_station_spreadsheet
=
data
.
pop
(
'capacity_by_station_spreadsheet'
)
station_id_list
=
copy
([
x
for
x
in
capacity_by_station_spreadsheet
[
0
][
1
:]
if
x
])
for
line
in
capacity_by_station_spreadsheet
[
1
:]:
for
station_id
,
capacity
in
zip
(
station_id_list
,
line
[
1
:]):
available_capacity_by_station
[
station_id
].
append
(
float
(
capacity
or
0
))
assert
set
(
station_id_list
)
==
set
(
data
[
'nodes'
].
keys
()),
"Check stations ids in capacity spreadsheet"
# a mapping project id -> mapping station_id -> required capacity
required_capacity_by_project
=
dict
()
for
project_id
,
station_sequence
,
requirement_sequence
\
in
data
[
'capacity_by_project_spreadsheet'
][
1
:]:
if
project_id
:
required_capacity_by_project
[
project_id
]
=
{}
for
idx
,
capacity_station
in
enumerate
(
station_sequence
.
split
(
'-'
)):
capacity_station
=
'%s_Station'
%
capacity_station
.
strip
()
required_capacity_by_project
[
project_id
][
capacity_station
]
=
\
float
(
requirement_sequence
.
split
(
'-'
)[
idx
])
# a mapping project id -> first station
first_station_by_project
=
dict
()
for
project_id
,
station_sequence
,
requirement_sequence
\
in
data
[
'capacity_by_project_spreadsheet'
][
1
:]:
if
station_sequence
:
first_station_by_project
[
project_id
]
=
station_sequence
.
split
(
'-'
)[
0
]
# implicitly add a Queue for wip
assert
'Qstart'
not
in
new_data
[
'nodes'
],
"reserved ID used"
wip
=
[]
for
project
,
capacityRequirementDict
in
\
required_capacity_by_project
.
items
():
wip
.
append
(
dict
(
_class
=
'Dream.CapacityProject'
,
id
=
project
,
name
=
project
,
capacityRequirementDict
=
capacityRequirementDict
))
new_data
[
'nodes'
][
'QStart'
]
=
dict
(
_class
=
'Dream.Queue'
,
id
=
'QStart'
,
name
=
'Start Queue'
,
capacity
=-
1
,
wip
=
wip
)
# implicitly add a capacity station controller
assert
'CSC'
not
in
new_data
[
'nodes'
],
"reserved ID used"
new_data
[
'nodes'
][
'CSC'
]
=
dict
(
_class
=
'Dream.CapacityStationController'
,
name
=
'CSC'
,
start
=
0
,
interval
=
1
,
)
# "expand" abstract stations
for
node_id
,
node_data
in
data
[
'nodes'
].
items
():
if
node_data
[
'_class'
]
==
'Dream.AbstractCapacityStation'
:
# remove the node
new_data
[
'nodes'
].
pop
(
node_id
)
# remove outbound edges, while keeping a reference to the next station
# to set nextCapacityStationBufferId on the exit
next_abstract_station
=
None
for
edge_id
,
(
source
,
dest
,
edge_dict
)
in
\
list
(
new_data
[
'edges'
].
items
()):
# list because we remove some elements in the loop
if
source
==
node_id
:
next_abstract_station
=
dest
del
new_data
[
'edges'
][
edge_id
]
wip
=
[]
# set as wip all projects that have to be processed in this station
# firts
for
project
,
requirement_dict
in
required_capacity_by_project
.
items
():
if
first_station_by_project
[
project
]
==
node_id
:
requirement
=
requirement_dict
[
'%s_Station'
%
node_id
]
name
=
'%s_%s_%s'
%
(
project
,
node_id
,
requirement
)
wip
.
append
(
dict
(
_class
=
'Dream.CapacityEntity'
,
id
=
name
,
name
=
name
,
capacityProjectId
=
project
,
requiredCapacity
=
requirement
))
new_data
[
'nodes'
][
"%s_Buffer"
%
node_id
]
=
dict
(
_class
=
'Dream.CapacityStationBuffer'
,
id
=
"%s_Buffer"
%
node_id
,
name
=
node_data
[
'name'
],
wip
=
wip
,
isAssembly
=
node_data
[
'isAssembly'
]
)
new_data
[
'nodes'
][
"%s_Station"
%
node_id
]
=
dict
(
_class
=
'Dream.CapacityStation'
,
id
=
"%s_Station"
%
node_id
,
name
=
node_data
[
'name'
],
intervalCapacity
=
available_capacity_by_station
[
node_id
],
)
exit
=
dict
(
_class
=
'Dream.CapacityStationExit'
,
id
=
"%s_Exit"
%
node_id
,
name
=
node_data
[
'name'
],)
# set nextCapacityStationBufferId
if
next_abstract_station
:
exit
[
'nextCapacityStationBufferId'
]
=
'%s_Buffer'
%
next_abstract_station
new_data
[
'nodes'
][
"%s_Exit"
%
node_id
]
=
exit
new_data
[
'edges'
][
'%s_1'
%
node_id
]
=
[
"%s_Buffer"
%
node_id
,
"%s_Station"
%
node_id
,
{}]
new_data
[
'edges'
][
'%s_2'
%
node_id
]
=
[
"%s_Station"
%
node_id
,
"%s_Exit"
%
node_id
,
{}]
return
new_data
dream/simulation/GUI/Default.py
deleted
100644 → 0
View file @
737a19f5
This diff is collapsed.
Click to expand it.
dream/simulation/GUI/DemandPlanning.py
deleted
100644 → 0
View file @
737a19f5
This diff is collapsed.
Click to expand it.
dream/simulation/GUI/PartJobShop.py
deleted
100644 → 0
View file @
737a19f5
from
copy
import
copy
import
json
import
time
import
random
import
operator
from
datetime
import
datetime
from
dream.simulation.GUI
import
ACO
from
dream.simulation.GUI.Default
import
schema
MACHINE_TYPE_SET
=
set
([
"Dream.MachineManagedJob"
,
"Dream.MouldAssembly"
])
class
Simulation
(
ACO
.
Simulation
):
def
getConfigurationDict
(
self
):
conf
=
ACO
.
Simulation
.
getConfigurationDict
(
self
)
conf
[
"Dream-MachineManagedJob"
]
=
{
"property_list"
:
[
schema
[
"operationType"
]
],
"_class"
:
'Dream.MachineManagedJob'
,
"name"
:
'Machine'
,
"short_id"
:
"M"
,
}
conf
[
"Dream-MouldAssembly"
]
=
{
"property_list"
:
[
schema
[
"operationType"
]
],
"_class"
:
'Dream.MouldAssembly'
,
"name"
:
'Assembly'
,
"short_id"
:
"MA"
,
}
conf
[
"Dream-QueueManagedJob"
]
=
{
"property_list"
:
[
schema
[
"capacity"
],
schema
[
"schedulingRule"
]
],
"_class"
:
'Dream.QueueManagedJob'
,
"name"
:
'Queue'
,
"short_id"
:
"Q"
,
}
conf
[
"Dream-ConditionalBuffer"
]
=
{
"property_list"
:
[
schema
[
"capacity"
],
schema
[
"schedulingRule"
]
],
"_class"
:
'Dream.ConditionalBuffer'
,
"name"
:
'Cam Queue'
,
"short_id"
:
"B"
,
}
conf
[
"Dream-MouldAssemblyBuffer"
]
=
{
"property_list"
:
[
schema
[
"capacity"
],
schema
[
"schedulingRule"
]
],
"name"
:
'Assembly Queue'
,
"short_id"
:
"MA"
,
}
conf
[
"Dream-ExitJobShop"
]
=
{
"_class"
:
'Dream.ExitJobShop'
,
"name"
:
'Exit'
,
"short_id"
:
"E"
,
}
conf
[
"Dream-OperatorManagedJob"
]
=
{
"_class"
:
'Dream.OperatorManagedJob'
,
"name"
:
'Operator'
,
"short_id"
:
"PM"
,
}
conf
[
"Dream-OrderDecomposition"
]
=
{
"_class"
:
'Dream.OrderDecomposition'
,
"name"
:
'Decomposition'
,
"short_id"
:
"D"
,
}
conf
[
"Dream-Configuration"
][
"gui"
][
"wip_part_spreadsheet"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"job_schedule_spreadsheet"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"job_gantt"
]
=
1
conf
[
"Dream-Configuration"
][
"gui"
][
"queue_stat"
]
=
0
conf
[
"Dream-Configuration"
][
"gui"
][
"debug_json"
]
=
1
# remove tools that does not make sense here
conf
.
pop
(
'Dream-Machine'
)
conf
.
pop
(
'Dream-Queue'
)
conf
.
pop
(
'Dream-Exit'
)
conf
.
pop
(
'Dream-Repairman'
)
conf
.
pop
(
'Dream-Source'
)
conf
.
pop
(
'Dream-EventGenerator'
)
return
conf
def
getMachineNameSet
(
self
,
step_name
):
"""
Give list of machines given a particular step name. For example
if step_name is "CAM", it will return ["CAM1", "CAM2"]
"""
machine_name_set
=
set
()
for
machine_name
in
self
.
data
[
"nodes"
].
keys
():
if
machine_name
.
startswith
(
step_name
):
machine_name_set
.
add
(
machine_name
)
return
machine_name_set
def
getNotMachineNodePredecessorList
(
self
,
step_name
):
"""
Give the list of all predecessors that are not of type machine
For example, for step_name "CAM", it may return "QCAM"
"""
predecessor_list
=
[]
machine_name_set
=
self
.
getMachineNameSet
(
step_name
)
for
edge
in
self
.
data
[
"edges"
].
values
():
if
edge
[
1
]
in
machine_name_set
:
predecessor_step
=
edge
[
0
]
if
predecessor_step
in
predecessor_list
:
continue
if
not
self
.
data
[
"nodes"
][
predecessor_step
][
"_class"
]
in
MACHINE_TYPE_SET
:
predecessor_list
=
[
predecessor_step
]
+
predecessor_list
predecessor_list
=
[
x
for
x
in
self
.
getNotMachineNodePredecessorList
(
predecessor_step
)
\
if
x
not
in
predecessor_list
]
+
predecessor_list
return
predecessor_list
def
getRouteList
(
self
,
sequence_list
,
processing_time_list
,
prerequisite_list
):
# use to record which predecessor has been already done, used to avoid doing
# two times Decomposition
predecessor_set
=
set
()
route_list
=
[]
for
j
,
sequence_step
in
enumerate
(
sequence_list
):
for
predecessor_step
in
self
.
getNotMachineNodePredecessorList
(
sequence_step
):
# We avoid having two time Decomposition in the route. XXX Is this correct ?
if
predecessor_step
==
"Decomposition"
and
predecessor_step
in
predecessor_set
:
continue
predecessor_set
.
add
(
predecessor_step
)
route
=
{
"stationIdsList"
:
[
predecessor_step
],
}
route_list
.
append
(
route
)
route
=
{
"stationIdsList"
:
list
(
self
.
getMachineNameSet
(
sequence_step
)),
"processingTime"
:
{
"distributionType"
:
"Fixed"
,
"mean"
:
float
(
processing_time_list
[
j
])},
"setupTime"
:
{
"distributionType"
:
"Fixed"
,
"mean"
:
.
5
},
# XXX hardcoded value
}
if
prerequisite_list
:
route
[
"prerequisites"
]
=
prerequisite_list
route_list
.
append
(
route
)
return
route_list
def
getListFromString
(
self
,
my_string
):
my_list
=
[]
if
not
my_string
in
(
None
,
''
):
my_list
=
my_string
.
split
(
'-'
)
return
my_list
def
_preprocess
(
self
,
in_data
):
""" Set the WIP in queue from spreadsheet data.
"""
data
=
copy
(
ACO
.
Simulation
.
_preprocess
(
self
,
in_data
))
self
.
data
=
data
now
=
datetime
.
now
()
if
data
[
'general'
][
'currentDate'
]:
now
=
datetime
.
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
if
'wip_part_spreadsheet'
in
data
:
wip_list
=
[]
i
=
0
wip_part_spreadsheet_length
=
len
(
data
[
'wip_part_spreadsheet'
])
while
i
<
wip_part_spreadsheet_length
:
value_list
=
data
[
'wip_part_spreadsheet'
][
i
]
if
value_list
[
0
]
==
'Order ID'
or
not
value_list
[
4
]:
i
+=
1
continue
order_dict
=
{}
wip_list
.
append
(
order_dict
)
order_id
,
due_date
,
priority
,
project_manager
,
part
,
part_type
,
\
sequence_list
,
processing_time_list
,
prerequisite_string
=
value_list
due_date
=
(
datetime
.
strptime
(
due_date
,
'%Y/%m/%d'
)
-
now
).
days
*
24
prerequisite_list
=
self
.
getListFromString
(
prerequisite_string
)
sequence_list
=
sequence_list
.
split
(
'-'
)
processing_time_list
=
processing_time_list
.
split
(
'-'
)
order_dict
[
"_class"
]
=
"Dream.Order"
order_dict
[
"id"
]
=
"%i"
%
i
# XXX hack, we use it in UI to retrieve spreadsheet line
order_dict
[
"manager"
]
=
project_manager
order_dict
[
"name"
]
=
order_id
order_dict
[
"dueDate"
]
=
due_date
order_dict
[
"priority"
]
=
float
(
priority
)
# XXX make it dynamic by writing a function that will reuse the
# code available a bit after
order_dict
[
"route"
]
=
self
.
getRouteList
(
sequence_list
,
processing_time_list
,
prerequisite_list
)
i
+=
1
component_list
=
[]
if
i
<
wip_part_spreadsheet_length
:
while
data
[
'wip_part_spreadsheet'
][
i
][
0
]
in
(
None
,
''
):
value_list
=
data
[
'wip_part_spreadsheet'
][
i
]
if
value_list
[
4
]
in
(
None
,
''
):
break
order_id
,
due_date
,
priority
,
project_manager
,
part
,
part_type
,
\
sequence_list
,
processing_time_list
,
prerequisite_string
=
value_list
sequence_list
=
sequence_list
.
split
(
'-'
)
prerequisite_list
=
self
.
getListFromString
(
prerequisite_string
)
processing_time_list
=
processing_time_list
.
split
(
'-'
)
component_dict
=
{}
component_dict
[
"_class"
]
=
"Dream.OrderComponent"
if
part_type
==
"Mould"
:
component_dict
[
"_class"
]
=
"Dream.Mould"
component_dict
[
"componentType"
]
=
part_type
component_dict
[
"id"
]
=
"%i"
%
i
# XXX hack, we use it in UI to retrieve spreadsheet line
component_dict
[
"name"
]
=
part
component_list
.
append
(
component_dict
)
route_list
=
self
.
getRouteList
(
sequence_list
,
processing_time_list
,
prerequisite_list
)
if
part_type
==
"Mould"
:
route_list
=
route_list
[
1
:]
component_dict
[
"route"
]
=
route_list
i
+=
1
order_dict
[
"componentsList"
]
=
component_list
data
[
"nodes"
][
"QStart"
][
"wip"
]
=
wip_list
return
data
dream/simulation/GUI/Shifts.py
deleted
100644 → 0
View file @
737a19f5
from
copy
import
copy
import
json
import
time
import
random
import
operator
import
datetime
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
import
logging
logger
=
logging
.
getLogger
(
'dream.platform'
)
class
Simulation
(
DefaultSimulation
):
def
_preprocess
(
self
,
data
):
"""Preprocess data, reading shift spreadsheet
"""
data
=
DefaultSimulation
.
_preprocess
(
self
,
data
)
strptime
=
datetime
.
datetime
.
strptime
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
shift_by_station
=
{}
for
line
in
data
[
'shift_spreadsheet'
][
1
:]:
if
line
[
1
]:
# Get the dates, and convert them to simulation clock time units.
# In this class, time unit is a minute (XXX it can be an option)
start_date
=
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
2
]),
'%Y/%m/%d %H:%M'
)
start_time
=
(
start_date
-
now
).
total_seconds
()
//
60
stop_date
=
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
3
]),
'%Y/%m/%d %H:%M'
)
stop_time
=
(
stop_date
-
now
).
total_seconds
()
//
60
for
station
in
line
[
1
].
split
(
','
):
station
=
station
.
strip
()
shift_by_station
.
setdefault
(
station
,
[]).
append
(
(
start_time
,
stop_time
)
)
for
node
,
node_data
in
data
[
'nodes'
].
items
():
if
node
in
shift_by_station
:
node_data
[
'shift'
]
=
{
'shiftPattern'
:
shift_by_station
.
pop
(
node
),
'endUnfinished'
:
0
}
# XXX shall we make this
# configurable ?
assert
not
shift_by_station
,
\
"Some stations only exist in shift but not in graph: %r"
\
%
shift_by_station
.
keys
()
# from pprint import pformat
# logger.info(pformat(data))
return
data
dream/simulation/GUI/__init__.py
deleted
100644 → 0
View file @
737a19f5
# ===========================================================================
# 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/>.
# ===========================================================================
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try
:
__import__
(
'pkg_resources'
).
declare_namespace
(
__name__
)
except
ImportError
:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
\ 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