Concerning debugging CSPs, it sometimes helps to call a script directly, e.g.,
like the following.
{Browse {SendMoreMoney}}
That way any blocking can be detected and the first propagation can be
investigated.------
Best,
Torsten
On 9 Jul 2011, at 09:11, Wolfgang Meyer wrote:
> Hi,
>
> the debugger does unfortunately not work with search, i.e. you can't debug
> code that runs in subordinate computation spaces.
> See here: http://www.mozart-oz.org/lists/oz-users/2339.html (I have not yet
> tried this "Investigator" tool.)
>
> The call to FD.sumC does indeed block. The problem is the order of arguments.
> The first two arguments must be switched.
> BTW, in this case a better error handling is probably not possible.
> Theoretically, the contents of the first arguments could become determined at
> any time, so sumC MUST block and wait for the values.
>
> Hope thuis helps,
> Wolfgang
>
>
> On Fri, Jul 8, 2011 at 6:48 PM, Lyle Kopnicky <[email protected]> wrote:
> Hi folks,
>
> I'm working on the cryptarithmetic problem in Chapter 12 of CTM. It involves
> generalizing the SEND + MORE = MONEY problem presented in the chapter.
> Starting with the code in the chapter, I've made an incremental change toward
> generalizing the code. However, it doesn't seem to be running all the code.
> The three Browses in a row are for debugging, and are outputting the correct
> intermediate results. However, they are only shown once, indicating that
> NumberFor is only called once, even though it should be called three times.
> Is it blocking somehow?
>
> I have tried to run this through the debugger. It does not seem to want to
> trace through the relevant calls. I have tried to set breakpoints, and gotten
> an "error setting breakpoint". I have tried splitting up the line with the
> three NumberFor calls into three separate statements, and putting
> {Ozcar.breakpoint} calls before each one, but that doesn't stop the debugger,
> either.
>
> Any idea what is going wrong here?
>
> declare
>
> fun {SolveAll F}
> L={Solve F}
> proc {TouchAll L}
> if L==nil then skip else {TouchAll L.2} end
> end
> in
> {TouchAll L}
> L
> end
>
> proc {SendMoreMoney ?Sol}
> S E N D M O R Y
> NumberFor
>
> fun {PowsOfTen Xs N}
> case Xs
> of nil then nil
> [] _|Xs then N|{PowsOfTen Xs N*10}
> end
> end
> in
> Sol=sol('S':S 'E':E 'N':N 'D':D 'M':M 'O':O 'R':R 'Y':Y)
> Sol:::0#9
> {FD.distinct Sol}
>
> fun {NumberFor Word}
> AtomWord = {Map {Reverse Word} Char.toAtom}
> in
> {Browse atomWord(AtomWord)}
> {Browse mappedAtomWord({Map AtomWord fun {$ C} Sol.C end})}
> {Browse powsOfTen({PowsOfTen AtomWord 1})}
> {FD.sumC {Map AtomWord fun {$ C} Sol.C end} {PowsOfTen AtomWord 1} '=:'}
> end
>
> S\=:0
> M\=:0
> {NumberFor "SEND"} + {NumberFor "MORE"} =: {NumberFor "MONEY"}
> % 1000*S + 100*E + 10*N + D
> % + 1000*M + 100*O + 10*R + E
> %=: 10000*M + 1000*O + 100*N + 10*E + Y
> {FD.distribute ff Sol}
> end
>
> {Browse {SolveAll SendMoreMoney}}
>
> Thanks,
> Lyle
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
Best wishes,
Torsten
--
Dr Torsten Anders
Course Leader, Music Technology
University of Bedfordshire
Park Square, Room A315
http://strasheela.sourceforge.net
http://www.torsten-anders.de
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users