It's a little hard for me to catch up with the flurry of messages, but I am
trying =)  I'm also on Vancouver time so I'm guessing you guys had a head
start.

Good ideas, thank you:
removing 0=
adj=: < @ I. @: *
Devon for elaboration of differences b/w # and $.

The domain of the left argument of arcsX is the variables whose arcs we
wish to compute.  Thus it is a list of unique values
chosen from {0,1,...,n-1}.  It is not just all the variables (i.n) or one
variable (eg. 0) but might be some subset
(0 1 4).  I follow the argument for (arcs=: $ #: I.@) but my J is slow.  We
would have to be able to select an or
of equals for example select from first column where the value is 0 or 1 or
4.

The general pattern of revise is that it takes as input the CSP instance
(A, a, C) as well as the domains of all values D and the set of variables
whose domains may still require filtering.  Initially, we don't have any
information about which variables these might be so we conservatively say
that they all require filtering (i.n).  After the initial call all
neighboring variables to a variable whose domain has changed will need to
be filtered again.  This might come up as follows in sudoku:

assume x1,x2,x3 are on the same row
Dx1 = {1}
Dx2 = {1,2}
Dx3 = {1,2,3}

After filtering for the first time we get:
Dx1 = {1}
Dx2 = {2}
Dx3 = {2,3}   NB. 2 has at least one compatible value in Dx2 = {1,2}

We still need to filter again (specifically, we need to check the influence
of removing a value from Dx2 on Dx3):
Dx1 = {1}
Dx2 = {2}
Dx3 = {3}   NB. 2 has no compatible values in Dx2 = {2}

Thus, with xs referring to the nub of the first column of arcs, and ys to
the nub of the second column: if ys is the input to the first call to
revise, then xs will be the argument to the next call of revise but will be
known as ys in that context.

Hope this helps.

Mike

On Sun, Nov 4, 2012 at 6:40 AM, Raul Miller <rauldmil...@gmail.com> wrote:

> In
>    A=. 0= ? (2$n)$2       NB. generate random matrix of [0,1]
>
> The 0= is unnecessary, and probably reflects a habit based on the
> false idea that boolean algebra is does not have an integer domain.
> Boolean rings have (subset of) integer domains, and [even after
> redefinition] boolean algebra is a boolean ring.
>
> If you ever want to treat Heyting Algebras or Bayesian Probability you
> might also want to consider what happens when you replace the $2 with
> $0.
>
> I think I would also be more comfortable with
>    2 2 $ ''; 'y'; 'x'; A
> for the displayed table, but that's a minor quibble.
>
> An alternative definition for adj might be
>    adj=: <@I.@:*
>
> But somewhere around here, I get lost.  Your use pattern for arcsX is:
>
>    (i.n) arcsX A
>
> where A has the shape n,n
>
> What is the domain of the left argument of arcsX?  I am guessing that
> it's either i.n or a single element choosen from i.n but if that is
> the case, I think I'd define arcsX to only work for the i.n case --
> the name says "arcs" after all.  Also, if I wanted to extract the
> values from the result of arcsX which correspond to a single value
> from i. n, that's simple enough -- I can select on the first column of
> the result.
>
> In other words, perhaps something like this:
>
>    arcs=: $ #: I.@,
>    arcs *A
>
> Also, I have not taken the time yet, to read "revise", so I will stop here.
>
> --
> Raul
>
> On Sun, Nov 4, 2012 at 12:31 AM, Michal D. <michal.dobrog...@gmail.com>
> wrote:
> > Thank you everyone for the comments and encouragement.
> >
> > I think Bo's (?]) and accompanying code was an interesting illustration
> of
> > a nice use of the hook.  I'm not sure why to prefer doubling an entire
> > array as opposed to dividing a single scalar?  I think that inlining getx
> > and gety is anti-style ;-).  See also all the argument unwrapping that
> > happens in the new revise.  Too bad there is no way to prevent this.
> >
> > I take it that picking # over $ is a purely stylistic preference.  I
> > appreciate all the comments regarding coppula and NB.*, both sound like a
> > good idea.
> >
> > The historical comments regarding a hook conjunction exactly mirror my
> > frustrations.  Thank you Raul also for arcsX2, that is a thing of beauty
> =).
> >
> > New and improved code at http://pastebin.com/fzs0GAev with an expanded
> > intro to "CSPs".
> >
> > Cheers,
> >
> > Mike
> >
> > On Thu, Nov 1, 2012 at 10:01 PM, Michal D. <michal.dobrog...@gmail.com
> >wrote:
> >
> >> Hi All,
> >>
> >> I've managed to write my first not-completely-trivial program in J.  It
> >> implements an arc consistency algorithm (
> >> http://en.wikipedia.org/wiki/Local_consistency#Arc_consistency).  I
> would
> >> appreciate any comments regarding style, what I'm doing wrong in J or
> how
> >> to improve the code.  I also have a couple of questions of my own:
> >>
> >> 1) how do I avoid @ especially once we remove explicit arguments?
> >> 2) how do I avoid constant boxing/unboxing due to fill (see arcsX)?
> >> 3) Is a boxed value always a pointer? One could imagine implementing
> >> 'ragged' arrays without pointers.
> >> 4) Is there a good way to have named variables (ie. avoid getx, gety)?
> >> 5) Why is a hook the default and not composition?
> >>
> >> Code at: http://pastebin.com/k4XuKfFi
> >>
> >> Cheers!
> >>
> >> Mike
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to