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

> EMAIL DISCLAIMER http://secure-web.cisco.com/

> 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 qQROtbGcjFVQYzS1dH8rrLqfu9keBZ FOwTORhpS6nv03iK3n4Rfprcyye4- E6ncmWCQt2qyCT8O6DOP6Bzba8FMMt jP9m9GcIPzCx8jVG3s2TBK95C2QlkD IqiojxkfqtyY-v2y- ePSDVdps9QzfDGym6J-Ppo1Gp- sXLRW3hGyr1T4oQs- dzpb46WVVrynykUX1Lu_ iwbBwIcHpTt_JSY5-NN156rzA_ xvLlWf- Neq1JEgnBDWa5jElATLlv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