Questions tagged [answer-set-programming]

Answer set programming is a declarative programming paradigm that can solve difficult search problems. It is based on the stable model (answer set) semantics of logic programming. Unlike traditional programming languages, we don’t give step by step instructions in answer set programming. It is something more like this is what I want, now you work out how to do it.

Answer set programming (ASP) is a declarative programming paradigm that can solve difficult search problems. It is based on the stable model (answer set) semantics of logic programming. Unlike traditional programming languages, we don’t give step by step instructions in answer set programming. It is something more like this is what I want, now you work out how to do it.

In answer set programming, if we can get the logic correct, ASP requires:

  • Orders of magnitude less code than imperative programming
  • Fewer points of failure
  • Less code to test
  • More productive (happier) programming life

traditional programming scheme

answer set programming scheme

161 questions
2
votes
1 answer

Route Inspection of Directed Graph in ASP

For the multidirected graph below I am trying to write an program that visits all edges at least once. For instance, in the below graph I am looking for an outcome similar to "edge(1,2), edge(2,3), edge(3,1), edge(1,2), edge(2,4), edge(4,5),…
2
votes
1 answer

Struggles with the choice rule in Clingo (Answer-Set-Programming)

I'm currently struggling with the following problem: Let's assume this Pseudo-Code: % Animal: ID, Type, Cost animal (id1, dog, 300). animal (id2, dog, 400). animal (id3, dog, 600). animal (id1, cat, 200). animal (id2, cat,…
TheXyresiC
  • 23
  • 2
2
votes
2 answers

Generating Solution Candidates For Matching People in Clingo/ASP

I have a list of people and I want to pair them all then do some filtering based on preferences. When I generate my candidate solutions, how do I avoid creating candidate solutions that re-pair a people. For example: person(a;b;c;d) . {match(X, Y):…
exchez
  • 493
  • 1
  • 4
  • 13
2
votes
1 answer

How to sum all rather than just distinct values in clingo?

The following code produces x(3) rather than x(4) because it adds 1 and 2 together even though 1 appears twice. What is the right way of obtaining total sums in clingo? p(0,1;1,1;2,2). x(X) :- X = #sum { Y: p(_,Y) }.
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
2
votes
2 answers

How to define multiple penalties to minimise overall in clingo?

I am trying to use clingo to generate tournament player-room allocations: player(1..20). room(1..4). played(1..20, 0). rank(1..20, 1). played(1..20, 1..20, 0). 0 { used_room(R) } 1 :- room(R). 3 { game(P, R) } 4 :- used_room(R), player(P). :-…
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
2
votes
1 answer

determining if two cliques are different

Assume I have a graph and want to find 2 different cliques withhin the graph. A clique is a subset of the graphs vertices where all of them are connected. Example Graph with 2 cliques (a,b,c) and (b,c,d) of cliquesize 3 : edge(a,b). edge(a,c).…
DuDa
  • 3,718
  • 4
  • 16
  • 36
2
votes
1 answer

How do I extract the trees from a graph using Answer Set Programming?

There is an undirected graph (V,E), weights on the edges w : E → N, a target k ∈ N, and a threshold O ∈ N. Find a k-vertices tree of the graph of weight less than the threshold. In other words, select k vertices and k - 1 edges from V and E…
2
votes
1 answer

How to get a set of courses that fulfill degree requirements with Answer Set Programming

(Noob here.) Say I have a degree that requires a student to take CS1 and CS2 and (CS3 or CS4). I'd like to use ASP to get a list of courses a student could take to fulfill the degree requirements. Specifically, I'd expect the answer to be {CS1, CS2,…
bricksphd
  • 147
  • 9
2
votes
1 answer

Answer Set Programming: How does Graph coloring work? (Explain ASP Code)

My assignment: Graph coloring - Write an answer set program to check if a graph had a 4-coloring and, if it does, the answer set should contain the coloring. If there isn't a coloring, it wont have an answer set. The program should consist of the…
2
votes
1 answer

Brave/Cautious reasoning in clingo

In Clingo guide, there are two modes called cautious and brave introduced as the follows: brave Compute the brave consequences (union of all answer sets) of a logic program. cautious Compute the cautious consequences (intersection of all answer…
BobHU
  • 402
  • 5
  • 18
2
votes
1 answer

Negation as failure in Prolog and default negation in Answer Set Programming

I'm having an extremely hard time understanding the concept of negation as failure in Prolog compared to default negation in Answer Set Programming. Could someone please explain to me what the difference is?
2
votes
1 answer

How to represent the unknown knowledge to be reasoned in Answer Set Programming?

Here is the problem to solve: If Jim does not buy toys for his children, Jim’s children will not receive toys for Christmas. If Jim’s children do not write their Christmas letters, Jim will not buy them toys. Jim’s children do receive toys for…
BobHU
  • 402
  • 5
  • 18
2
votes
1 answer

Is "undecidable" can be represented in ASP (Answer Set Programming)?

A sentence like If a(X), then one can't decide/conclude anything about a(X) being b(X) First attempt b(X) | -b(X) :- a(X). Second attempt :- a(X), b(X). :- a(X), -b(X). First one makes no change to the solution while second one makes everything…
Pay C.
  • 1,048
  • 1
  • 13
  • 20
2
votes
1 answer

Mixed quantification in Answer Set Programming

I would like to be able to formulate the following FOL sentence in ASP/clingo: ∀ X. prop(X) ⇐ (∃ Y. ∀ V. ∃ A. (p(Y, V, A) ∧ q(X, V, A)) ) The domain of both X and Y is given by dom/1. The domain for A is given by…
2
votes
1 answer

problems generating interval information

Given a a binary function over time, I try to extract the information about the intervals occuring in this function. E.g. I have the states a and b, and the following function: a, a, b, b, b, a, b, b, a, a Then i would want a fact interval(Start,…
Uzaku
  • 511
  • 5
  • 17
1
2
3
10 11