Print

Print


Thanks, I will have a go.

Stewart.

On 30 May 2018 at 18:33, Sean Luke <[log in to unmask]> wrote:

> Got it.
>
> While I understand the consternation, I don't think this is a bug.  The
> way the locations lookup code works is by first identifying and adding into
> bags the relevant elements, and THEN optionally removing the origin.
> That's somewhat faster than checking for the origin and optionally removing
> it along the way.
>
> The origin is removed by using the remove(...) function on intBag.  This
> function works by swapping the removed-element with the top element, then
> just reducing the size of the bag by 1.  That's better than swapping
> everything down by 1, but as a result the top element in the bag is now out
> of order -- it's where the origin was.  That's the out of order thing
> you're seeing.
>
> There aren't any guarantees that the locations or neighbors will be in any
> particular order -- you should view them as a set rather than a list.  And
> I  am hesitant to modify the code otherwise.  HOWEVER there is a solution
> for you.
>
> In AbstractGrid2D and AbstractGrid3D there are the following methods:
>
> protected void removeOrigin(int x, int y, IntBag xPos, IntBag yPos);
> protected void removeOriginToroidal(int x, int y, IntBag xPos, IntBag yPos)
>
> If you look at these methods you'll see that they use remove(...).
>
> Make a subclass of the grid class you're using (say, MyObjectGrid2D).
> Then copy these methods into that subclass, but replace references to
> remove(...) with removeNondestructively(...).  You'll probably get better
> results then.
>
> Sean
>
>
> > On May 30, 2018, at 3:04 AM, Stewart Aitken <00000068a29a4109-dmarc-
> [log in to unmask]> wrote:
> >
> > Hello Sean,
> >
> > Modified Test.java for your attention.
> > The incorrect listing is in "Neighbors - false exclude origin".
> > In each case the list order is different between the include and exclude
> output.
> >
> > Observe the printout and you will see what I mean.
> >
> > Stewart.
> >
> > On 16 May 2018 at 21:28, Sean Luke <[log in to unmask]> wrote:
> > getVonNeumannNeighbors calls getVonNeumannLocations to get locations,
> then extracts the elements at those locations.  So if you're having issues
> with the wrong stuff being returned, with a high probability it's
> getVonNeumannLocations.
> >
> > Sean
> >
> > > On May 16, 2018, at 3:27 PM, Stewart Aitken <00000068a29a4109-dmarc-
> [log in to unmask]> wrote:
> > >
> > > Thanks Sean,
> > >
> > > One thing that strikes me straight away is you are using:
> > >
> > > grid.getVonNeumannLocations(0, 8, 1, Grid2D.BOUNDED, true, xs, ys);
> > >
> > > and I am using:
> > >
> > > mySpace.getVonNeumannNeighbors(myX, myY, hop, Grid2D.BOUNDED, true,
> result, xNeighbors, yNeighbors);
> > >
> > > Is this incorrect?
> > >
> > > Having run your Test.java, I get the same results as you.
> > >
> > > Kind regards,
> > >
> > > Stewart.
> > >
> > >
> > >
> > >
> > > On 15 May 2018 at 21:37, Sean Luke <[log in to unmask]> wrote:
> > > > On May 12, 2018, at 3:36 PM, Stewart Aitken <00000068a29a4109-dmarc-
> [log in to unmask]> wrote:
> > > >
> > > > Hi Sean,
> > > >
> > > > Downloaded all of the updated files and added them to my MASON
> project in eclipse,
> > > > carried out a clean and rebuild and it made no difference.
> > > >
> > > > Here are some outputs from the von Neumann Neighbourhood:
> > > > Remember, the width and height count from 1 and the outputs count
> from 0.
> > > > That accounts for the difference seen.
> > >
> > >
> > > I'm sorry Stewart, but your message was just too cryptic to parse.  To
> nail down your problem, I need a specific and simple example, in code, of
> expected results and deviations.  To get you started, I made a little test
> program which prints out location results from the distance=1 von Neumann
> neighborhood at various locations in a 7x15 grid and with various modes.
> You could modify this to find an example where it's producing the wrong
> results. [so far it seems correct]
> > >
> > >
> > >
> > >
> > > Sean
> > >
> > > Here's what I'm getting printed out in the current version of MASON
> BTW:
> > >
> > >
> > >
> > > Bounded 7x15 Center: (0,8)
> > > 0: (0, 7)
> > > 1: (0, 8)
> > > 2: (0, 9)
> > > 3: (1, 8)
> > > Unbounded 7x15 Center: (0,8)
> > > 0: (-1, 8)
> > > 1: (0, 7)
> > > 2: (0, 8)
> > > 3: (0, 9)
> > > 4: (1, 8)
> > > Toroidal 7x15 Center: (0,8)
> > > 0: (6, 8)
> > > 1: (0, 7)
> > > 2: (0, 8)
> > > 3: (0, 9)
> > > 4: (1, 8)
> > > Bounded 7x15 Center: (0,0)
> > > 0: (0, 0)
> > > 1: (0, 1)
> > > 2: (1, 0)
> > > Unbounded 7x15 Center: (0,0)
> > > 0: (-1, 0)
> > > 1: (0, -1)
> > > 2: (0, 0)
> > > 3: (0, 1)
> > > 4: (1, 0)
> > > Toroidal 7x15 Center: (0,0)
> > > 0: (6, 0)
> > > 1: (0, 14)
> > > 2: (0, 0)
> > > 3: (0, 1)
> > > 4: (1, 0)
> > > Bounded 7x15 Center: (6, 14)
> > > 0: (5, 14)
> > > 1: (6, 13)
> > > 2: (6, 14)
> > > Unbounded 7x15 Center: (6, 14)
> > > 0: (5, 14)
> > > 1: (6, 13)
> > > 2: (6, 14)
> > > 3: (6, 15)
> > > 4: (7, 14)
> > > Toroidal 7x15 Center: (6, 14)
> > > 0: (5, 14)
> > > 1: (6, 13)
> > > 2: (6, 14)
> > > 3: (6, 0)
> > > 4: (0, 14)
> > > Bounded 7x15 Center: (4, 0)
> > > 0: (3, 0)
> > > 1: (4, 0)
> > > 2: (4, 1)
> > > 3: (5, 0)
> > > Unbounded 7x15 Center: (4, 0)
> > > 0: (3, 0)
> > > 1: (4, -1)
> > > 2: (4, 0)
> > > 3: (4, 1)
> > > 4: (5, 0)
> > > Toroidal 7x15 Center: (4, 0)
> > > 0: (3, 0)
> > > 1: (4, 14)
> > > 2: (4, 0)
> > > 3: (4, 1)
> > > 4: (5, 0)
> > > Bounded 7x15 Center: (4, 8)
> > > 0: (3, 8)
> > > 1: (4, 7)
> > > 2: (4, 8)
> > > 3: (4, 9)
> > > 4: (5, 8)
> > > Unbounded 7x15 Center: (4, 8)
> > > 0: (3, 8)
> > > 1: (4, 7)
> > > 2: (4, 8)
> > > 3: (4, 9)
> > > 4: (5, 8)
> > > Toroidal 7x15 Center: (4, 8)
> > > 0: (3, 8)
> > > 1: (4, 7)
> > > 2: (4, 8)
> > > 3: (4, 9)
> > > 4: (5, 8)
> > >
> > >
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > EMAIL DISCLAIMER http://secure-web.cisco.com/
> 1ejZdv09xipqWR5r9Pp1BOI1wCXg-Mw7_OS6HIE19wLC0KMJYrr15cKvsEeBqXS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