Modeling with finite domain constraints II Kris Kuchcinski

advertisement
Modeling with
finite domain constraints II
Kris Kuchcinski
kku@ida.liu.se
5/31/2016
1
Outline
 Advanced modeling example for scheduling
 elliptic wave filter example
 use of cumulative constraints for task scheduling and bin packing
problems
 The role of forward checking and look-ahead methods
during search
 Meta-search heuristics
 credit search
 limited discrepancy search
5/31/2016
2
Elliptic wave filter example
i1
i2 i3 i4
i5
i6
+
+
+
+
+
*
*
+
+
+
+
+
+
*
*
+
+
+
*
+
+
i7
i8
*
+
5/31/2016
+
+
+
+
*
+
*
+
+
+
+
3
Precedence constraints
Sicstus:
...
T15 + 2 #=< T17,
T16 + 1 #=< T18,
...
CHIP:
...
T15 + 2 #<= T17,
T16 + 1 #<= T18,
...
5/31/2016
4
Modeling with Sicstus I
Constraints:
For all i, j
Ti + Di #=< Tj #\/ Tj + Dj #=< Ti #\/ Ri #\= Rj
Labeling:
label([]).
label([r(T, R)|L]) :indomain(T), indomain(R),
label(L).
Minimization:
minimize(label(L), End)
5/31/2016
5
Modeling with Sicstus II
Constraints:
For all i, j :
Ti + Di #=< Tj #\/ Tj + Dj #=< Ti #\/ Ri #\= Rj
cumulative(([T1,T2,...,T34], [1,1,… ,1],
[1,1,… ,1], AddNo),
cumulative([T6,T7,… ,T27], [2,2,… ,2],
[1,1,… ,1], MulNo),
Minimization:
minimize(labeling([ff], T), End),
labeling([], R).
5/31/2016
6
Experimental results
Results for 2 adders and 2 multipliers
End
Constraints
Solution 1
no cumulative
18
2566
25 390 772
Solution 2
no cumulative
first fail labeling
Solution 2
(cumulative)
18
2565
18
2567
5/31/2016
Resumptions
Entailments
Prunings
Backtracks
CPU time
(s)
146 330 69
16 082 433
211 981
206
364 472
174 178
198 992
4 551
8.5
31 772
5 764
14 433
1
0.5
7
Modeling with CHIP
Constraints:
diffn([[T1,R1,1,1],[T2,R2,1,1],… ,[T34,R34,1,1]),
Minimization:
min_max(labeling(V, 1, smallest, rec_indomain), [E14, …, E34]),
rec_indomain(r(T,R)) :indomain(T), indomain(R).
CPU time = 0.23 s
5/31/2016
8
Use of cumulative constraint for
task scheduling
Resource
Resource limit
Time
cumulative([T1, T2, T3], [D1, D2, D3], [1, 1, 1], ResourceLimit)
5/31/2016
9
Use of cumulative constraint for
binpacking problems
Time
Time limit
Resource
cumulative([R1, R2, R3], [1, 1, 1], [D1, D2, D3], TimeLimit)
5/31/2016
10
Branch and Bound algorithm
Branch and Bound consists of the following steps:
 finds a bound for the cost function after each decision,
 cut out all the branches of the decision tree which give
results worse than the bound (branch),
 update the bound if a better value for the performance
index is found.
5/31/2016
11
Typical branch and bound search
(TSP problem)
City
City
City
City
1
2
3
4
City 1
-
City 2
3
-
City 3
6
40
-
City 4
41
5
4
-
{1}
L 
{1,2}
L 
{1,2,3}
L 
{1,2,4}
L 8
{1,2,3,4}
L =88
{1,2,4,3}
L =8
5/31/2016
{1,3}
L 
{1,3,2}
L 
{1,4}
L 
{1,3,4}
L 
{1,3,4,2}
L =8
12
Search with restart
(CHIP’s min_max)
City
City
City
City
1
2
3
4
City 1
-
City 2
3
-
{1,2}
L 
City 3
6
40
-
{1,2}
L 
{1,2,3}
L 
{1,2,4}
L 8
{1,2,3,4}
L =88
{1,2,4,3}
L =8
5/31/2016
City 4
41
5
4
-
{1}
L 
{1,3}
L 
{1,3,2}
L 
{1,3}
L 
{1,4}
L 
{1,3,4}
L 
{1,3,4,2}
L =8
13
When backtracking is initiated
during search?
 by constraint violation; Prolog standard,
 unavoidability of constraint violation in the next stepForward Checking (FC),
 unavoidability of constraint violation in future steps(Full) Look Ahead (LA) or Maintaining Arc Consistency
(MAC).
5/31/2016
14
Forward Checking and
Look Ahead
Instantiated
variables
Currently instantiated
variable
Not yet instantiated
variables
backtracking
forward checking
5/31/2016
Look ahead
15
Forward Checking algorithm
procedure AC-FC(CurrentVar)
Q  {(Vi, VCurrentVar) in arcs(G), i > CurrentVar}
consistent  true
while not Q empty & consistent
select and delete any arc (Vk, Vm) from Q;
if arc_consistent(Vk, Vm) then
consistent  not Dk empty
endif
endwhile
return consistent
end AC-FC;
5/31/2016
16
Look Ahead algorithm
procedure AC-LA(CurrentVar)
Q  {(Vi, VCurrentVar) in arcs(G), i > CurrentVar}
consistent  true
while not Q empty & consistent
select and delete any arc (Vk, Vm) from Q;
if arc_consistent(Vk, Vm) then
Q  Q  {(Vi,Vk) such that (Vi,Vk) in arcs(G),
i  k, i  m, i > CurrentVar}
consistent  not Dk empty
endif
endwhile
return consistent
end AC-LA;
5/31/2016
17
Meta-heuristics - motivation
 Large optimization problems can run for a long time
without providing any solution,
 The search using branch and bound can be trapped in
the beginning of the search tree and can not explore the
rest of the search space,
 There exist known heuristics and meta-heuristics for
selected problems.
5/31/2016
18
Credit search
initial credit = 8
credit(T,
8, % credits
10,
my_delete,
my_indomain,
3, % backtracks
part(1,2)),
2
1
4
2
1
1
1
credit search
local search
solution
5/31/2016
19
Download