Skip to main content Accessibility help
Hostname: page-component-684899dbb8-ct24h Total loading time: 0.314 Render date: 2022-05-17T15:33:29.237Z Has data issue: true Feature Flags: { "shouldUseShareProductTool": true, "shouldUseHypothesis": true, "isUnsiloEnabled": true, "useRatesEcommerce": false, "useNewApi": true }

Finding similar/diverse solutions in answer set programming*

Published online by Cambridge University Press:  01 November 2011

Institute of Information Systems, Vienna University of Technology, Vienna, Austria (e-mail:
Faculty of Engineering and Natural Sciences, Sabanci University, Istanbul, Turkey (e-mail:,
Faculty of Engineering and Natural Sciences, Sabanci University, Istanbul, Turkey (e-mail:,
Institute of Information Systems, Vienna University of Technology, Vienna, Austria (e-mail:


For some computational problems (e.g., product configuration, planning, diagnosis, query answering, phylogeny reconstruction), computing a set of similar/diverse solutions may be desirable for better decision-making. With this motivation, we have studied several decision/optimization versions of this problem in the context of Answer set programming (ASP), analyzed their computational complexity, and introduced offline/online methods to compute similar/diverse solutions of such computational problems with respect to a given distance function. All these methods rely on the idea of computing solutions to a problem by means of finding the answer sets for an ASP program that describes the problem. The offline methods compute all solutions of a problem in advance using the ASP formulation of the problem with an existing ASP solver, like clasp, and then identify similar/diverse solutions using some clustering methods (possibly in ASP as well). The online methods compute similar/diverse solutions of a problem following one of the three approaches: by reformulating the ASP representation of the problem to compute similar/diverse solutions at once using an existing ASP solver; by computing similar/diverse solutions iteratively (one after the other) using an existing ASP solver; by modifying the search algorithm of an ASP solver to compute similar/diverse solutions incrementally. All these methods are sound; the offline method and the first online method are complete whereas the others are not. We have modified clasp to implement the last online method and called it clasp-nk. In the first two online methods, the given distance function is represented in ASP; in the last one, however, it is implemented in C++. We have shown the applicability and the effectiveness of these methods using clasp or clasp-nk on two sorts of problems with different distance measures: on a real-world problem in phylogenetics (i.e., reconstruction of similar/diverse phylogenies for Indo-European languages), and on several planning problems in a well-known domain (i.e., Blocks World). We have observed that in terms of computational efficiency (both time and space), the last online method outperforms the others; also, it allows us to compute similar/diverse solutions when the distance function cannot be represented in ASP (e.g., due to some mathematical functions not supported by the ASP solvers) but can be easily implemented in C++.

Regular Papers
Copyright © Cambridge University Press 2011

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)



Part of the results in this paper are contained, in preliminary form, in Proceedings of the 25th International Conference on Logic Programming (ICLP 2009). This work was partially supported by FWF (Austrian Science Funds) project P20841, the Wolfgang Pauli Institute, and TUBITAK Grants 107E229 and 108E229.


Bafna, V. and Pevzner, P. 1998. Sorting by transpositions. SIAM Journal of Discrete Mathematics 11, 224240.CrossRefGoogle Scholar
Bailleux, O. and Marquis, P. 1999. DISTANCE-SAT: Complexity and algorithms. In Proc. of AAAI, 642647.Google Scholar
Bluis, J. and Shin, D.-G. 2003. Nodal distance algorithm: Calculating a phylogenetic tree comparison metric. In Proc. of BIBE, 8794.Google Scholar
Bodenreider, O., Çoban, Z. H., Doğanay, M. C., Erdem, E. and Koşucu, H. 2008. A preliminary report on answering complex queries related to drug discovery using answer set programming. In Proc. of ALPSWS, 8590.Google Scholar
Brooks, D. and McLennan, D. 1991. Phylogeny, Ecology, and Behavior: A Research Program in Comparative Biology. University of Chicago Press, Chicago, IL.Google Scholar
Brooks, D. R., Erdem, E., Erdogan, S. T., Minett, J. W. and Ringe, D. 2007. Inferring phylogenetic trees using answer set programming. Journal of Automated Reasoning 39 (4), 471511.CrossRefGoogle Scholar
Brooks, D. R., Erdem, E., Minett, J. W. and Ringe, D. 2005. Character-based cladistics and answer set programming. In Proc. of PADL, 3751.Google Scholar
Caldiran, O., Haspalamutgil, K., Ok, A., Palaz, C., Erdem, E. and Patoglu, V. 2009. Bridging the gap between high-level reasoning and low-level control. In Proc. of LPNMR, 342354.Google Scholar
Camin, J. and Sokal, R. 1965. A method for deducing branching sequences in phylogeny. Evolution 19 (3), 311326.CrossRefGoogle Scholar
Chafle, G., Dasgupta, K., Kumar, A., Mittal, S. and Srivastava, B. 2006. Adaptation in web service composition and execution. In Proc. of ICWS, 549557.Google Scholar
Chen, Z.-Z. and Toda, S. 1995. The complexity of selecting maximal solutions. Information and Computation 119, 231239.CrossRefGoogle Scholar
Coban, E., Erdem, E. and Ture, F. 2008. Comparing ASP, CP, ILP on two challenging applications: Wire routing and haplotype inference. In Proc. of the 2nd International Workshop on Logic and Search (LaSh 2008), 166180.Google Scholar
DasGupta, B., He, X., Jiang, T., Li, M., Tromp, J. and Zhang, L. 1997. On distances between phylogenetic trees. In Proc. of SODA, 427436.Google Scholar
Davis, M., Logemann, G. and Loveland, D. 1962. A machine program for theorem-proving. Communications of the ACM 5, 394397.CrossRefGoogle Scholar
Do, M. B. and Kambhampati, S. 2001. Planning as constraint satisfaction: Solving the planning graph by compiling it into CSP. Artificial Intelligence 132 (2), 151182.CrossRefGoogle Scholar
Edwards, A. and Cavalli-Sforza, L. 1964. Reconstruction of evolutionary trees. In Phenetic and Phylogenetic Classification, Heywood, V. H. and McNeill, J., Systematics Association, London, 6776.Google Scholar
Eiter, T. and Subrahmanian, V. 1999. Heterogeneous active agents, ii: Algorithms and complexity. Artificial Intelligence 108 (1–2), 257307.CrossRefGoogle Scholar
Erdem, E. 2002. Theory and Applications of Answer Set Programming. PhD thesis, Department of Computer Sciences, University of Texas at Austin.Google Scholar
Erdem, E. 2009. PHYLO-ASP: Phylogenetic systematics with answer set programming. In Proc. of LPNMR, 567572.Google Scholar
Erdem, E., Lifschitz, V. and Ringe, D. 2006. Temporal phylogenetic networks and logic programming. Theory and Practice of Logic Programming 6 (5), 539558.CrossRefGoogle Scholar
Erdem, E. and Wong, M. D. F. 2004. Rectilinear Steiner tree construction using answer set programming. In Proc. of ICLP, 386399.Google Scholar
Ferraris, P. and Lifschitz, V. 2005. Weight constraints as nested expressions. Theory and Practice of Logic Programming 5, 4574.CrossRefGoogle Scholar
Gebser, M., Kaufmann, B., Neumann, A. and Schaub, T. 2007a. clasp: A conflict-driven answer set solver. In Proc. of LPNMR, 260265.Google Scholar
Gebser, M., Kaufmann, B., Neumann, A. and Schaub, T. 2007b. T.: Conflict-driven answer set solving. In Proc. of IJCAI, 386392.Google Scholar
Gelfond, M. and Lifschitz, V. 1991. Classical negation in logic programs and disjunctive databases. New Generation Computing 9, 365385.CrossRefGoogle Scholar
Gerevini, A., Saetti, A. and Serina, I. 2003. Planning through stochastic local search and temporal action graphs in LPG. Journal of Artificial Intelligence Research 20 (1), 239290.Google Scholar
Gutin, G. 2003. Independent sets and cliques. In Handbook of Graph Theory, Chap. 5.3. Gross, J. L. and Yellin, J., Eds. CRC Press, Boca Raton, FL, 389402.Google Scholar
Hamming, R. W. 1950. Error detecting and error correcting codes. Bell System Technical Journal 29 (2), 147160.CrossRefGoogle Scholar
Hebrard, E., Hnich, B., O'Sullivan, B. and Walsh, T. 2005. Finding diverse and similar solutions in constraint programming. In Proc. of AAAI, 372377.Google Scholar
Hebrard, E., O'Sullivan, B. and Walsh, T. 2007. Distance constraints in constraint satisfaction. In Proc. of IJCAI, 106111.Google Scholar
Hon, W.-K., Kao, M.-Y. and Lam, T.-W. 2000. Improved Phylogeny Comparisons: Non-shared Edges, Nearest Neighbor Interchanges, and Subtree Transfers. In Algorithms and Computation. Goos, G., Hartmanis, J., van Leeuwen, J., Lee, D. T., Teng, S-H., Eds. Springer Berlin/Heidelberg, 369382.Google Scholar
Kautz, H. A. and Selman, B. 1992. Planning as satisfiability. In Proc. of ECAI, 359363.Google Scholar
Kuhner, M. and Felsenstein, J. 1994. A simulation comparison of phylogeny algorithms under equal and unequal evolutionary rates [published erratum appears in Mol Biol Evol 1995 May;12(3):525]. Molecular Biology and Evolution 11 (3), 459468.Google Scholar
Lifschitz, V. 1999. Action languages, answer sets and planning. In The Logic Programming Paradigm: a 25-Year Perspective, Apt, K. R., Marek, V. W., Truszczynski, M., Warren, D. S., Eds. Springer Verlag, Berlin, 357373.CrossRefGoogle Scholar
Lifschitz, V. 2008. What is answer set programming? In Proc. of. AAAI, 15941597.Google Scholar
Lifschitz, V. 2010. Thirteen definitions of a stable model. In Fields of Logic and Computation, Blass, A., Derschowitz, N., Reisig, W., Eds. Springer-Verlag, Berlin, Heidelberg, 488503.CrossRefGoogle Scholar
Lifschitz, V., Tang, L. R. and Turner, H. 1999. Nested expressions in logic programs. Annals of Mathematics and Artificial Intelligence 25, 369389.CrossRefGoogle Scholar
Marek, W. and Remmel, J. 2003. On the expressibility of stable logic programming. Theory and Practice of Logic Programming 3 (4–5), 551567.CrossRefGoogle Scholar
Marques-Silva, J. and Sakallah, K. 1999. A search algorithm for propositional satisfiability. IEEE Transactions on Computers 5, 506521.CrossRefGoogle Scholar
McIlraith, S. A. and Son, T. C. 2002. Adapting Golog for composition of semantic web services. In Proc. of KR, 482496.Google Scholar
Nogueira, M., Balduccini, M., Gelfond, M., Watson, R. and Barry, M. 2001. An A-Prolog decision support system for the space shuttle. In Proc. of PADL. Springer-Verlag, London, 169183.Google Scholar
Nye, T. M., Lio, P. and Gilks, W. R. 2006. A novel algorithm and web-based tool for comparing two alternative phylogenetic trees. Bioinformatics 22 (1), 117119.CrossRefGoogle ScholarPubMed
Papadimitriou, C. 1994. Computational Complexity. Addison-Wesley, Reading, MA.Google Scholar
Ringe, D., Warnow, T. and Taylor, A. 2002. Indo-European and computational cladistics. Transactions of the Philological Society 100 (1), 59129.CrossRefGoogle Scholar
Robinson, D. F. and Foulds, L. R. 1981. Comparison of phylogenetic trees. Mathematical Biosciences 53 (1–2), 131147.CrossRefGoogle Scholar
Simons, P., Niemelä, I. and Soininen, T. 2002. Extending and implementing the stable model semantics. Artificial Intelligence 138, 181234.CrossRefGoogle Scholar
Soininen, T. and Niemelä, I. 1998. Developing a declarative rule language for applications in product configuration. In Proc. of PADL, 305319.Google Scholar
Son, T., Pontelli, E. and Sakama, C. 2009. Logic programming for multiagent planning with negotiation. In Proc. of ICLP, 99114.Google Scholar
Srivastava, B., Nguyen, T. A., Gerevini, A., Kambhampati, S., Do, M. B. and Serina, I. 2007. Domain independent approaches for finding diverse plans. In Proc. of IJCAI, 20162022.Google Scholar
Swofford, D. L. 2003. PAUP*: Phylogenetic Analysis under Parsimony (and Other Methods), version 4.0. Sinauer Associates, Sunderland, MA.Google Scholar
White, J. and O'Connell, J. 1982. A Prehistory of Australia, New Guinea, and Sahul. Academic, San Diego, CA.Google Scholar
Cited by

Save article to Kindle

To save this article to your Kindle, first ensure is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the or variations. ‘’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Finding similar/diverse solutions in answer set programming*
Available formats

Save article to Dropbox

To save this article to your Dropbox account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you used this feature, you will be asked to authorise Cambridge Core to connect with your Dropbox account. Find out more about saving content to Dropbox.

Finding similar/diverse solutions in answer set programming*
Available formats

Save article to Google Drive

To save this article to your Google Drive account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you used this feature, you will be asked to authorise Cambridge Core to connect with your Google Drive account. Find out more about saving content to Google Drive.

Finding similar/diverse solutions in answer set programming*
Available formats

Reply to: Submit a response

Please enter your response.

Your details

Please enter a valid email address.

Conflicting interests

Do you have any conflicting interests? *