Reference 〉 Class
basePatches
PatchesRect

PatchesPolar(dimtuple(int, int))

A coordinate system class defining a two-dimensional polar grid. It assigns inward, outward, clockwise, and counterclockwise properties to patches, and moveInward(), moveOutward(), moveClockwise(), and moveCounterclockwise() methods to non-patch agents, and also defines distance and angle functions on a polar grid.

Patches are addressed by an θ,r index, both ints, where θ is the number of the patch starting at north, and moving clockwise, and r is the number of patches outward from the center. There will thus be θ×r patches. Coordinates are defined similarly, with the angle dimension ranging from 0 to θ (patch coordinate), rather than 0 to 2π (angle coordinate).

This class subclasses PatchesRect since it shares the quality that columns have equal length. It should not be initialized in user code; it is initialized automatically with model.spatial(geometry='polar').

Initialization Parameters

  • dim tuple(int, int), required

    The θ,r dimensions of the grid. θ is the number of patches around; r is the number of patches out.

Methods

Click a method name for more detailed documentation.

  • at( x, y )

    Returns the patch at the specified coordinate.

  • revive( coords )

    Reinstates a dead patch.

  • neighbors( model )

    Establishes the spatial network among the patches after initialization. This function is registered automatically as a modelPostSetup hook during spatial setup and should not be called by user code.

  • place( patch )

    Organizes Patch objects within the Patches object. Takes a patch object when created by Agents.initialize(), places it in the appropriate list, and assigns its position property.

Object Properties

  • offmap bool

    Whether agents can enter areas of the map with no patch. If False and an agent tries to move() to a coordinate with no patch, the move will fail and a warning will be raised. Set from the offmap argument of model.spatial().

    Initial value: False

  • boundaries tuple(tuple(int,int), tuple(int,int))

    A tuple of tuples with the maximum and minimum coordinates that agents can take, given the grid dimensions. ((xmin, xmax), (ymin, ymax)).

  • corners bool|float

    Whether the 'spatial' network includes patches connected only by a corner. Corresponds to the corners argument of model.spatial().

    Initial value: False

  • wrap tuple(bool, bool)

    Whether each axis wraps around at the boundary. Fixed to (True, False) in polar geometry, since agents can move continuously around but will not wrap from the edge to the center.

  • dim tuple(int, int)

    The θ,r dimensions of the grid. θ is the number of patches around; r is the number of patches out.

Static Properties

  • geometry str

    The name of the patch geometry, to be set by subclasses.

    Initial value: ''

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.

History