pacman.model.placements package

Module contents

class pacman.model.placements.Placement(vertex, x, y, p)

Bases: object

The placement of a vertex on to a machine chip and core.

Parameters:
  • vertex (MachineVertex) – The vertex that has been placed
  • x (int) – the x-coordinate of the chip on which the vertex is placed
  • y (int) – the y-coordinate of the chip on which the vertex is placed
  • p (int) – the ID of the processor on which the vertex is placed
location

The (x,y,p) tuple that represents the location of this placement.

Return type:tuple(int,int,int)
p

The ID of the processor of the chip where the vertex is placed

Return type:int
vertex

The vertex that was placed

Return type:MachineVertex
x

The x-coordinate of the chip where the vertex is placed

Return type:int
xy

The (x,y) tuple that represents the chip of this placement.

Return type:tuple(int,int)
y

The y-coordinate of the chip where the vertex is placed

Return type:int
class pacman.model.placements.Placements(placements=None)

Bases: object

The placements of vertices on the chips of the machine.

Parameters:

placements (iterable(Placement)) – Any initial placements

Raises:
add_placement(placement)[source]

Add a placement

Parameters:

placement (Placement) – The placement to add

Raises:
add_placements(placements)[source]

Add some placements

Parameters:placements (iterable(Placement)) – The placements to add
chips_with_placements

Get the chips with placements on them

Return type:iterable(tuple(int,int))
get_placement_of_vertex(vertex)[source]

Return the placement information for a vertex

Parameters:vertex (MachineVertex) – The vertex to find the placement of
Returns:The placement
Return type:Placement
Raises:PacmanNotPlacedError – If the vertex has not been placed.
get_placement_on_processor(x, y, p)[source]
Return the placement on a specific processor or raises an exception
if the processor has not been allocated
Parameters:
  • x (int) – the x coordinate of the chip
  • y (int) – the y coordinate of the chip
  • p (int) – the processor on the chip
Returns:

the placement on the given processor

Return type:

Placement

Raises:

PacmanProcessorNotOccupiedError – If the processor is not occupied

get_vertex_on_processor(x, y, p)[source]
Return the vertex on a specific processor or raises an exception
if the processor has not been allocated
Parameters:
  • x (int) – the x coordinate of the chip
  • y (int) – the y coordinate of the chip
  • p (int) – the processor on the chip
Returns:

the vertex placed on the given processor

Return type:

MachineVertex

Raises:

PacmanProcessorNotOccupiedError – If the processor is not occupied

is_processor_occupied(x, y, p)[source]

Determine if a processor has a vertex on it

Parameters:
  • x (int) – x coordinate of processor.
  • y (int) – y coordinate of processor.
  • p (int) – Index of processor.
Return bool:

Whether the processor has an assigned vertex.

is_vertex_placed(vertex)[source]

Determine if a vertex has been placed

Parameters:vertex (MachineVertex) – The vertex to determine the status of
Return type:bool
iterate_placements_on_core(x, y)[source]

Iterate over placements with this x, y and this type

Parameters:
  • x (int) – x coordinate to find placements for.
  • y (int) – y coordinate to find placements for.
Return type:

Placement

iterate_placements_with_vertex_type(x, y, vertex_type)[source]

Iterate over placements with this x, y and this type

Parameters:
  • x (int) – x coordinate to find placements for.
  • y (int) – y coordinate to find placements for.
  • vertex_type (class) – Class of vertex to find
Return type:

Placement

n_placements

The number of placements

Return type:int
n_placements_on_chip(x, y)[source]

The number of placements on the given chip :param int x: x coordinate of chip. :param int y: y coordinate of chip.

placements

All of the placements :return: iterable of placements :rtype: iterable(Placement)

placements_on_chip(x, y)[source]

Get the placements on a specific chip

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
Return type:

iterable(Placement)