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
0
votes
1 answer

Find lowest element of predicates of the size 2 and ensure that there is only one lowest element?

I am working on a piece of encoding that finds the cell with the lowest coordinates in a grid. This cell will be used as a starting point for a path. Cells are defined with predicate cell(X,Y). isLower(X,Y,F,G) :- cell(X,Y), cell(F,G), X<=F, Y<=G. …
PyDev
  • 91
  • 1
  • 5
0
votes
1 answer

Is it possible to not use cardinality constraint to generate solution candidates in clingo?

I'm learning Answer Set Programming by solving the zebra puzzle. I found some solution examples online. But someone told me that I can solve the puzzle without using cardinality constraint macro to generate solution Candidates. Like without using…
AmuMa
  • 1
  • 1
0
votes
1 answer

Clingo: Operation undefined while doing computations inside the testing rules

I am new to ASP programming and finding it a bit hard to understand how ASP works. I am using clingo tool for ASP coding. Currently, I am working on a seating arrangement problem. The original problem is a bit complicated as it involves lots of…
0
votes
1 answer

Clingo: How to do "If p causes UNSAT then q."

In the code below % Facts a. % Rules -a :- a, not not p. Adding the fact p. to the above would cause it to be UNSAT. Is there a way in clingo to add a rule to show this? Something like q :- Assuming p causes UNSAT. Solutions like adding the…
abyyskit
  • 3
  • 3
0
votes
1 answer

Clingo: Can I match multiple variables (sorta like varargs)?

I am looking for something like this: g(X, ...Y) :- f(X, ...Y) . which will be a syntactic sugar for: g(X, Y) :- f(X, Y) . g(X, Y, Z) :- f(X, Y, Z) . g(X, Y, Z, Z1) :- f(X, Y, Z, Z1) . %...and so on is there any way to provide some such syntactic…
Sid Datta
  • 1,110
  • 2
  • 13
  • 29
0
votes
2 answers

Solver: OR-Tools or clingo(ASP) model for "simple" logical problem

I try to solve a "simple" logical problem with OR-Tools or clingo(ASP). It goes like this: I have a set of Persons like Person(Tony, Bob, Ann, Carl, Amber, Peter) I also have groups like Group1(Bob, Ann, Carl, Amber, Peter), Group2(Bob, Amber), and…
jmlots
  • 25
  • 6
0
votes
1 answer

Reducing the search space efficiently in clingo

I am struggling to scale a constraint problem (it breaks down for large values and / or if I try to optimise instead of just looking for any solution). I've taken some steps to break the search space down based on advice from some previous questions…
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
0
votes
1 answer

Shorthand for multiple choice predicates in clingo

Right now I have a single choice predicate that defines my search space. #const nRounds = 3. #const nPlayers = 17. #const nSeats = nRounds * nPlayers. #const nRooms = 3. #const nDecks = 6. nSeats { seat(1..nPlayers, 1..nRooms, 1..nDecks) }…
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
0
votes
1 answer

Removing a1 field from chess board in Clingo knight path program

I need to do some symulations about knight path and Hamilton cycle on chesseboard, but i wondering what if i exclude some fields from chesseboard xchessboard(1..8). ychessboard(1..8). time(1..8*8+1). xypos(X,Y) :- xchessboard(X),…
0
votes
1 answer

How to find second last value in Answer Set Programming (ASP Clingo)

I'm modelling a university curriculum timetable with Answer Set Programming (Clingo). The requirements are that each lesson must be asssigned to a specific week , day and start /end hours until the total hours are reached. In a day there are max 8…
0
votes
1 answer

Clingo program expected to be satisfiable

I am testing some programs involving arithmetics in Clingo 5.0.0 and I don't understand why the below program is unsatisfiable: #const v = 1. a(object1). a(object2). b(object3). value(object1,object2,object3) = "1.5". value(X,Y,Z) > v, a(X), a(Y),…
Olivier
  • 33
  • 1
  • 8
0
votes
2 answers

Riddle puzzle in clingo

So in the tag prolog someone wanted to solve the "the giant cat army riddle" by Dan Finkel (see video / Link for description of the puzzle). Since I want to improve in answer set programming I hereby challenge you to solve the puzzle more efficient…
DuDa
  • 3,718
  • 4
  • 16
  • 36
0
votes
0 answers

sbass unable to read gringo output

I'm running a simple ASP program: %Defining possible states of each of the rook space occupied(t; f). %Generate all possible grids {rook(X, Y, D) : occupied(D)} = 1 :- X=2..x, Y=2..y. %Bound the grid with empty space rook(X, Y, f) :- X=0,…
0
votes
1 answer

Is there a method to represent arbitrary length tuple in Clingo?

If I wanna get the head of an arbitrary length tuple, I have to code like: head(A) :- tuple(A,B). head(A) :- tuple(A,B,C). head(A) :- tuple(A,B,C,D). ....... Is there a method could represent head(A) :- tuple(A...). Thanks!
0
votes
1 answer

How to define OR condition in Clingo

I'm new to Clingo. I want to know how to express an OR condition inside a count aggregate. I'm writing this rule. countPreviousSlots(C1, C2, TotalCount) :- firstLecture(C2, S2, G2, I2), TotalCount = #count{S1,G1,I1 : slot(S1, G1, I1, C1),…
Alfabrick12
  • 5
  • 1
  • 5