Questions tagged [clp]

Constraint logic programming is a programming paradigm that combines features of logic programming and constraint programming. As in regular logic programming, programs are queried about the provability of a goal, which may contain constraints in addition to literals.

67 questions
10
votes
1 answer

SWI Prolog vs. GNU Prolog - CLP(FD) issues under SWI

I wrote a quick predicate in Prolog trying out CLP(FD) and its ability to solve systems of equations. problem(A, B) :- A-B #= 320, A #= 21*B. When I call it in SWI, I get: ?- problem(A,B). 320+B#=A, 21*B#=A. Whereas in GNU, I get the…
Name McChange
  • 2,750
  • 5
  • 27
  • 46
7
votes
1 answer

How to validate commutativity involving the dif/2 constraint?

There is a lot of hype around the dif/2 constraint, especially as a rescue for some non-declarativity of (\=)/2 and (\==)/2. This non-declarativity is often characterized as non-monotonicity and examples of non-communtativity are given. But what…
user502187
5
votes
1 answer

Using Prolog & CLP(R) for a system of constraints

I'm looking to use Prolog to generate a random vector that satisfies a system of constraints. As an example, our user might provide our software with the following information at runtime: Given a vector , we might have two…
Groostav
  • 3,170
  • 1
  • 23
  • 27
4
votes
2 answers

Variable bin packing problem with Prolog (CLP)

I am trying to find an algorithm for the NP-hard 2D Variable Size Bin Packing Problem (2DVSBPP) in (Swi-)Prolog using Constraint Logic Programming (CLP). The problem could be explained like this: some ordered Products need to be packed as…
ebeo
  • 83
  • 6
4
votes
1 answer

Verify_attributes in SICStus Prolog

Attribute variables permit to extend unification. The following is about arcane details of the interface. Let's cut right to the chase! In sicstus-prolog library(atts) provides predicates for using attributed variables. I think I get what the…
repeat
  • 18,496
  • 4
  • 54
  • 166
4
votes
2 answers

CLP: Constraints on structured variables?

Lets have the following hypothetical scenario ... a grid with 5x5 and let say 3 figures. We want to define constraint on the positions. In CLP we normally define the constraints with integers, so this is one way of doing it : ... Fig1X #\= 2,…
sten
  • 7,028
  • 9
  • 41
  • 63
4
votes
1 answer

Correct way of writing recursive functions in CLP(R) with Prolog

I am very confused in how CLP works in Prolog. Not only do I find it hard to see the benefits (I do see it in specific cases but find it hard to generalise those) but more importantly, I can hardly make up how to correctly write a recursive…
Bram Vanroy
  • 27,032
  • 24
  • 137
  • 239
3
votes
2 answers

How to pass java primitive arrays to a C dll using JNA?

When mapping java code to a DLL using JNA, how should one pass/use a java array (int[], double[]) in a C call when the C's function argument is a pointer? I am facing a bug, and I think it is somewhere in my mapping of arrays to C. What I tried:…
simon
  • 77
  • 7
3
votes
2 answers

In writing a purely relational prolog program, is it ok to use a carefully placed cut?

I am trying my hand in writing a relational prolog program that manages a key, value store. The initial code is taken from some lecture slides i found on the internet (http://people.eng.unimelb.edu.au/pstuckey/book/course.html -- see: using data…
user2193970
  • 345
  • 2
  • 10
3
votes
1 answer

CLP(B) weighted sat_count/3 in Prolog

For the CLP(B) library of SWI-Prolog, I want to implement a weighted version of sat_count/2 sat_count(Sat0, N) :- catch((parse_sat(Sat0, Sat), sat_bdd(Sat, BDD), sat_roots(Sat, Roots), …
GinoC
  • 442
  • 4
  • 16
3
votes
2 answers

How to make path restrictions using Prolog CLP FD?

I'm trying to use restrictions programming through Prolog CLP FD to solve a puzzle that was proposed. This puzzle consists in the next simple rules: Now, in my code, I already cover the restrictions for the 2x2 grid AND that one piece MUST be…
josealeixo.pc
  • 391
  • 3
  • 13
3
votes
1 answer

3-in-a-row logic puzzle: optimisation for sequence constraints in lists/arrays

In the following puzzle we try and fill the grid with blue and white squares in such a way that: A 3-in-a-row (or column) of the same colour is not allowed. Each row and column has an equal number of blue and white squares. If we now represent…
SND
  • 1,552
  • 2
  • 16
  • 29
3
votes
0 answers

Best tool for a beginner in Constraint Logic Programming

I need to create a prototype application for production order scheduling for my university. I am still new to the topic of CLP and I am looking for an easy tool/environment/system that will let me define logic for few machines (i.e. 5-10) with their…
siobchan
  • 59
  • 4
3
votes
2 answers

Contraint Logic Programming Scheduling

I'm trying to solve a problem using clp in prolog. The problem is as follows: Basically a ship is carrying a number of containers and we want to unload them. The containers is described as predicates container(I,N,D), where I is the containers…
PB101
  • 142
  • 4
3
votes
2 answers

Solve Instant Insanity in PROLOG with CLP

This is the game I've managed to generate the problem with 4 colours and 4 cubes randomly mixed and following the colour scheme suggested in the link. So, the goal is to generate the possible solutions to the problem using clpfd. The main principle…
Joao Pereira
  • 573
  • 4
  • 16
1
2 3 4 5