171 questions
3
votes
1
answer
114
views
Clingo/Gringo: How to prevent meaningless variants from being grounded
I'm trying to solve time dependent ASP problem using Clingo (version 5.7.1). Imagine that some project can start any year (2025, 2026 or 2027), and depending on this, its value in a given year can be ...
0
votes
0
answers
56
views
I struggle understanding the "Powerset" Operator in the language clingo
First of all: how is the operator "{}" really called? The documentation ist not very good at answering this.
I call it powerset operator because it creates a powerset of all elements.
{ z(1)...
1
vote
1
answer
32
views
Fallback to default if an atom doesn't exist
Beginner to ASP here :)
I need to define a default value for an atom when it isn't provided in the input.
% creating rooms
cost(create(room(R)), W) :- room(R), roomDomainNew(R), roomCost(W).
Here, if ...
0
votes
1
answer
179
views
Clingo and or logical syntax error: unexpected !=
I develop an application in clingo and here is my code:
conflicting_hours(Course1, Section1, Room, Start1, Hour1) :-
occupies(Course1, Section1, Room, Start1, Hour1),
occupies(Course2, ...
0
votes
0
answers
166
views
Clingo constraint not working properly and being ignored
I have a Clingo program optimising parcel delivery, and there are 2 constraints to limit the weight and the volume a car can deliver respectively, however these constraints are not working.
...
2
votes
1
answer
368
views
Sudoku in Clingo
I am trying to write a sudoku in clingo to learn the syntax a bit more. The part that I am satisfied with correctly represents the column/row constraints:
subgrid_size(3).
number(1..S*S) :- ...
0
votes
2
answers
401
views
Show sorted predicates in Clingo
I have a predicate pred/2, how do I #show this predicate in the answer that is sorted by the first argument, given that the first argument will be numerical?
I couldn't find any relevant documentation ...
0
votes
1
answer
145
views
How to make a simple game simulation in clingo?
I’m new to clingo (answer set programming) and I’m stuck with a very simple problem.
I want to simulate a very simple behaviour:
A game board with two rows and three columns, and three tokens, placed ...
0
votes
1
answer
144
views
in clingo can I head start my optimization with an existing suboptimal answer set?
I want to run a clingo program containing an optimization. I already have a (suboptimal) model. Is there a way to "help" clingo with the existing model? I'm using the python api.
Minimal ...
0
votes
1
answer
202
views
Permutation of a list and absolute differences of its elements
I am trying to learn and understand Answer Set Programming with Clingo (https://potassco.org/clingo/run/).
Here is a task I am struggling with now:
Find the sequence s = (s1, s2, ..., sn) with the ...
1
vote
1
answer
415
views
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 code
node(1..5).
...
2
votes
1
answer
373
views
Calculating the distance between two nodes in a directed Graph
I'm currently learning answer set programming with clingo and I'm really struggling with calculating the distance between nodes in a directed graph.
I would know how to hardcode it for every distance ...
0
votes
2
answers
87
views
How can I take an arbitrary input as a variable in clingo(Answer set programming)?
For example, I input four node:
node(a). node(b). node(c). node(d).
Without no hard-code, how can I pick an arbitrary input as a variable.
I set a root(A)
I want root(A) equal to node(a)
2
votes
1
answer
800
views
Only compute/solve a specific rule in clingo
Warning: ASP newbie.
Let's assume we have this simple program:
% crime scene
% Facts
present(harry). % was present on the crime scene
present(sally).
present(mary).
motive(harry). % has a motive
...
0
votes
1
answer
140
views
Clingo ASP - Exchange Coin Problem How to sum the same numbers
Thats my task:
We have coins: 1 cent, 2 cents, 5 cents, 10 cents, 20 cents, 50 cents, 1 dollar and 2 dollars. How many ways can you get 2 dollars using anynumber of coins?
I accualy ended up with ...
0
votes
1
answer
337
views
remove a sub set from set in Clingo
I am new to Clingo and encountered a situation where I needed to remove a subset from the answer set. For example, I have p(1..9). and I want to remove p(5) from my answer set. How can I do it? ...
0
votes
1
answer
378
views
clingo return the max subset
I have the following code:
1{p(1..10)}10.
:- p(I*2).
and it shows 31 answers, But I just need the max subset p(1) p(3) p(5) p(7) p(9).
How can I do it?
1
vote
1
answer
465
views
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 ...
1
vote
1
answer
994
views
How to parse program parts in Clingo Python?
I'm trying to run the following Blockworld Planning Program in python:
#include <incmode>.
#program base.
% Define
location(table).
location(X) :- block(X).
holds(F,0) :- init(F).
#program ...
1
vote
1
answer
877
views
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, ...
-1
votes
1
answer
57
views
Passing a file to DLV in cmd
I have a program written in a text file and I want to execute this file using dlv in the command prompt, however it keeps returning this error:
heba.txt: line 0: can't open input.
Any idea how to ...
2
votes
1
answer
1k
views
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 ...
1
vote
1
answer
465
views
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).
...
0
votes
1
answer
168
views
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 ...
1
vote
1
answer
561
views
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 ...