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
ea65fe98
Commit
ea65fe98
authored
Oct 16, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progression to new LP
parent
08f6c5f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
100 deletions
+116
-100
dream/simulation/SkilledOperatorRouter.py
dream/simulation/SkilledOperatorRouter.py
+1
-1
dream/simulation/opAss_LPmethod.py
dream/simulation/opAss_LPmethod.py
+115
-99
No files found.
dream/simulation/SkilledOperatorRouter.py
View file @
ea65fe98
...
@@ -173,7 +173,7 @@ class SkilledRouter(Router):
...
@@ -173,7 +173,7 @@ class SkilledRouter(Router):
#===================================================================
#===================================================================
self
.
availableStationsDict
=
{}
self
.
availableStationsDict
=
{}
for
station
in
self
.
availableStations
:
for
station
in
self
.
availableStations
:
self
.
availableStationsDict
[
str
(
station
.
id
)]
=
{
'stationID'
:
str
(
station
.
id
),
'WIP'
:
station
.
wip
}
self
.
availableStationsDict
[
str
(
station
.
id
)]
=
{
'stationID'
:
str
(
station
.
id
),
'WIP'
:
station
.
wip
,
'lastAssignment'
:
self
.
env
.
now
}
#===================================================================
#===================================================================
# # operators and their skills set
# # operators and their skills set
#===================================================================
#===================================================================
...
...
dream/simulation/opAss_LPmethod.py
View file @
ea65fe98
...
@@ -4,7 +4,7 @@ Created on 2 Jul 2014
...
@@ -4,7 +4,7 @@ Created on 2 Jul 2014
@author: Anna
@author: Anna
'''
'''
def
opAss_LP
(
machineList
,
PBlist
,
PBskills
,
previousAssignment
=
{}):
def
opAss_LP
(
machineList
,
PBlist
,
PBskills
,
previousAssignment
=
{}
,
weightFactors
=
[
2
,
1
,
0.5
,
2
,
1
,
1
],
Tool
=
{}
):
from
pulp
import
LpProblem
,
LpMaximize
,
LpVariable
,
LpBinary
,
lpSum
,
LpStatus
from
pulp
import
LpProblem
,
LpMaximize
,
LpVariable
,
LpBinary
,
lpSum
,
LpStatus
import
pulp
import
pulp
...
@@ -14,25 +14,27 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -14,25 +14,27 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
machines
=
machineList
.
keys
()
machines
=
machineList
.
keys
()
sumWIP
=
float
(
sum
([
machineList
[
mach
][
'WIP'
]
for
mach
in
machines
]))
sumWIP
=
float
(
sum
([
machineList
[
mach
][
'WIP'
]
for
mach
in
machines
]))
weightFactors
=
[
2
,
1
,
0.5
,
1.5
]
# define LP problem
# define LP problem
prob
=
LpProblem
(
"PBassignment"
,
LpMaximize
)
prob
=
LpProblem
(
"PBassignment"
,
LpMaximize
)
obj
=
[]
# declare variables...binary assignment variables (operator i to machine j)
# declare variables...binary assignment variables (operator i to machine j)
PB_ass
=
LpVariable
.
dicts
(
'PB'
,
[(
oper
,
mach
)
for
oper
in
PBlist
for
mach
in
machines
if
machineList
[
mach
][
'stationID'
]
in
PBskills
[
oper
]]
,
0
,
1
,
cat
=
pulp
.
LpBinary
)
PB_ass
=
LpVariable
.
dicts
(
'PB'
,
[(
oper
,
mach
)
for
oper
in
PBlist
for
mach
in
machines
if
machineList
[
mach
][
'stationID'
]
in
PBskills
[
oper
]]
,
0
,
1
,
cat
=
pulp
.
LpBinary
)
# objective...assignment of PBs to stations with higher WIP...sum of WIP associated with stations where PB is assigned
# objective...assignment of PBs to stations with higher WIP...sum of WIP associated with stations where PB is assigned
obj
=
[
machineList
[
mach
][
'WIP'
]
*
PB_ass
[(
oper
,
mach
)]
*
weightFactors
[
0
]
/
float
(
sumWIP
)
for
oper
in
PBlist
for
mach
in
machines
if
machineList
[
mach
][
'stationID'
]
in
PBskills
[
oper
]]
if
weightFactors
[
0
]
>
0
and
sumWIP
>
0
:
obj
.
append
([
machineList
[
mach
][
'WIP'
]
*
PB_ass
[(
oper
,
mach
)]
*
weightFactors
[
0
]
/
float
(
sumWIP
)
for
oper
in
PBlist
for
mach
in
machines
if
machineList
[
mach
][
'stationID'
]
in
PBskills
[
oper
]])
# second set of variables (delta assignment between stations) to facilitate the distribution of PBs across different stations
# second set of variables (delta assignment between stations) to facilitate the distribution of PBs across different stations
if
weightFactors
[
1
]
>
0
:
stationGroup
=
{}
stationGroup
=
{}
for
mach
in
machines
:
for
mach
in
machines
:
if
machineList
[
mach
][
'stationID'
]
not
in
stationGroup
:
if
machineList
[
mach
][
'stationID'
]
not
in
stationGroup
:
stationGroup
[
machineList
[
mach
][
'stationID'
]]
=
[]
stationGroup
[
machineList
[
mach
][
'stationID'
]]
=
[]
stationGroup
[
machineList
[
mach
][
'stationID'
]].
append
(
mach
)
stationGroup
[
machineList
[
mach
][
'stationID'
]].
append
(
mach
)
Delta_Station
=
LpVariable
.
dicts
(
"D_station"
,[(
st1
,
st2
)
for
i1
,
st1
in
enumerate
(
stationGroup
.
keys
())
for
st2
in
stationGroup
.
keys
()[
i1
+
1
:]])
Delta_Station
=
LpVariable
.
dicts
(
"D_station"
,
[(
st1
,
st2
)
for
i1
,
st1
in
enumerate
(
stationGroup
.
keys
())
for
st2
in
stationGroup
.
keys
()[
i1
+
1
:]])
# calculate global max number of machines within a station that will be used as dividers for Delta_Station
# calculate global max number of machines within a station that will be used as dividers for Delta_Station
maxNoMachines
=
0
maxNoMachines
=
0
...
@@ -68,6 +70,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -68,6 +70,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
obj
.
append
(
Delta_Station
[(
st1
,
st2
)]
*
weightFactors
[
1
]
/
float
(
normalisingFactorDeltaStation
)
)
obj
.
append
(
Delta_Station
[(
st1
,
st2
)]
*
weightFactors
[
1
]
/
float
(
normalisingFactorDeltaStation
)
)
# min variation in PB assignment
# min variation in PB assignment
if
weightFactors
[
2
]
>
0
:
Delta_Assignment
=
[]
Delta_Assignment
=
[]
OldAss
=
{}
OldAss
=
{}
for
pb
in
previousAssignment
:
for
pb
in
previousAssignment
:
...
@@ -98,6 +101,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -98,6 +101,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
# 4th obj = fill a subline
# 4th obj = fill a subline
if
weightFactors
[
3
]
>
0
:
# verify whether there are machines active in the sublines
# verify whether there are machines active in the sublines
subline
=
{
0
:{
'noMach'
:
0
,
'WIP'
:
0
},
1
:{
'noMach'
:
0
,
'WIP'
:
0
}}
subline
=
{
0
:{
'noMach'
:
0
,
'WIP'
:
0
},
1
:{
'noMach'
:
0
,
'WIP'
:
0
}}
for
mach
in
machineList
:
for
mach
in
machineList
:
...
@@ -127,7 +131,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -127,7 +131,7 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
subLine
=
LpVariable
(
'SubL'
,
lowBound
=
0
)
subLine
=
LpVariable
(
'SubL'
,
lowBound
=
0
)
sub
=
[]
sub
=
[]
for
station
in
range
(
3
):
for
station
in
range
(
3
):
mach
=
G
.
Tool
[
station
][
chosenSubLine
].
name
#'St'+str(station)+'_M'+str(chosenSubLine)
mach
=
Tool
[
station
][
chosenSubLine
].
name
#'St'+str(station)+'_M'+str(chosenSubLine)
for
oper
in
PBlist
:
for
oper
in
PBlist
:
if
station
in
PBskills
[
oper
]:
if
station
in
PBskills
[
oper
]:
sub
.
append
(
PB_ass
[(
oper
,
mach
)])
sub
.
append
(
PB_ass
[(
oper
,
mach
)])
...
@@ -138,6 +142,15 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -138,6 +142,15 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
obj
.
append
(
subLine
*
weightFactors
[
3
]
/
3.0
)
obj
.
append
(
subLine
*
weightFactors
[
3
]
/
3.0
)
# 5th objective: prioritise machines with furthest in time last assignment
LastAssignmentSum
=
float
(
sum
([
machineList
[
mach
][
'lastAssignment'
]
for
mach
in
machines
]))
if
LastAssignmentSum
>
0
and
weightFactors
[
4
]
>
0
:
obj
+=
[
machineList
[
mach
][
'lastAssignment'
]
*
PB_ass
[(
oper
,
mach
)]
*
weightFactors
[
4
]
/
float
(
LastAssignmentSum
)
for
oper
in
PBlist
for
mach
in
machines
if
machineList
[
mach
][
'stationID'
]
in
PBskills
[
oper
]]
# 6th objective: max the number of pb assigned
if
weightFactors
[
5
]
>
0
:
obj
+=
[
PB_ass
[(
oper
,
mach
)]
*
weightFactors
[
5
]
/
float
(
len
(
PBlist
))
for
oper
in
PBlist
for
mach
in
machines
if
machineList
[
mach
][
'stationID'
]
in
PBskills
[
oper
]]
prob
+=
lpSum
(
obj
)
prob
+=
lpSum
(
obj
)
# constraint 1: # operators assigned to a station <= 1
# constraint 1: # operators assigned to a station <= 1
...
@@ -148,6 +161,10 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -148,6 +161,10 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
for
operator
in
PBlist
:
for
operator
in
PBlist
:
prob
+=
lpSum
([
PB_ass
[(
operator
,
machine
)]
for
machine
in
machines
if
machineList
[
machine
][
'stationID'
]
in
PBskills
[
operator
]])
<=
1
prob
+=
lpSum
([
PB_ass
[(
operator
,
machine
)]
for
machine
in
machines
if
machineList
[
machine
][
'stationID'
]
in
PBskills
[
operator
]])
<=
1
# write the problem data to an .lp file.
prob
.
writeLP
(
"PBassignment.lp"
)
prob
.
solve
()
prob
.
solve
()
if
LpStatus
[
prob
.
status
]
!=
'Optimal'
:
if
LpStatus
[
prob
.
status
]
!=
'Optimal'
:
...
@@ -173,4 +190,3 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
...
@@ -173,4 +190,3 @@ def opAss_LP(machineList, PBlist, PBskills, previousAssignment={}):
\ No newline at end of file
\ 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