clpfd Questions

3

Solved

I can make lists of ascending integer like so: ?- findall(L,between(1,5,L),List). I know I can also generate values using: ?- length(_,X). But I don't think I can use this in a findall, as th...
Nystatin asked 16/9, 2015 at 14:17

6

I already made a working generalized verbal arithmetic solver in Prolog but it's too slow. It takes 8 minutes just to run the simple expression S E N D + M O R E = M O N E Y. Can someone help me ma...
Amputee asked 7/6, 2012 at 3:24

4

Solved

While reading SICP I came across logic programming chapter 4.4. Then I started looking into the Prolog programming language and tried to understand some simple assignments in Prolog. I found that P...
Sillimanite asked 24/5, 2010 at 11:46

4

Solved

This is the problem in short: 16 children are to be seated in a 4 x 4 array of chairs. The children are 8 girls (numbered 1..8) and 8 boys (numbered 9..16). 1,3,5,8 think boys are yucky 9,10,11,14...
Richy asked 3/7, 2015 at 18:14

2

Solved

I'm trying to understand how Prolog works. I'm using SWI-Prolog. Here's a bit of code: forall(C1,C2) :- \+ (C1, \+ C2). foo(N) :- N < 10. bar(N) :- N > 5. foobar(N) :- forall(foo(N),bar(N...
Portative asked 18/3, 2015 at 19:6

3

In CLP(FD), we frequently need to state: "This is a list of integers and finite domain variables in (sometimes: strictly) ascending/descending order." Is there any CLP(FD) system that provides a g...
Hypogeum asked 18/11, 2014 at 9:26

2

Solved

I'm trying to create a list in Prolog (SWI Prolog) and check which numbers are powers of 2 and second find how many times a specific number is in the list (in this example I'm trying to find how ma...
Anvil asked 3/2, 2014 at 1:38

4

Solved

I've been trying to create a predicate in Prolog which splits a list of integers into a list of positive integers and into a list of negative integers. Sample query with expected result: ?- split...
Likable asked 3/3, 2012 at 14:56

2

Solved

I'm new to prolog and I'm doing some exercises for practice. So I'm trying to get the sum of the given numbers in a list. I'm trying to use this: my_last(X, [X]). my_last(X, [_|L]) :- my_last(X, ...
Mimesis asked 17/7, 2012 at 10:28

3

Solved

I am trying to write a Prolog (CLP) predicate that would build a constraint constraining inequality of two lists. More formally, having two lists A=[A1,...,AN], B=[B1,...,BN] the constraint is def...
Olivas asked 22/12, 2012 at 10:42

4

Solved

:- use_module(library(clpfd)). % load constraint library % [constraint] Compute a list of distinct odd numbers (if one exists), such that their sum is equal to a given number. odd(Num) :- Num mod...
Tirade asked 23/11, 2009 at 22:3

3

Solved

I am developing a program in PROLOG (with restrictions) which is supposed to output a combination of 6 numbers within certain restrictions. The list must have the numbers from 1 to 4 and will, con...
Ferritin asked 12/12, 2014 at 18:52

2

Solved

Given the following sample of code: example(Ls) :- Ls = [X,Y], Ls ins 1..2, Cost #= max((X #= 1)*3 + (Y #= 1)*5, (X #= 2)*3 + (Y #= 2)*5), labeling([minimize(Cost)], Ls). The idea is to fin...
Breeden asked 12/1, 2014 at 13:40

6

Solved

min_member(-Min, +List) True when Min is the smallest member in the standard order of terms. Fails if List is empty. ?- min_member(3, [1,2,X]). X = 3. The explanation is of course that variable...
Girt asked 9/12, 2014 at 8:54

2

Solved

I went through the manual and documentation but still don't understand. I'm trying to implement a sudoku solution where after writing out all the other rules of the game, I've added label(Board) ac...
Shrivel asked 30/11, 2014 at 17:48

2

Solved

I'm attempting project scheduling with SWI prolog and CLP. I managed to support sequential dependencies but I'm struggling with avoiding double booking people. I have a list called Schedule conta...

3

Solved

I am doing this problem but I am completely new to Prolog and I have no idea how to do it. Nine parts of an electronic board have square shape, the same size and each edge of every part is marked ...
Nonintervention asked 11/11, 2014 at 3:25

1

Solved

As a basic Prolog exercise, I set myself the task of writing a binary tree height predicate that would work forwards and "backwards" - that is, as well as determining the height of a known binary t...
Hoogh asked 22/9, 2014 at 4:48

1

Solved

There are many families of scheduling problems. I'm looking into a problem where I have families of jobs/tasks where the transition from one family to another family require reconfiguring the machi...

1

Solved

If I have A in 0..4, A * A #=A. Is it possible that A in 0..1. ? I would say no because 0*0 = 0, and 1*1 = 1, so these two can not be A? Thank you in advance.
Aurelio asked 17/5, 2014 at 18:11

2

Solved

I'm working on a problem where I use the cumulatives/[2,3] predicate. But I get very bad performance when I try to combine this with minimize in labeling I have the following demo. 10 task, all wi...
Mcandrew asked 14/5, 2014 at 8:35

1

I'm trying to solve a CSP where I need to distribute cocktails over bartenders so that each bartender has at most one cocktail and all cocktails are given a bartender. I solved it by creating a lis...
Huang asked 23/3, 2014 at 16:32

2

Solved

I'm working on some experiments for comparing different labeling heuristics in Sicstus Prolog. But I keep getting into 'Resource error: insufficient memory'. I'm pretty sure I'm doing something w...
Aleutian asked 10/2, 2014 at 19:45

3

Solved

The term fib(N,F) is true when F is the Nth Fibonacci number. The following Prolog code is generally working for me: :-use_module(library(clpfd)). fib(0,0). fib(1,1). fib(N,F) :- N #> 1, N...
Klos asked 19/1, 2014 at 11:24

2

I'm trying to write reversible relations in "pure" Prolog (no is, cut, or similar stuff. Yes it's homework), and I must admit I don't have a clue how. I don't see any process to create such a thing...
Jollification asked 30/12, 2012 at 23:30

© 2022 - 2024 — McMap. All rights reserved.