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
1
vote
1 answer

How to check for membership in a list in CLINGO?

Having a background in Prolog, I'm struggling to convert this DLV (which has builtin predicates to handle lists similarly to Prolog) program into CLINGO. path(X,Y,[X|[Y]]) :- rel(X,Y). path(X,Y,[X|T]) :- rel(X,Z), path(Z,Y,T), not…
1
vote
1 answer

How do I encode this in answer set programming?

I am a total newbie to answer set programming, and I am struggling with a rather simple question. The program needs to be written in clingo. So here is the question: An abstract argumentation framework consists of a set A of arguments and an attack…
weak_at_math
  • 105
  • 7
1
vote
1 answer

Travelling Salesman Problem with Time Windows

I'm trying to solve TSP problem with additional constraint - time windows. All the standard assumptions apply: We start and end at given city. Each city is visited only once. We try to find the optimal path in terms of travel cost (here travel…
1
vote
1 answer

Clingo answer set programming line intersection

I have a rule that generates the following route(5,1,5,3) route(5,2,5,3) route(5,3,5,3) route(3,1,3,1) route(2,3,5,3) route(3,3,5,3) route(4,3,5,3) route(4,1,3,1) route(5,1,3,1) route(3,2,3,1) route(3,3,3,1) route(3,4,3,1)…
NTP
  • 4,338
  • 3
  • 16
  • 24
1
vote
2 answers

How do I tell my graph coloring problem program to only assign color 1 one time?

Basically, I have a graph coloring program where each node with an edge to another node has to be different colors. Here, is my code: node(1..4). edge(1,2). edge(2,3). edge(3,4). edge(4,1). edge(2,4). color(1..3). { assign(N,C) : color(C) } =…
1
vote
0 answers

I have what appears to be functioning ASP code but it is returning no answer set?

I am attempting to solve a Binary sudoku puzzle with Answer Set Programming, Clingo, and MKAtoms. I have a working set of code, but it is not returning any answer sets. I have reviewed the code but am unsure of the problem. % Binary Sudoku solver:…
Cody West
  • 11
  • 1
1
vote
1 answer

How do I generate a fixed sized list of facts (duplicates included)?

I'm new to ASP & Clingo and I need to work on a project for school. I thought about some basic music generator. For now, I need to generate notes (I'm sticking with C major for now). I also want to generate them randomly and I don't know how to do…
user10778456
1
vote
1 answer

Cannot understand cardinality constraint in clingo

I have the graph coloring problem defined in Clingo as so: node(sa;wa;nt;q;nsw;v;t). color(r;g;b). edge(sa,(wa;nt;q;nsw;v)). edge(wa,nt). edge(nt,q). edge(q,nsw). edge(nsw,v). edge(X,Y) :- edge(Y,X). and I have the solution characterized like…
1
vote
1 answer

lparse/clingo: How to say AllOf(a,b,c) :- condition?

The following makes one or more literals true: a,b,c :- condition. a;b;c :- condition. In the above a,b,c,condition is a valid model, but also (a,condition), (a,b,condition), etc. I want all of a, b, c to be true, always, if condition is true. I…
Sid Datta
  • 1,110
  • 2
  • 13
  • 29
1
vote
1 answer

Room coverage in Answer Set Programming

I'm currently developing an Answer Set Programming problem, consisting in a robot that is needed to cover a room avoiding obstacles and reach a Goal point when all the room is covered. My idea was to transform the room map into asp predicates,in the…
wizenink
  • 11
  • 2
1
vote
1 answer

Ontology using description logic

I wonder how can we make an ontology using Description logic syntax (A-box, T-box) for a staff of a university? What classes, objects, relations, parents, siblings, constraints and interrelationships among them we can make? I made the below class…
1
vote
1 answer

clingo apply a variable range

I do not know much about clingo, i hope i can share the problem clearly. Currently i've cellUseCount(X,Y,C) :- C = #count{cell(X,Y)}, target(X,Y,XX,YY). which returns results for each X,Y value. How can i get for X-XX and Y-YY range. For instance:…
Dilara Albayrak
  • 314
  • 1
  • 3
  • 23
1
vote
1 answer

How to forbid grounding of false facts in Answer Set Programming/Gringo

When I run gringo on my program, it results into many grounded statements of the form :- foo(a,b). Then I also obtain many grounded constraints such as: :- bar(a,x,y), foo(a,b). Given the knowledge above, these are totally useless. Note, these are…
user1747134
  • 2,374
  • 1
  • 19
  • 26
1
vote
2 answers

Answer Set Programming - make a FACT invalid

I have a question regarding Answer Set Programming on how to make an existing fact invalid, when there is already (also) a default statement present in the Knowledge Base. For example, there are two persons seby and andy, one of them is able to…
1
vote
1 answer

How to sum in Clingo?

I have the following dataset: food_a(bagel, 245). food_a(sandwich, 200). food_a(salad,300). food(bagel). food(sandwich). food(salad). I want to satisfy the following constraint: Given a total calorie count, I want to return the food items that…
tortuga
  • 737
  • 2
  • 13
  • 34