Questions tagged [clpr]

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).

15 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,665
  • 6
  • 41
  • 88
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
  • 2,871
  • 1
  • 20
  • 27
4
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
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
  • 22,919
  • 16
  • 101
  • 195
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
3
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
  • 6,681
  • 7
  • 26
  • 42
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
  • 263
  • 1
  • 3
  • 15
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
  • 3,922
  • 5
  • 30
  • 49
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…
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
  • 3,922
  • 5
  • 30
  • 49
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…
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
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
  • 2,618
  • 2
  • 21
  • 33
0
votes
1 answer

Inequality solving using Prolog

I am working on solving inequality problems using prolog.I have found a code and it solves ax+b>=0 type equations. The code I have used is as follows. :-use_module(library(clpr)). dec_inc(left,right):- …
ict
  • 105
  • 1
  • 5