# clp with intervals

From: Joost Geurts <Joost.Geurts_at_cwi.nl>
Date: Fri 19 Nov 2004 04:59:26 PM GMT
Message-Id: <1100883566.12692.171.camel@hobbes.ins.cwi.nl>
```Dear people,

I have the following CLP program which fails although I do not really
understand why. It fails in SWI-prolog at exactly the same point so I
assume it is me who made a mistake. Maybe somebody can explain, and
possibly suggest a way to solve it.

The problem is that I have a N intervals (in the example below there are
two, A and B) which are contained in an interval C which has the
property that it is a small as possible.

For completeness I state additional requirements for my application
although they are not all encoded in the sample program:
The C interval is contained in D. Finally at label time I'd like to
specify whether C should be labeled min, max or centered (default:
center)

The last constraint, CX2 #= MinX2 fails. My guess is it has something to
do with the minlist constraint. I am using eclipse 5.7 with the ic
library.

Any help would be greatly appreciated,

Joost

/*

AX1-----AX2
BX1-----BX2
CX1--------------------CX2
DX1--------------------------------------DX2

*/

run(Out) :-
CVars = [AX1,AX2,BX1,BX2,CX1,CX2,DX1,DX2],
Out =
[ax1:AX1,ax2:AX2,bx1:BX1,bx2:BX2,cx1:CX1,cx2:CX2,dx1:DX1,dx2:DX2],

L = 0, H = 1000,
AX1 #>= L, AX1 #=< H, AX2 #>= L, AX2 #=< H, AX1 #=< AX2,
BX1 #>= L, BX1 #=< H, BX2 #>= L, BX2 #=< H, BX1 #=< BX2,
CX1 #>= L, CX1 #=< H, CX2 #>= L, CX2 #=< H, CX1 #=< CX2,
DX1 #>= L, DX1 #=< H, DX2 #>= L, DX2 #=< H, DX1 #=< DX2,

% set size for A , B
WA = 180,
WB = 120,

% width A,B
WA #= AX2 - AX1,
WB #= BX2 - BX1,

% A before B
AX2 #=< BX1,

% C contains A&B
AX1 #>= CX1, AX2 #=< CX2,
BX1 #>= CX1, BX2 #=< CX2,

% find minimum  of A & B
minlist([AX1,BX1],MinX1),
minlist([AX2,BX2],MinX2),

% D contains C
DX1 #=< CX1, DX2 #>= CX2,

% C fits tightly
CX1 #= MinX1,
CX2 #= MinX2, % This constraint fails!

labeling(CVars),
true.

--
Joost Geurts <Joost.Geurts@cwi.nl>
```
Received on Fri Nov 19 17:05:33 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:31 PM GMT GMT