CLP(R) (Constraint Logic Programming over the Reals) is a constraint solver over the reals. It uses most often floating-point values as an approximation. In many Prolog systems it is hosted as library(clpr).
Questions tagged [clpr]
16 questions
8
votes
1 answer
Solving a simple geometric puzzle in CLPQ/R (Prolog)
Consider the following square:
You are given three constraints:
All rectangles (A, B, C, D and E) have the same area;
Their geometric layout constitutes a square; and
The height of A is 2.
Now, I know this is very simple to solve by hand, but I…

Hugo Sereno Ferreira
- 8,600
- 7
- 46
- 92
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
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
Order of unknowns in Prolog constraint logic programming (clpr)
I have:
:-use_module(library(clpr)).
comp(X, Y, Z):-
{X = Y * Z, Y = Z, Y > 0, Z > 0}.
Which with the query:
?-comp(X,3,Z).
Yields:
X = 9.0,
Z = 3.0
as expected. But why doesn't
comp(9,Y,Z).
also give me values for Y and Z? What I get is…
user3170496
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,264
- 13
- 101
- 209
2
votes
1 answer
Accessing coefficients in a numerical expression (clpr)
I have some clauses where the head represents the names and values of a set of variables in a linear equation and the body the actual equation. Like so:
:-use_module(library(clpr)).
relation(
independents([
var(x1, X1),
…
user3170496
2
votes
1 answer
How to interface Prolog CLP(R) with real vectors?
I'm using Prolog to solve simple geometrical equations.
For example, I can define all points p3 on a line passing trough two points p1 and p2 as:
line((X1, Y1, Z1), (X2, Y2, Z2), T, (X3, Y3, Z3)) :-
{(X2 - X1) * T = X3},
{(Y2 -…

yawn
- 422
- 1
- 5
- 21
2
votes
1 answer
Arguments are not sufficiently instantiated in prolog
I'm trying to run this code but I get this error anytime I use this query: gp174(P, S).
ERROR: >=/2: Arguments are not sufficiently instantiated.
and this is my code:
call_option(B,S,C,E,P) :-
0 =< S,
S =< E / 100,
P = -C *…

Ali_IT
- 7,551
- 8
- 28
- 44
1
vote
1 answer
SWI Prolog, CLP(R): Can I bind a constraint to a variable?
Or can a constraint variable be bound to another variable (see the example below)?
?- use_module(library(clpr)).
true.
% this works
?- {X >= 5.0, X =< 10.0}, minimize(X).
X = 5.0 .
% but I do not know why this fails
?- C = {X >= 5.0, X =< 10.0},…

Michael
- 4,722
- 6
- 37
- 58
1
vote
0 answers
SWI-PROLOG How to use library(clpqr) solver predicates
I am failing with using the predicates from the library CLPQR in SWI-Prolog. The library itself works. Expressions like "clpq: {X = 5^2}" are solved correctly. But I can't figure out how to use "minimize", "maximize", "inf", "sup", etc.
Link to the…

MisterMirko
- 23
- 3
1
vote
1 answer
SWI-Prolog: How to write a solution to the command line output?
I am using SWI-Prolog with the clpr library for solving constraints over real numbers. I do this by calling SWI-Prolog from the command line and parsing the output by another program.
For example, to solve something like {F = 1.8 * C + 32}, {C =…

Michael
- 4,722
- 6
- 37
- 58
1
vote
2 answers
XSB Prolog meta-interpreter issue with clpr constraints
I am running XSB Prolog on my Mac (El Capitan 10.11.2):
XSB Version 3.6. (Gazpatcho) of April 22, 2015
[i386-apple-darwin15.2.0 64 bits; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2016-01-17]
I am using the clpr package and want…

Vijay Saraswat
- 41
- 3
1
vote
0 answers
Writing CLPR output to console
I'm a very beginner to Prolog. I want to modify the code to write the output to the console.
How can I write the output of this program to the console?
%
% from file: library('clpqr/examples/elimination')
%
conv(Points, Xs) :-
lin_comb(Points,…

MarkiE
- 11
- 2
0
votes
1 answer
SWI Prolog - CLP(R) not propagating fully
This gives me a result:
?- {5/(X) = (5/2)}.
X = 2.0 ;
This shows me a constraint, but doesn't let me use X in any material way:
?- {5/(3-X) = (5/2)}.
{-2.5+5/(3-X)=0.0}.
?- {5/(3-X) = (5/2)}, Z is X.
ERROR: Arguments are not sufficiently…

Name McChange
- 2,750
- 5
- 27
- 46
0
votes
2 answers
minimize/1 is not rearranging the order of solutions
For Colombia's Observatorio Fiscal[1], I am coding a simple tax minimization problem, using CLP(R) (in SWI-Prolog). I want to use minimize/1 to find the least solution first. It is instead listing the bigger solution first. Here is the code:
:-…

Jeffrey Benjamin Brown
- 3,427
- 2
- 28
- 40