geoVeRoPy.instance module

geoVeRoPy.instance.rndArcNeighbors(arcs: dict, arcIDs: list[int | str] | str = 'All', shape: str = 'Circle', arcFieldName: str = 'arc', **kwargs) dict[source]

Given an arc dictionary, add neighborhood to selected arcs

Warning

This function will modify the input dictionary arcs

Parameters:
  • arcs (dictionary, required) – A plain arcs dictionary to add neighborhoods.

  • arcIDs (string|list[int|str], optional, default 'All') – A list of arc IDs to add neighborhood, leave it as ‘All’ to indicate adding such information to all arcs.

  • method (dictionary, optional, default {'shape': 'FixedRadius', 'radius': 1, 'lod': 30}) –

    The shape of dictionary. Options includes 1) Adding fixed radius neighborhoods to a given arc

    >>> method = {
    ...     'shape': 'FixedRadius',
    ...     'radius': 1,
    ...     'lod': 30
    ... }
    

Returns:

Changes will apply to the original nodes dictionary

Return type:

dictionary

geoVeRoPy.instance.rndArcs(A: int | None = None, arcIDs: list[int | str] = [], distr='UniformLengthInSquareXY', arcFieldName: str = 'arc', **kwargs) dict[source]

Randomly create a set of arcs

Parameters:
  • A (integer, optional, default as None) – Number of arcs to be visited

  • arcIDs (list, optional, default as None) – Alternative input parameter of A. A list of arc IDs, A will be overwritten if arcIDs is given

  • distr (str, optional, default as 'UniformLengthInSquareXY') –

    The distribution of arcs. Options and required additional inputs are as follows:

    1. (default) ‘UniformLengthInSquareXY’, uniformly sample from a square on the Euclidean space, with uniformly selected length
      • xRange: 2-tuple, with minimum/maximum range of x, default as (0, 100)

      • yRange: 2-tuple, with minimum/maximum range of y, default as (0, 100)

      • minLen: float, minimum length of the arcs

      • maxLen: float, maximum length of the arcs

  • **kwargs (optional) – Provide additional inputs for different distr options

Returns:

A dictionary of randomly created arcs.

Return type:

dict

geoVeRoPy.instance.rndLocs(N: int, distr='UniformSquareXY', **kwargs) list[source]

Randomly create a list of N locations

Parameters:
  • N (integer, required) – Number of locations/vertices/customers to be randomly created

  • distr (string, optional, default as 'UniformSquareXY') –

    Spatial distribution of locations, options and required additional inputs are as follows:

    1. (default) ‘UniformSquareXY’, uniformly sample from a square on the Euclidean space
      • xRange: 2-tuple, with minimum/maximum range of x, default as (0, 100)

      • yRange: 2-tuple, with minimum/maximum range of y, default as (0, 100)

    2. ’UniformPolyXY’, uniformly sample from a given polygon
      • polyXY: poly, the polygon of the area, (no holes)

      • polyXYs: list of polys, alternative option for polyXY

    3. ’UniformAvoidPolyXY’, uniformly sample from a square avoiding some polygons
      • xRange: 2-tuple, with minimum/maximum range of x, default as (0, 100)

      • yRange: 2-tuple, with minimum/maximum range of y, default as (0, 100)

      • polyXY: poly, the polygon of the area, (no holes)

      • polyXYs: list of polys, alternative option for polyXY

    4. ’UniformCircleXY’, uniformly sample from a circle on the Euclidean space
      • centerXY: 2-tuple, the center of circle

      • radius: float, the radius of the circle

    5. ’UniformPolyLatLon’, uniformly sample from a polygon by lat/lon
      • polyLatLon: poly, the polygon of the area, (no holes)

      • polyLatLons: list of polys, alternative option for polyLatLon

    6. ’UniformCircleLatLon’, uniformly sample from a circle by lat/lon
      • centerLatLon: 2-tuple, the (lat, lon) for the center

      • radiusInMeters: float, the radius of the circle in meters

    7. ’RoadNetworkPolyLatLon’, uniformly generate within a given polygon on a road network
      • roads: dict, the road network dictionary

      • polyLatLon: poly, optional, the polygon on the map to sample from

      • polyLatLons: list of polys, optional, alternative for polyLatLon

      • roadClass: list[str], the road classes that allows to sample from

    8. ’RoadNetworkCircleLatLon’, uniformly generate within a circle on a road network
      • roads: dict, the road network dictionary

      • centerLatLon: 2-tuple, the (lat, lon) for the center

      • radiusInMeters: float, the radius of the circle in meters

      • roadClass: list[str], the road classes that allows to sample from

  • **kwargs (optional) – Provide additional inputs for different distr options

Returns:

A list of randomly created locations

Return type:

list

Raises:
geoVeRoPy.instance.rndNodeNeighbors(nodes: dict, nodeIDs: list[int | str] | str = 'All', shape: str = 'Circle', locFieldName='loc', neighborFieldName='neighbor', **kwargs) dict[source]

Given a node dictionary, create neighborhood to selected nodes

Warning

This function will modify the input dictionary nodes

Parameters:
  • nodes (dictionary, required) – A plain nodes dictionary to add neighborhoods.

  • nodeIDs (string|list[int|str], optional, default 'All') – A list of node IDs to add neighborhood, leave it as ‘All’ to indicate adding such information to all nodes.

  • shape (str, optional, default as 'Circle') –

    The shape of neighborhoods, options and required additional inputs are as follows:

    1. (default) ‘Circle’, add circle surrounding nodes
      • ’radius’: The radius, default as 1

      • ’lod’: The level of details, circle will be approximated as a x-gon polygon, default as 30

    2. ’Poly’, add polygon surrounding nodes
      • ’poly’: In relative axis where node locates in [0, 0]

    3. ’Egg’, add egg shape to nodes. The curve function: \(\frac{x^2}{(a - b)x + ab} + \frac{y^2}{c^2} = 1\)
      • ’a’: required

      • ’b’: required

      • ’c’: required

      • ’direction’: default as 0

      • ’lod’: default as 30

    4. ’RndSquare’, add random size squares around nodes
      • ’minLen’: required, minimum length

      • ’maxLen’: required, maximum length

    1. ’RndCurvy’, add random curvy shapes around nodes
      • ’maxRadius’: default as 1.2

      • ’minRadius’: default as 0.8

      • ’N’: default as 5

      • ’w’: default as 3

      • ’lod’: default as 30

    2. ’RndConvexPoly’, add convex polygons with random size around nodes
      • ’maxNumSide’: maximum number of sides

      • ’maxDiag’: maximum length of the diagonal

      • ’minDiag’: minimum length of the diagonal

  • **kwargs (optional) – Provide additional inputs for different distr options

Returns:

Changes will apply to the original nodes dictionary

Return type:

dict

geoVeRoPy.instance.rndNodes(N: int | None = None, nodeIDs: list[int | str] = [], nodes: dict | None = None, distr='UniformSquareXY', locFieldName='loc', **kwargs) dict[source]

Randomly create a nodes dictionary

Parameters:
  • N (integer, optional) – Number of locations/vertices/customers to be randomly created

  • nodeIDs (list of int|str, optional) – A list of ids for the locations to be created, an alternative option for N

  • nodes (dict, optional) – A nodes dictionary, if given, new locations will be append into this dictionary

  • distr (string, optional, default as 'UniformSquareXY') – See distr docstring in rndLocs()

  • locFieldName (str, optional, default as 'loc') – The key in nodes dictionary to indicate the locations

  • **kwargs (optional) – Provide additional inputs for different distr options

Returns:

A list of randomly created locations

Return type:

list

Raises:
geoVeRoPy.instance.rndPolys(P: int | None = None, polyIDs: list[int | str] | None = None, distr='UniformSquareXY', shape='RndConvexPoly', anchorFieldName='anchor', polyFieldName='poly', allowOverlapFlag=True, returnAsListFlag=True, **kwargs) dict[source]

Randomly create polygons

Parameters:
  • P (int|str, optional, default as None) – Number of polygons to create

  • polyIDs (list[int|str]|None, optional, default as None) – A list of ids for the polygons to be created, an alternative option for P

  • distr (str, optional, default as 'UniformSquareXY') – Anchor locations of each polygon. Options and required additional information are referred to rndLocs().

  • shape (str, optional, default as 'Circle',) – Shape of the polygons. Options and required additional information are referred to rndNodeNeighbors().

  • anchorFieldName (str, optional, default as 'anchor') – The key value of the anchor location

  • polyFieldName (str, optional, default as 'poly',) – The key value of the polygons

  • allowOverlapFlag (bool, optional, default as True) – True if allows the polygons to overlap

  • returnAsListFlag (bool, optional, default as True) – True if returns a list of polygons instead of a dictionary

Returns:

A dictionary with polygon information

Return type:

dict