clingo

Newbie questions on Answer Set Programming

放肆的年华 提交于 2021-02-19 23:45:44
问题 I'm totally new to Clingo (and logic programming) and I'm looking for the best way to implement the following basic constraints: Q1. I have a predicate selected(T) where T ranges from 1 to N=5; how can I specify that exist at least one T such that selected(T) ? Q2. I have a binary predicate wrap(E,T) where E, T range from 1 to M, N; how can I specify that for each E exist at least one T such that wrap(E,T) ? Q3. How can I specify that if selected(a) OR selected(b) then selected(c) must be

Newbie questions on Answer Set Programming

时间秒杀一切 提交于 2021-02-19 23:42:38
问题 I'm totally new to Clingo (and logic programming) and I'm looking for the best way to implement the following basic constraints: Q1. I have a predicate selected(T) where T ranges from 1 to N=5; how can I specify that exist at least one T such that selected(T) ? Q2. I have a binary predicate wrap(E,T) where E, T range from 1 to M, N; how can I specify that for each E exist at least one T such that wrap(E,T) ? Q3. How can I specify that if selected(a) OR selected(b) then selected(c) must be

Brave/Cautious reasoning in clingo

*爱你&永不变心* 提交于 2021-01-29 04:29:58
问题 In Clingo guide, there are two modes called cautious and brave introduced as the follows: brave Compute the brave consequences (union of all answer sets) of a logic program. cautious Compute the cautious consequences (intersection of all answer sets) of a logic program. No more information is provided in the guide. I tried some examples and have trouble understanding the issue. I tried to run the following simple ASP program: p :- not q. q :- not p. Running Clingo with no mode parameter will

Murder puzzle in ASP

痞子三分冷 提交于 2021-01-01 06:35:10
问题 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 myself, and I would be happy to compare my code with yours. Thank you. jean was killed on Tuesday; the only suspects are: Luc, Paul, Alain, Bernard and Louis. The rules to follow are: The murderer is somebody who has a motive to kill jean, who owns

Murder puzzle in ASP

女生的网名这么多〃 提交于 2021-01-01 06:33:49
问题 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 myself, and I would be happy to compare my code with yours. Thank you. jean was killed on Tuesday; the only suspects are: Luc, Paul, Alain, Bernard and Louis. The rules to follow are: The murderer is somebody who has a motive to kill jean, who owns

How do I extract the trees from a graph using Answer Set Programming?

℡╲_俬逩灬. 提交于 2020-12-13 03:27:15
问题 There is an undirected graph (V,E), weights on the edges w : E → N, a target k ∈ N, and a threshold O ∈ N. Find a k-vertices tree of the graph of weight less than the threshold. In other words, select k vertices and k - 1 edges from V and E respectively such that they constitute a tree, and the sum of the weights of the selected edges are less than O. Write an ASP program that takes V , E, w, k, and O as input, and finds a selection of edges satisfying the constraints, or outputs

How do I extract the trees from a graph using Answer Set Programming?

岁酱吖の 提交于 2020-12-13 03:26:32
问题 There is an undirected graph (V,E), weights on the edges w : E → N, a target k ∈ N, and a threshold O ∈ N. Find a k-vertices tree of the graph of weight less than the threshold. In other words, select k vertices and k - 1 edges from V and E respectively such that they constitute a tree, and the sum of the weights of the selected edges are less than O. Write an ASP program that takes V , E, w, k, and O as input, and finds a selection of edges satisfying the constraints, or outputs

ununderstandable behavior subprocess.Popen(cmd,stdout) and os.system(cmd)

拟墨画扇 提交于 2020-01-06 09:03:29
问题 I use an external command inside a python script using firstly: subprocess.Popen(cmd, stdout=subprocess.PIPE) then i get the stdout. The problem is that the result of this external command when executing it inside the script is not the same if i execute it directly in the command line. I use then os.system(cmd) , but the same problem. Is this instructions in python use some buffers? How can i explain the difference between the two results (command line and inside the script). I'm using this

ununderstandable behavior subprocess.Popen(cmd,stdout) and os.system(cmd)

 ̄綄美尐妖づ 提交于 2020-01-06 09:02:35
问题 I use an external command inside a python script using firstly: subprocess.Popen(cmd, stdout=subprocess.PIPE) then i get the stdout. The problem is that the result of this external command when executing it inside the script is not the same if i execute it directly in the command line. I use then os.system(cmd) , but the same problem. Is this instructions in python use some buffers? How can i explain the difference between the two results (command line and inside the script). I'm using this

Clingo: assert partial constraints

一曲冷凌霜 提交于 2019-12-12 01:23:52
问题 I am trying to implement a program in clingo that solves one of those classic riddles where you have a series of assertions of facts and constraints and you have to deduce other facts. Here goes the problem: Five men of different nationalities live in five side-by-side houses, each of a different color; they all have different jobs, a different favourite animal and favourite beverages. We know that: The English man lives in the red house. The Spanish man's favourite animal is the dog. The