Oz and Mozart Users Mailing List

Re: How to model this FD problem?


From: Luis Quesada (luque@info.ucl.ac.be)
Date: Sat Aug 25 2001 - 17:03:59 CEST


Dear Kenneth:

I don't know what you mean for "if I leave out the System.show of the
solution(s) I get almost identical times". What I mean is that the
number of * nodes of the search tree * can grow in a dramatic way using
your solution.

I just added another variable in the following example, however the
tree is 20 times bigger. Using my solution the number of nodes is still
one!

declare
proc {Foo Root}
   A B C D Dis
in
   Root = solution(a:A b:B c:C d:D)
   [A B C]:::0#50
   {FD.impl A=:1 (B::1#20)+(C::1#20)+(D::1#20)=:3 1}
   A=1
   {Space.waitStable}
   Dis = {Record.filter Root fun {$ X} {Not {FD.reflect.min X} == 0}end}

   {FD.distribute ff Dis}
end
{ExploreAll Foo}

BTW,

{FD.impl A=:1 B::1#20 1}
{FD.impl A=:1 C::1#20 1}
{FD.impl A=:1 D::1#201}

is equivalent (in terms of solutions) to

{FD.impl A=:1 (B::1#20)+(C::1#20)+(D::1#20)=:3 1}

and it also equivalent to:

or A=:1 B::1#20 C::1#20 D::1#20 [] A\=:1 end.
(This is what I meant when I told you about the rule in my previous
message)

Another useful rule could be:

A1->B
A2->B
.
.
.
An->B
____________________
A1 \/ A2 \/...\/ An -> B

You can use the above to reduce

{FD.impl A=:1 B::1#20 1}
{FD.impl A=:2 B::1#20 1}
{FD.impl A=:3 B::1#201}

to

{FD.impl A::1#3 B::1#20 1} (in case you decide to keep your solution)

In the attachment there is a *naive* alternative to create the script
dynamically (I call it in that way because it was the first idea that
came to my mind so I am not sure it is the best one :-). In short, the
idea is to read the definition of the root variable from a stream (see
the comments in the code). Note that the definition of the stream and
the definition of the script are two processes that run concurrently.

Cheers,

Luis

PD: I don't think your questions are stupid.

--
Catholic University of Louvain
Department of Computing Science and Engineering
Place Sainte Barbe, 2
B-1348 Louvain-la-Neuve, Belgium
Phone: (++32) (10) 47 90 13
Fax: (++32) (10) 45 03 45
E-mail: luque@info.ucl.ac.be

local S % Stream

%Procedure that uses the information of the stream to define the root variable of the script proc {DefineRoot S Root} Root={Record.make '#' {Nth S 1}} try P=proc {$ E} Statement={Nth S E} in if Statement==nil then raise ok end else case Statement of '#'(_) then Root.(Statement.1.1)::Statement.1.2 else {FD.impl Root.(Statement.1.1)::Statement.1.2 Root.(Statement.2.1)::Statement.2.2 1} end {P E+1} end end in {P 2} catch _ then skip end end

in thread %Definition of the root variable S=[ [a b c] %features '#'((a#(0#10))) % Domain of Root.a '#'((b#(0#10))) % Domain of Root.b '#'((c#(0#10))) % Domain of Root.c (a#[1 3])#(b#(3#5)) % rule 1 (b#[3#5 6])#(c#[1 2]) % rule 2 '#'((a#[3])) % starting point nil ] end

thread %Definition of the script in terms of DefineRoot proc {Script Root} Root={DefineRoot S} {FD.distribute ff Root} end in {Browse {SearchAll Script}} end end

- Please send submissions to users@mozart-oz.org and administriva mail to users-request@mozart-oz.org. The Mozart Oz web site is at http://www.mozart-oz.org/.



This archive was generated by hypermail 2b29.