Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modular Answer Set Programming. Introduction One common answer set programming (ASP) methodology is to: Encode the problem Enumerate possible solutions.

Similar presentations


Presentation on theme: "Modular Answer Set Programming. Introduction One common answer set programming (ASP) methodology is to: Encode the problem Enumerate possible solutions."— Presentation transcript:

1 Modular Answer Set Programming

2 Introduction One common answer set programming (ASP) methodology is to: Encode the problem Enumerate possible solutions Test and eliminate non-solutions Size of state space of the problem can limit ASP solvers to find solutions in a reasonable amount of time. Can we somehow split the representation and solve in parts?

3 Illustration of Splitting Consider an AnsProlog program  =E 1  E 2  T 1  T 2, where E 1, E 2 are enumeration parts and T 1, T 2 are test parts. 1. Split  into  1 = T 1  E 1 and  2 = T 2  E 2. 2. Compute answer sets of  1. 3. For each answer set A i of  1, compute the answer sets of  2  A i.

4 Illustration of Splitting Assume that T 1 enumerates n binary atoms and T 2 enumerates m binary atoms, and T 1  E 1 has only a small number k of solutions A i. Finding answer sets of  could involve a search space of 2 m+n. As for splitting,  1 can involve search space of 2 n and k search spaces of 2 m for  2  A i.

5 Idea – modular ASP A declarative language that builds on top of AnsProlog. Large programs can be broken into modules. Enhance readability and project management. Communication between modules are done by “import rules”.

6 ASP modules An ASP rule is of the form: An ASP module consists of: a name, a set of parameters, a collection of ASP rules, and a collection of ASP import rules.

7 Instantiation of Modules Suppose P is the name of an ASP module and P has the following rule: date(1..N). P(N=9) is an instantiation of P which indicates that the value of N becomes 9 in module P.

8 Modular ASP by examples Suppose P 1 is the following ASP module that contains the predicate p(X,Y,Z), which is declared as for export. % module P1 p(c,d,a). p(e,f,a) :- not p(g,h,a). p(g,h,a) :- not p(e,f,a). Module P 1 has two answer sets: { p(c,d,a), p(e,f,a)} and { p(c,d,a), p(g,h,a)}

9 Import rule (a) Import predicates that exist in all answer sets of module P to module P’, based on some criteria. Example: Suppose P 2 is an ASP module that contains an import rule r of the form (a) that refers to P 1. % import rule r q(X,Y) :- P1.p(X,Y,a). % answer sets of P1 are { p(c,d,a), p(e,f,a)} and { p(c,d,a), p(g,h,a)} The predicate p(c,d,a) exists in all answer sets of P 1. Therefore, the extracted set of r is {q(c,d)}.

10 Import rule (b) Import predicates that exist in any answer sets of module P to module P’, based on some criteria. Suppose P 3 is an ASP module that contains an import rule r of the form (b) that refers to P 1. % import rule r *q(X,Y) :- P1.p(X,Y,a). % answer sets of P1 are {p(c,d,a), p(e,f,a)} and { p(c,d,a), p(g,h,a)} By filtering the answer sets of P 1 using r, the extracted set of r is { { q(c,d), q(e,f) }, { q(c,d), q(g,h) } }.

11 Import rule (c) Import predicates that exist in any answer sets of module P to module P’ based on some criteria, and numerate the predicates to form a singleton set of predicates. Suppose P 4 is an ASP module that contains an import rule r of the form (c) that refers to P 1. % import rule r q(#,X,Y) :- P1.p(X,Y,a). % answer sets of P1 are {p(c,d,a), p(e,f,a)} and { p(c,d,a), p(g,h,a)} The extracted set of r is { q(1,c,d), q(1,e,f), q(2,c,d), q(2,g,h) }.

12 ACC example Description of ACC college basketball tournament problem Nine college teams play over a period of nine weeks in the Two games per week: one on a weekday and one on a weekend On each game day: 8 teams play either at home or away Double round-robin: every team plays against every other team twice, once at home and once away. Mirroring dates: teams who play on day d will play again on day d+9. 2 9*8*9 atoms of order of schedules!

13 ACC example Attempted to encode the problem using a direct encoding approach No returned solutions by the currently most efficient AnsProlog solvers - Smodels and DLV Encode the problem using ASP modules Solutions are returned in a reasonable amount of time

14 Conclusion Modular ASP is a simple extension to AnsProlog. Can write AnsProlog modules and import from one module to another. Difficult problems can be solved with certain modularization. Future Work: incorporate different ASP solvers and other declarative languages such as Prolog to modular ASP.


Download ppt "Modular Answer Set Programming. Introduction One common answer set programming (ASP) methodology is to: Encode the problem Enumerate possible solutions."

Similar presentations


Ads by Google