[Oz] Generating lists of variables
Raphael Collet
raph at info.ucl.ac.be
Thu Jun 29 14:36:29 CEST 2000
> Thank you both for your assistance, it has been very
> helpfull. If I could now beg your indulgence for a
> further a question:
>
> I have now succesfully created the record "channel"
> and implemented a series of constraints. However, the
> distribution still eludes me. At first I tried to
> distribute directly on the record:
>
> {FD.distribute ff Channel}
>
> but it gave me the following error message:
>
> %*************************** type error
> *************************
> %**
> %** Expected type: vector of finite domains
> %** At argument: 1
> %** In statement: {FDP.distribute 1 0
> channel(c(_{1#27} _{4#27} _{7#27} _{10#27} _{13#30})
> c(_{1#27} _{4#27} _{7#27} _{10#27} _{13#27} _{16#27}
> _{19#30}) c(_{1#27} _{4#27} _{7#30}) c(_{1#27} _{4#27}
> _{7#27} _{10#27} _{13#30})) _}
> %**
> %** Call Stack:
> %** procedure 'FdDistribute' in file
> "/home/mozart/httpd/html/build/build-1.1.0/mozart/share/lib/cp/FD.oz",
> line 506, column 6, PC = 5198140
> %**--------------------------------------------------------------
FD.distribute expects as argument a vector of finite domains, e.g., a
list of FD variables or a record of FD variables. Channel is a record
of records of FD variables!
> So I instead tried to distribute on "Root", defined
> as:
> Root = {List.flatten Channel}
>
> but it still gave the same result. I then added the
> use of the Record.toList, but it still didn't change
> anything. I can distribute just fine on the individual
> sub-record of Channel, but never on the whole thing.
> What am I doing wrong?
First, Channel is NOT a list, so {List.flatten Channel} returns Channel
as result. Second, {Record.toList Channel} gives you a list of records
of FD variables. You just cannot distribute on such a thing, for the
reason I explained above.
Now we are close to a solution. FD.distribute is used to specify the
order variables will be chosen and the strategy for distribution.
Actually, the following two lines are equivalent:
{FD.distribute ff [X Y]}
{FD.distribute ff [X]} {FD.distribute ff [Y]}
Thus, you can specify the distribution strategy you expect by saying:
"Distribute on the first subrecord, then distribute on the second
subrecord, etc." This is done by distributing on each field of Channel:
{Record.forAll Channel proc {$ X}
{FD.distribute ff X}
end}
I hope this sheds light on the matter.
--
Raphaël Collet
raph at info.ucl.ac.be
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
More information about the mozart-users
mailing list