Once you have what you want, you can use some tools to study it:
 
Change from a Noun to a verb, view its tacit version and apply it to data:
  
    dd=: 13 :'(y%2) > (?]) x$y'
   
    dd
(2 %~ ]) > [: (? ]) $
    
   7 dd 3
1 1 0
1 0 1
0 1 1
0 1 1
0 1 1
0 1 1
0 1 1

Both the boxed version and the tree can be helpful.
   

      5!:4 <'dd'
      -- 2      
  ----+- ~ --- %
  │   L- ]      
  +- >          
--+   -- [:     
  │   │     -- ?
  L---+-----+- ]
      L- $      
   
      5!:2 <'dd'
------------T-T------------┐
│--T-----T-┐│>│---T-----T-┐│
││2│--T-┐│]││ ││[:│--T-┐│$││
││ ││%│~││ ││ ││  ││?│]││ ││
││ │L-+--│ ││ ││  │L-+--│ ││
│L-+-----+--│ │L--+-----+--│
L-----------+-+-------------

Each in its own way will show you the forks and hooks.  You will begin to
see differences in the patterns of trees that are built from right to left
compared to those built from left to right.

Oddly, I can untangle code long before I can understand what it is doing.
Now I'm ready to try to follow your thinking as it applies to Sudoku.

You should have lots of fun with J!

Linda


-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Michal D.
Sent: Monday, November 05, 2012 10:19 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Arc consistency in J

Actually, this is a bug  in the original code.  Thanks Linda!  It should be:

(d%2) > (?]) n$d

The idea being that each row (domain) has half of it's possible values set.
Which is different from what you suggest because you may get a row of all
zeros which is already inconsistent and so there is no point in running arc
consistency on it.

Cheers,

Mike


On Mon, Nov 5, 2012 at 2:11 AM, Linda Alvord <lindaalv...@verizon.net>wrote:

> I just began to ponder this thread. Do you think E is the same as D?
>
> D=. (n%2) > (?]) n$d
> E=. ?(n,d)$2
>
> Linda
>
> -----Original Message-----
> From: programming-boun...@forums.jsoftware.com
> [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Michal D.
> Sent: Sunday, November 04, 2012 11:26 PM
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Arc consistency in J
>
> > >> variables.  In other words, if we specify the constraint x < y it 
> > >> looks like either x1 < x2 or x2 < x1 is sufficient to satisfy arc 
> > >> consistency.  In other words, i think we should always use the 
> > >> symmetric closure of the constraint.
> > >
> > >> Does this sound valid to you?
> > >
> > > Unfortunately not.  There are no values that can satisfy x1<x2 and
> x2<x1.
> > > If this was the case all csps would have no solutions
> >
> > I meant x1<x2 OR x2<x1
> >
> > So symmetric closure was the wrong term for me to use.
> >
> > But I think we want to be using intersection of the relationship 
> > with its inverse.
> >
> > Does that sound right to you?
> >
>
> Sorry I missed the or.  Unfortunately not, I mean you can have a 
> constraint like that if you want but you don't have to have to in 
> general.  I think we're dwelling on an implementation detail.  They 
> (wikipedia) must just have the < constraint propagating both ways.
>
> My brain is fried but I did hack together an ugly search procedure.  
> You can try it out on a sudoku puzzle if you want.  For some reason I 
> couldn't generate it using the code you gave me.  
> http://pastebin.com/2zPB4DBA
>
> Maybe we can update the printf docs to say:
> load 'format/printf'
> http://www.jsoftware.com/help/jforc/input_and_output.htm
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to