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
2 answers

Find the shortest path in DLV

I am trying to find all the paths in a graph with minimum distance using DLV. Say I have the following graph: I am expecting to obtain the predicates (I hope I don't skip any): path(a, b, 1), path(a, d, 1), path(a, e, 1), path(a, c, 2) path(b, a,…
2
votes
1 answer

Contiguous group of cells in grid

I'm working on a puzzle solver (nonograms, griddler, picross...) just for fun and to learn a bit more of ASP. (You can read more about these puzzles in wikipedia https://en.wikipedia.org/wiki/Nonogram) I want to check if there's a horizontal…
Trigork
  • 177
  • 1
  • 16
2
votes
1 answer

Answer Set Programming: how to assign students to a group such that no two students who dislike each other are in a same group

I am a beginner to Answer Set Programming. I want to group all students in a different groups such that: 1. Each group has 3 to 4 students 2. No two students who dislike each other are in the same group. 3. And we can not assign same student to…
Quest P
  • 87
  • 7
2
votes
1 answer

Converting logical puzzle into predicate calculus and prolog/dlv

The question is : The salt has been stolen! Well, it was found that the culprit was either the Caterpillar, Bill the Lizard or the Cheshire Cat. The three were tried and made the following statements in court: CATERPILLAR: Bill the Lizard ate the…
2
votes
1 answer

how to minimize the number of instances of a literal, in clingo 4.5

I'm unsure how to write an optimization statement in clingo4 (ASP solver). I want to minimize the total number of instances of certain literals in each answer set. I'm simulating a fire-response agent in ASP. The agent can choose to perform certain…
hassapikos
  • 59
  • 1
  • 2
  • 10
2
votes
2 answers

Aggregates in clingo

I have generated : curr(p5,2) curr(p5,1) curr(p5,6) How can I sum up the lase fields 2+1+6? I saw the following in page 21 of clingo_guild.pdf : 15 :- not M-2 [ enroll(C) : hours(C,H) = H ] M, max_hours(M). and come up : #sum [pick(P) : curr(P,I)…
tak-po li
  • 85
  • 4
2
votes
1 answer

Answer Set Programming - How to count number of facts appears to be my query result?

So I have a set of facts and a query written in ASP to be run on DLV, %Q1 : Find the implicit "is_a" relationship between terms %ex: if term A is is_a term B, term B is_a term C, then term A is_a term C %is_a One level triple1(TermA,…
2
votes
1 answer

Answer set programming getting length of series as input

I am new at Answer Set Programming and trying to encode a problem into ASP. I think it is a simple question. Here is the code; events(1..3). sequence(A,B,C) :- events(A;B;C), A!=B, A!=C, B!=C. As you see, there is a sequence which consists of…
genclik27
  • 323
  • 1
  • 7
  • 18
1
vote
1 answer

Detecting even cycles in a directed graph using answer set programming (clingo)?

I struggled a bit with that task. But I want to know, how I can detect if there is an even cycle in a directed graph using answer set programming with clingo. If there is an even cycle, the program should return satisfiable, if there is no even…
LuxLaw
  • 13
  • 3
1
vote
1 answer

Shortest path in Answer Set Programming

I'm trying to find all the shortest path from one source node to all other destination node (so 1-3, 1-5, 1-4) with the relative cost for each shortest path. I've tried with this…
1
vote
1 answer

Solving Hamiltonian cycle in answer set programming

Hamiltonian cycle instantiation and encoding: % vertices: n=node n(1..4). % edges: e=edge e(1,(2;3)). e(2,(3;4)). e(3,(1;4)). e(4,1). % starting point s(1). # p=path, o=omit, op=on-path, r=reach, s=start% generate path p(X,Y):- not o(X,Y),…
1
vote
1 answer

How can I define a married couple in Clingo?

I'm trying to create 5 marriages, given 5 women and 5 man and their preferences to each other. homem(miguel). homem(joao). homem(pedro). homem(marco). homem(carlos). mulher(maria). mulher(paula). mulher(carla). mulher(cristina). mulher(ana). all…
1
vote
1 answer

Optimizing difficulty with a level generator using Clingo

I’m making a puzzle level generator (sokoban) using Clingo and got stuck trying to create levels with a specific move limit. The idea is to use the move limit to control difficulty of a level. This is how I’ve created the generator: Specify rules…
jokke
  • 65
  • 6
1
vote
1 answer

append an atom with exisiting variables and create new set in clingo

I am totally new in asp, I am learning clingo and I have a problem with variables. I am working on graphs and paths in the graphs so I used a tuple such as g((1,2,3)). what I want is to add new node to the path in which the tuple sequence holds. for…
Ali Ghazi
  • 45
  • 7
1
vote
1 answer

Practical Advantages and Disadvantages of Answer Set Programming/Logic Programming

I've recently taken an interest in Logic Programming, and more specifically Answer-Set Programming with CLINGO, and was wondering what the general consensus on this paradigm is in practical terms. For example, most declarative programs, including…
1 2
3
10 11