1 / 9

Set Domain Solvers

Set Domain Solvers. ic_sets - the set constraint solver. Load the ic_sets library by using :- lib(ic_sets). at the beginning of your code, or type lib(ic_sets). at the top-level ECLiPSe prompt. Sets must be finite and contain only integers We write sets as sorted lists

ham
Download Presentation

Set Domain Solvers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Set Domain Solvers

  2. ic_sets - the set constraint solver • Load the ic_sets library by using • :- lib(ic_sets). • at the beginning of your code, or type • lib(ic_sets). • at the top-level ECLiPSe prompt. • Sets must be finite and contain only integers • We write sets as sorted lists • Note: there is another set solver lib(conjunto) which is being phased out, and lib(fd_sets) which is identical to ic_sets, but works with lib(fd)

  3. Functionality The ic_sets library implements • variables with finite integers set domains • basic constraints over set expressions • constraints over set cardinality and weights • a search primitive

  4. Set domain variables • An integer (ground) set • X = [1,7,12,19] • A set variable • Set :: [7]..[1,7,12,19] • attaches an initial domain to a variable or • intersect their old domain with the new one. • Set variables have a lower and upper bound • Both bounds are (ground) sets • lower bound: set of elements that are definitelyin the set • upper bound: set of elements that may be in the set • They also have a separate lower and upper bound on cardinality.

  5. The basic set of constraints • X in S, X notin S • Set membership. • S1 sameset S2, S1 subset S2, S1 disjoint S2 • Set equality, subset, disjointness. • all_union(Sets,Union), all_disjoint(Sets) • Generalised union and disjointness. • #(Set, Card), weight(Set, ElementWeights, Weight) • Set cardinality and set weight. • Set expressions are allowed: • Intersection S1 /\ S2, Union S1 \/ S2, Difference S1 \ S2

  6. Bound propagation • Constraints affect set bounds: • ?- S::[]..[1,2,3,4,5]. • S = S{([] .. [1, 2, 3, 4, 5]) : C{[0 .. 5]}} • yes. • ?- S::[]..[1,2,3,4,5], 3 in S, 5 notin S. • S = S{[3] \/ ([] .. [1, 2, 4]) : C{[1 .. 4]}} • yes. • ?- S::[]..[1,2,3,4,5], S subset [1,5,6]. • S = S{([] .. [1, 5]) : C{[0 .. 2]}} • yes. • ?- S::[2,4]..[1,2,3,4,5], #(S,2). • S = [2, 4] • yes.

  7. Basic search support • insetdomain(SetVar, Options…) • Try to instantiate SetVar to a ground set. • [eclipse 23]: A :: []..[1,2,3,4,5], insetdomain(A,_,_,_).A = [1, 2, 3, 4, 5] More? (;) A = [1, 2, 3, 4] More? (;) A = [1, 2, 3, 5] More? (;)

  8. Set example – Steiner triplets • Ternary Steiner system of order n: the set of triplets taking values between 1 and n such that all pairs included in any triplets are different. •  a triplet can share at most one number with any other triplet. • Set has n(n-1)/6 triplets. • Not easy to express generically (for any n) with fd only….

  9. Steiner Triplets (Program) :- lib(ic_sets).steiner(N, LS) :-NB is N * (N-1) // 6, % compute number of set variables needed intsets(LS, NB, 1, N), % NB sets can take values between 1 and N( foreach(S,LS) do #(S,3) ), % sets are triplets ( fromto(LS,[S1|Ss],Ss,[]) do ( foreach(S2,Ss), param(S1) do % no triplet can share more than one number with another #(S1 /\ S2,C), ic: (C #=< 1) ) ), label_sets(LS).label_sets([]).label_sets([S | LS]) :- insetdomain(S,_,_,_), label_sets(LS).

More Related