Re: Solving a traditional binary CSP in Eclipse

From: Tom Kelsey <tom_at_dcs.st-and.ac.uk>
Date: Thu 01 May 2003 10:58:37 AM GMT
Message-ID: <3EB0FDDD.C3F3D75B@dcs.st-and.ac.uk>
Another approach is one constraint for each variable pair:

:- lib(fd).

top :-
	Vars = [X,Y,Z],
	Vars :: 1..5,
	(X #= 1 #/\ (Y #= 2 #\/ Y #= 1)) #\/ (X #= 3 #/\ Y #= 1),
	(
	    Y #< 4 -> Z #= 3
	;
	    true
	),
	(
	    Z ## 3 -> X #= Z
	;
	    X #= 1
	),
	labeling(Vars),
	printf("X = %d \n Y = %d \n Z = %d \n", [X,Y,Z]).

 
============================================================
Tom Kelsey                     email:  tom@dcs.st-and.ac.uk
School of Computer Science     direct:   +44 (0)1334 463247
University of St Andrews       office:   +44 (0)1334 463253
North Haugh KY16 9SS           fax:      +44 (0)1334 463278
          http://www.dcs.st-and.ac.uk/~tom
============================================================
Received on Thu May 01 12:11:20 2003

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