pacman.model.placements package

Module contents

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

Bases: object

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

Parameters:
  • vertex – The vertex that has been placed

  • x – the x-coordinate of the chip on which the vertex is placed

  • y – the y-coordinate of the chip on which the vertex is placed

  • p – the ID of the processor on which the vertex is placed

property chip: Chip

The chip of this placement.

property location: Tuple[int, int, int]

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

property p: int

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

property vertex: MachineVertex

The vertex that was placed.

property x: int

The X-coordinate of the chip where the vertex is placed.

property xy: Tuple[int, int]

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

property y: int

The Y-coordinate of the chip where the vertex is placed.

class pacman.model.placements.Placements(placements: Iterable[Placement] = ())

Bases: object

The placements of vertices on the chips of the machine.

Parameters:

placements – Any initial placements

Raises:
add_placement(placement: Placement) None[source]

Add a placement.

Parameters:

placement – The placement to add

Raises:
add_placements(placements: Iterable[Placement]) None[source]

Add some placements.

Parameters:

placements – The placements to add

property chips_with_placements: Iterable[Tuple[int, int]]

The chips with placements on them.

get_placement_of_vertex(vertex: MachineVertex) Placement[source]

Return the placement information for a vertex.

Parameters:

vertex – The vertex to find the placement of

Returns:

The placement

Raises:

PacmanNotPlacedError – If the vertex has not been placed.

get_placement_on_processor(x: int, y: int, p: int) Placement[source]

Get the placement on a specific processor, or raises an exception if the processor has not been allocated.

Parameters:
  • x – the x coordinate of the chip

  • y – the y coordinate of the chip

  • p – the processor on the chip

Returns:

the placement on the given processor

Raises:

PacmanProcessorNotOccupiedError – If the processor is not occupied

is_processor_occupied(x: int, y: int, p: int) bool[source]

Determine if a processor has a vertex on it.

Parameters:
  • x – x coordinate of processor.

  • y – y coordinate of processor.

  • p – Index of processor.

Return bool:

Whether the processor has an assigned vertex.

is_vertex_placed(vertex: MachineVertex) bool[source]
Parameters:

vertex – The vertex to determine the status of

Returns:

True if this vertex has already been placed

iterate_placements_by_vertex_type(vertex_type: type | Tuple[type, ...]) Iterable[Placement][source]
Parameters:

vertex_type – Class of vertex to find

Returns:

Placements on any chip with this vertex_type.

iterate_placements_by_xy_and_type(xy: Tuple[int, int], vertex_type: type | Tuple[type, ...]) Iterable[Placement][source]
Parameters:
  • xy – x and y coordinate to find placements for.

  • vertex_type – Class of vertex to find

Returns:

Placements with this x, y and this vertex_type.

iterate_placements_on_core(xy: Tuple[int, int]) Iterable[Placement][source]
Parameters:

xy – x and y coordinates to find placements for.

Returns:

Iterator over placements with this x and y.

property n_placements: int

The number of placements.

n_placements_on_chip(xy: Tuple[int, int]) int[source]
Parameters:

xy – x and y coordinate of chip.

Returns:

The number of placements on the given chip.

property placements: Iterable[Placement]

All of the placements.

placements_on_chip(xy: Tuple[int, int]) Collection[Placement][source]
Parameters:

xy – The x and y coordinates of the chip

Returns:

The placements on a specific chip.