Questions tagged [eclipse-clp]

ECLiPSe is a constraint logic programming system that works with Prolog as a basic engine. It includes modules for integer constraint logic programming as well as floating points. It also supports a large number of global constraints.

Books

A free downloadable pdf

A Gentle Guide to Constraint Logic Programming via ECLiPSe

78 questions
9
votes
3 answers

Example channelling constraints ECLiPSe

Can someone provide a simple example of channelling constraints? Channelling constraints are used to combine viewpoints of a constraint problem. Handbook of Constraint Programming gives a good explanation of how it works and why it can be…
Stanko
  • 3,209
  • 3
  • 16
  • 45
5
votes
1 answer

How to convert vectors to arrays in ECLiPSe (CLP)? (or Prolog)

I have to solve Sudoku puzzles in the format of a vector containing 9 vectors (of length 9 each). Seeing as vectors are linked lists in Prolog, I figured the search would go faster if I transformed the puzzles in a 2D array format first. Example…
Babyburger
  • 1,442
  • 1
  • 14
  • 27
4
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,512
  • 2
  • 16
  • 29
3
votes
1 answer

The difference between dollar sign ($) and number (or hash) sign (#) in Prolog

As I found I can use from $ and # in the shortened version of the suspend in Prolog. Hence, I can write the following query: ?- X $> 2, X = 2.5. And the result is: X = 2.5 Yes (0.11s cpu) So what is the difference between # and $ and why the…
OmG
  • 15,398
  • 7
  • 42
  • 71
3
votes
3 answers

How do I specify to Prolog that all the elements of a list have to be 1 or 0?

How do I make sure that all the elements of a prolog list are either 0 or 1? I need to generate a list of given length and make sure it has only these 2 numbers in it: E.g. [0,0,0,0,0,0], [1,0,0,1,0,1,1] etc I suppose the use of libraries…
Zap
  • 301
  • 2
  • 14
3
votes
1 answer

How do you check the elements of a submatrix in Prolog

I am trying to write a Shikaku solver in EclipsE Prolog. My contraints are defined as follow: solve(Problemname):- writeln("Start shikaku."), problem(Problemname, Width, Height, Hints), shikaku(Width, Height, Hints). shikaku(Width, Height, Hints):-…
JorenV
  • 352
  • 2
  • 15
3
votes
1 answer

An alldifferent for tuples

I'm trying to solve a sudoku with the viewpoint that every number has 9 positions. This is the representation for my sudoku: From the table you can read that number 5 has following positions (Row,Col) in the sudoku: (2,8),(4,2),(6,5). When I…
Stanko
  • 3,209
  • 3
  • 16
  • 45
3
votes
1 answer

Profiling ECLiPSe CLP?

I made two implementations to solve Shikaku puzzles. One uses Top,Left,Width and Height (TLWH) as parameters for each rectangle, the other Top,Left,Bottom,Right (TLBR). For some reason the one using TLBR is much faster, but I'm not really sure why.…
The Oddler
  • 5,718
  • 2
  • 40
  • 86
3
votes
1 answer

ECLiPSe CLP puzzle: perfect rectangle fitting

I'm working on a puzzle known as 'divide-by-box'. In essence, it's a form of perfect rectangle fitting, based on given clues. The rules are: Some grid cells contain numbers (this is known input data) The task is to partition the grid area into…
SND
  • 1,512
  • 2
  • 16
  • 29
3
votes
1 answer

Measuring execution time ECLiPSe CLP (or Prolog)

How do I measure the execution time of a method in ECLiPSe CLP? Currently, I have this: measure_traditional(Difficulty,Selection,Choice):- statistics(runtime, _), time(solve_traditional(Difficulty,Selection,Choice,_)), …
Babyburger
  • 1,442
  • 1
  • 14
  • 27
3
votes
2 answers

Whats wrong with this prolog optimization solution?

solve(Amounts) :- Total = 1505, Prices = [215, 275, 335, 355, 420, 580], length(Prices, N), length(Amounts, N), Amounts :: 0..Total//min(Prices), Amounts * Prices #= Total, labeling(Amounts).
AAAA
  • 33
  • 2
3
votes
1 answer

Exact solutions for lib(ic)

Using ECLiPSe Prolog's lib(ic) I stumbled upon the following problem from David H. Bailey, "Resolving numerical anomalies in scientific computation." which I was referred to by the Unum book. Actually, it is only part of it. First, let me formulate…
false
  • 10,182
  • 12
  • 93
  • 182
2
votes
1 answer

Is there any explicit support for modulo operation in eplex library

I am using eplex and ic library and trying to solve a problem. I see that the eplex and ic provide explicit support for addition,multiplication and subtraction but there is no support for modulo or division. More precisely, I have this code : …
learner
  • 21
  • 1
2
votes
1 answer

Internal workings of ic_global/occurrences/3

For the QuasiGroup completion problem I implemented two models. One of them is a model based on nothing but channeling constraints (based on a study by Dotu). The other one is a model based on the fact that every value needs to occur in ever…
2
votes
1 answer

Eclipse CLP labeling: exclude permutations

I am solving a scheduling problem (briefly described here: SWI Prolog CLP(FD) scheduling switched to ECLP). I am able to get some solution quickly, but now I want to incorporate some optimization task. A part of the problem/schedule row looks like…
Jan Drozen
  • 774
  • 2
  • 9
  • 22
1
2 3 4 5 6