Symbolic Solver icsymbolic a solver for symbolic domains
Symbolic Solver
ic_symbolic - a solver for symbolic domains ¡ Load the ic_symbolic library by using : - lib(ic_symbolic). at the beginning of your code, or type lib(ic_symbolic). at the top-level ECLi. PSe prompt. ¡ Implements variables and constraints over ordered symbolic domains 2
Domains ¡ Domain elements may be of any atomic type (atoms, strings, numbers) but usually atoms ¡ Domains are declared using domain/1: : - local domain(colour(red, green, blue)). : - export domain(vowel(a, e, i, o, u)). ¡ Domain elements must belong to only one visible domain (to avoid ambiguity) ¡ Domain elements are associated with natural numbers, based on the order from their declaration red → 1, green → 2, blue → 3 // a → 1, e → 2, i → 3, o → 4, u → 5 3
Symbolic variables ¡ Declaring symbolic variables: Colour &: : colour [X, Y] &: : [red, green] ¡ ¡ Internally, each symbolic variable is mapped to an IC variable Symbolic variables and constants appearing in a constraint must belong to same domain 4
Basic constraints ¡ X &= Y, X &= Y Equality, disequality. ¡ X &< Y, X &> Y, X &=< Y, X &>= Y Constrain relative to domain order. ¡ shift(X, C, Y), rotate(X, C, Y) Constrain offsets between variables in domain order. ¡ Reified versions of the above available 5
Other constraints ¡ alldifferent(List) All elements of List are different ¡ alldifferent(List, Cap) No elements of List appears more than Cap times ¡ occurrences(Value, List, N) Value occurs N times in List ¡ element(Index, List, Value) Value occurs in List at position Index ¡ atmost(N, List, Value) Value occurs at most N times in List 6
Search support ¡ indomain(X) Instantiates X to an element from its domain. ¡ Use symbol_domain_index/3 or symbols_domain_indices/3 to map symbolic variables to IC variables and then use IC’s search facilities 7
- Slides: 7