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 parse program parts in Clingo Python?

I'm trying to run the following Blockworld Planning Program in python: #include . #program base. % Define location(table). location(X) :- block(X). holds(F,0) :- init(F). #program step(t). % Generate { move(X,Y,t) : block(X), location(Y),…
thesofakillers
  • 290
  • 3
  • 13
1
vote
1 answer

How to create an optimal serializable plan in clingo?

I have the following blocks world program and I want to create a serializable plan for the following scenario: Initially: loc(m)=table, loc(l)=m, loc(a)=l, loc(b)=a, loc(c)=b, loc(o)=table, loc(n)=o, loc(d)=n, loc(e)=d, loc(j)=e, loc(k)=j,…
user11665646
1
vote
1 answer

Negative optimization result in Answer Set Programming

I have written an ASP program with an optimization condition in the end. When I compile it, even though I get the correct result, in the summary I get a negative value for the optimization (i.e. -3). Do you know why this happens? The optimization…
1
vote
1 answer

Spanning Trees in Answer Set Programming

For the undirected graph described below, I am trying to get its spanning trees and then separate its leaves from the internal nodes. Could you please help me with my code ? What I expect to see after running the code is something like : Answer 1 :…
1
vote
1 answer

ASP Core-2: Infinite Loop in Hamiltonian Path Solver

I am totally new in answer set proramming (ASP Core-2 with Clingo) and am struggling with a problem I have not been able to solve. The goal is to solve the 'Hamiltonian Path' problem, which is described as follows: In a directed graph we're looking…
BenjyTec
  • 1,719
  • 2
  • 12
  • 22
1
vote
1 answer

Answer Set Programming - filtering from a large number of models

instance.lp node(1). node(2). node(3). node(4). node(5). node(6). edge(1,2). edge(2,1). edge(4,1). edge(2,3). edge(2,6). edge(3,4). edge(3,5). edge(5,6). edge(6,3). begin(4). I have this problem instance, directed graph with a beginning node…
cheshire
  • 1,109
  • 3
  • 15
  • 37
1
vote
1 answer

Newbie question about the difference between integrity constraints and choice rules in ASP/Clingo?

#const w = 2. #const h = 1. % Create a grid wxh row(1..h). col(1..w). % Generate % {} below indicates all rooms need not exist in the solution. % There can be 1x1 rooms, that can be placed anywhere on the grid. {room11(X, Y) : col(X), row(Y) }. %…
Sid Datta
  • 1,110
  • 2
  • 13
  • 29
1
vote
1 answer

Why the disjunctive ASP program cannot return both disjunct predicates instance in an answer?

I am a newbie to ASP (Answer Set Programming). I tried the following program in clingo online version (reasoning mode = enumerate all) % instance member(dave). % encoding edu(X);rich(X) :- member(X). It returns: Answer: 1 member(dave)…
chansey
  • 1,266
  • 9
  • 20
1
vote
1 answer

How to actually check for model proven optimality with Potassco clingo python API?

I have the following code: from clingo import Control def on_model(m): print(m, m.optimality_proven) ctl = Control(["0"]) ctl.add("base", (), "0 { a } 1. :~ a. [-1@0]") ctl.ground([("base", ())]) solution = ctl.solve(on_model=on_model) assert…
user1747134
  • 2,374
  • 1
  • 19
  • 26
1
vote
1 answer

How to replace constants terms from python API in clingo / gringo?

Suppose I have a the following file foo.lp: foo(x). Now when I run gringo -t -c x=1 foo.lp I obviously get: foo(1). Now I want to know how to achieve the same behavior as the -c command line option from the Python API, like when I have: from…
user1747134
  • 2,374
  • 1
  • 19
  • 26
1
vote
1 answer

Clingo: operation undefined

Adding the following rule to my code results in an error message (info: operation undefined (Max-Min)): rank_difference(Room, Deck, Diff) :- played(Room, Deck), Min = #min {Rank: seat(Player, Room, Deck), rank(Player, Rank)}, Max = #max…
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
1
vote
3 answers

Maximize the interval in clingo

I have the following clingo code that generates the search space, followed by constraints. {in(I,1..4)}=1 :- I=1..n. :- [constraint1] :- [constraint2] This code works. But I need clingo to find the largest value of n for which a stable model…
Saqib Ali
  • 3,953
  • 10
  • 55
  • 100
1
vote
1 answer

How to replace choicerule to reduce "meaningless" answers that kill grounding process using asp (clingo)

I'm currently working on an answer set program to create a timetable for a school. The rule base I use looks similar to this: teacher(a). teacher(b). teacher(c). teacher(d). teacher(e).…
Spiderwick
  • 13
  • 3
1
vote
2 answers

Murder puzzle in ASP

So under the tag prolog I found this puzzle (original post) and I thought: this would be even better in ASP. So I put this here as a question for anyone who wants to solve a puzzle with me. I will answer this question as soon as I found a solution…
DuDa
  • 3,718
  • 4
  • 16
  • 36
1
vote
1 answer

ASP Clingo - getting the exact count of atoms

I'm looking forward to assign a specific count of persons to a specific shift. For example I got six persons and three different shifts. Now I have to assign exact two persons to every shift. I tried something like this but.. NOTE: this won't work,…
kaiserm99
  • 146
  • 8