Kip: Thanks for the links.  I think the point you made (that # and $ are
equivalent in this case) was my point.  Correct me if I'm wrong.


Bo: Ahh, sorry, I missed the 0.5> vs. 0= I thought the sole difference was
# and $.  Your comment makes sense now.


Linda: I think Raul already suggested removing 0= in 0= ? (2$n)$2.  In
fact, my sloppy application of this suggestion resulted in a bug where I
removed 0= in another line I shouldn't have.

Thanks for the rank1, rank2, examples.  This helped solidify my
understanding of monadic # and especially $ which I haven't made much use
of yet.

I appreciate the change to * from *. (it's no longer awkward to end this
sentence).


Raul:
   D
1 0 0 1
0 1 0 1
1 0 1 0
1 1 0 0
   c1
1 0 1 0
1 1 1 0
1 1 1 0
1 0 0 0
   X
0 0 0 0
0 0 0 1
0 0 0 0
0 2 0 0

Here X is telling us to use the constraint c1 (presumably b/c C is not
shown) between the variables 1 and 3 (0 based).  Likewise, use the
transpose going the other direction (3,1).

Given the structure of X, only variables 1 and 3 can possibly change. So if
they are all changing something is definitely wrong.

Unfortunately I've run out of time to read the rest of your response but
hopefully I can get through it soon.  I've also wanted to write a simpler
version of the algorithm where the right argument of ac is only D and it
runs through all the arcs in the problem instead of trying to be smart
about which ones could have changed.

Cheers,

Mike



On Sat, Nov 10, 2012 at 7:04 AM, Raul Miller <rauldmil...@gmail.com> wrote:

> I have been struggling with understanding this program, and I have an
> issue that I need clarified:
>
>    D
> 1 0 0 1
> 0 1 0 1
> 1 0 1 0
> 1 1 0 0
>    c1
> 1 0 1 0
> 1 1 1 0
> 1 1 1 0
> 1 0 0 0
>    X
> 0 0 0 0
> 0 0 0 1
> 0 0 0 0
> 0 2 0 0
>
> Here, I am thinking that an arc consistent result can only have 1
> values in half of the rows of D.  But ac gives me 1 values in all of
> the rows of D.
>
> Also, consider this case:
>
>    D
> 0 1 1 0
> 1 0 1 0
> 0 0 1 1
> 0 1 0 1
>    c1
> 1 0 1 1
> 1 0 1 1
> 1 0 0 1
> 0 1 1 0
>    X
> 0 0 1 1
> 0 0 1 0
> 2 2 0 0
> 2 0 0 0
>
> Here, ac gives me:
> 0 1 1 0
> 0 0 1 0
> 0 0 0 1
> 0 1 0 1
>
> But I think the result should be
> 0 1 1 0
> 1 0 1 0
> 0 0 1 1
> 0 1 0 1
>
> The difference is in the "0" value in the second row and the "2" value
> in the third row.
>
> If I understand the algorithm properly: according to X, relationships
> are considered between the third row and either the first or second
> row.  And, according to c1, 0 comp 2 is valid.
>
> In other words, I think this might be a valid implementation of arc
> consistency:
>
> arcn=:3 :0
>   'D c1 X'=: y
>   X1=. 1=X
>   ([:+./"1[: +./((|:c1) *"1 2~ (|:X1) *"1 2 ]) +. c1 *"1 2~ X1 *"1 2 ])^:_
> D
> )
>
>
> for reference, here's my "workalike" cover for ac (except, of course,
> the results are not the same):
>
> arccon=:3 :0
>    'D c1 X'=: y
>    'n d'=: $D
>    adj =: ((<@#)&(i.n)) @ (0&<)
>    A =: adj X
>    ac =: > @ (1&{) @ (revise^:_) @ ((i.n)&;)
>    ac D
> )
>
>
> I do not want to concern myself with efficiency issues until after I
> am sure I understand the algorithm properly.  (But making c1 and X
> sparse might be appropriate, in some contexts.)
>
> If I have made a mistake here, I'd greatly appreciate an explanation
> of where I went wrong.
>
> Thanks,
>
> --
> Raul
>
> On Fri, Nov 2, 2012 at 1:01 AM, 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