Modeling with finite domain constraints I Kris Kuchcinski

  • Slides: 14
Download presentation
Modeling with finite domain constraints I Kris Kuchcinski kku@ida. liu. se 9/16/2020 1

Modeling with finite domain constraints I Kris Kuchcinski kku@ida. liu. se 9/16/2020 1

Outline z Domains and labeling z Global and symbolic constraints y alldifferent, element y

Outline z Domains and labeling z Global and symbolic constraints y alldifferent, element y diffn, cumulative, precedence z Improving labeling (variable selection, splitting, etc. ) 9/16/2020 2

Domain definition z CHIP X : : 1. . 10, [X 1, X 2,

Domain definition z CHIP X : : 1. . 10, [X 1, X 2, X 3] : : 1. . 10, [Z 1, Z 2] : : [1, 3, 5], V 1 : : 1: 100 z Sicstus (based on indexicals) : - use_module(library(clpfd)) X in 1. . 10, X in {1, 3, 5} 9/16/2020 Z in -1. . 1, Y in (1. . 10) / (20. . 30) domain([X 1, X 2, X 3], 1, 10) 3

Labeling in CHIP and Sicstus z CHIP labeling(V, 0, input_order, indomain) z Sicstus labeling([],

Labeling in CHIP and Sicstus z CHIP labeling(V, 0, input_order, indomain) z Sicstus labeling([], V) 9/16/2020 4

Send+More=Money Example CHIP sendmory([S, E, N, D, M, O, R, Y]): [S, E, N,

Send+More=Money Example CHIP sendmory([S, E, N, D, M, O, R, Y]): [S, E, N, D, M, O, R, Y] : : 0. . 9, alldifferent([S, E, N, D, M, O, R, Y]), S #= 0, M #= 0, Send = 1000*S+100*E+10*N+D, More = 1000*M+100*O+10*R+E, Money = 10000*M+1000*O+100*N+10*E+Y, Send + More #= Money, labeling([S, E, N, D, M, O, R, Y], 0, input_order, indomain). 9/16/2020 5

Send+More=Money Example Sicstus : - use_module(library(clpfd)) sendmory([S, E, N, D, M, O, R, Y]):

Send+More=Money Example Sicstus : - use_module(library(clpfd)) sendmory([S, E, N, D, M, O, R, Y]): domain([S, E, N, D, M, O, R, Y], 0, 9), S #> 0, M #> 0, all_different(L), 1000*S+100*E+10*N+D + 1000*M+100*O+10*R+E #= 10000*M+1000*O+100*N+10*E+Y, labeling([], L). 9/16/2020 6

Symbolic constraints - alldifferent z alldifferent- CHIP alldifferent([X 1, X 2, …, Xn]) z

Symbolic constraints - alldifferent z alldifferent- CHIP alldifferent([X 1, X 2, …, Xn]) z alldifferent- Sicstus all_different([X 1, X 2, …, Xn]] % incomplete implementation all_distinct([X 1, X 2, …, Xn]) % complete implementation which % maintains domain-consistency 9/16/2020 7

Global constraints - cumulative z Task representation as a rectangle Resource limit Time cumulative([Start

Global constraints - cumulative z Task representation as a rectangle Resource limit Time cumulative([Start 1, Start 2], [D 1, D 2], [1, 1], Resource. Limit) 9/16/2020 8

Symbolic constraints - element(Index, List, Value) Example Ix : : 1. . 3, element(Ix,

Symbolic constraints - element(Index, List, Value) Example Ix : : 1. . 3, element(Ix, [11, 22, 33], Val) 9/16/2020 9

Global constraint - diffn/11 (CHIP only) Y (resources) duration task 1 Ri Start X

Global constraint - diffn/11 (CHIP only) Y (resources) duration task 1 Ri Start X (time) diffn([ [X 1, Y 1, Dx 1, Dy 1], [X 2, Y 2, Dx 2, Dy 2]], . . . ) 9/16/2020 10

Global constraint - precedence (CHIP only) precedence([H 1 , . . , Hr ],

Global constraint - precedence (CHIP only) precedence([H 1 , . . , Hr ], [O 1 , . . , On ], [D 1 , . . , Dn ], [[R 11 , . . , R 1 r ], . . , [Rn 1 , . . , Rnr ]], [[A 1 , B 1 ], . . , [Am , Bm ]]) where H 1, . . , Hr corresponds to the capacities of a set of resources, O 1, . . , On to the start of tasks, D 1, . . , Dn to the duration of tasks Ri 1, . . , Rir amount of resource used by the i th task. [A 1, B 1], . . , [Am, Bm] correspond to a list of pairs of task indices. 9/16/2020 11

Precedence example top: [A, B, C, D] : : 0. . 3, A #<=

Precedence example top: [A, B, C, D] : : 0. . 3, A #<= B, A #<= C, B #<= D, C #<= D, cumulative([A, B, C, D], [1, 1, 1, 1], unused, 1, unused), precedence([1], [A, B, C, D], [1, 1, 1, 1], [[1], [1]], [[1, 2], [1, 3], [2, 4], [3, 4]]), writef([A, B, C, D], 64). Results with precedence [0, B in {1. . 2}, C in {1. . 2}, 3] Results without precedence [A in {0. . 3}, B in {0. . 3}, C in {0. . 3}, D in {0. . 3}] 9/16/2020 12

Labeling CHIP labeling(+List, +Arg, +Method, +Pred) Method = input_order, first_fail, most_constrained, smallest, largest, max_regret,

Labeling CHIP labeling(+List, +Arg, +Method, +Pred) Method = input_order, first_fail, most_constrained, smallest, largest, max_regret, anti_first_fail delete(-Selected, +List, -Rest, +Arg, +Method) indomain(+X, +Method) Method = min, max, middle integer value domain_info(+X, -Min, -Max, -Size, -Occurrence, -Active) 9/16/2020 13

Labeling Sicstus labeling(+Options. List, +Variable. List) Variable selection options: leftmost, min, max, ffc Domain

Labeling Sicstus labeling(+Options. List, +Variable. List) Variable selection options: leftmost, min, max, ffc Domain split for the selected variable: step, bisect Order of exploring domains: up, down Solutions: all, minimize(X), maximize(X) fd_min(? X, ? Min) fd_size(? X, ? Size) 9/16/2020 fd_max((? X, ? Max) fd_dom(? X, ? Dom) 14