pacman.utilities package

Submodules

pacman.utilities.constants module

class pacman.utilities.constants.EDGES

Bases: enum.Enum

EAST = 0
NORTH = 2
NORTH_EAST = 1
SOUTH = 5
SOUTH_WEST = 4
WEST = 3

pacman.utilities.rig_converters module

pacman.utilities.rig_converters.convert_from_rig_placements(rig_placements, rig_allocations, machine_graph)[source]
pacman.utilities.rig_converters.convert_from_rig_routes(rig_routes, machine_graph)[source]
pacman.utilities.rig_converters.convert_to_rig_graph(machine_graph)[source]
pacman.utilities.rig_converters.convert_to_rig_machine(machine)[source]
pacman.utilities.rig_converters.convert_to_rig_placements(placements, machine)[source]
pacman.utilities.rig_converters.create_rig_graph_constraints(machine_graph, machine)[source]
pacman.utilities.rig_converters.create_rig_machine_constraints(machine)[source]

pacman.utilities.utility_calls module

pacman.utilities.utility_calls.check_algorithm_can_support_constraints(constrained_vertices, supported_constraints, abstract_constraint_type)[source]

Helper method to find out if an algorithm can support all the constraints given the objects its expected to work on

Parameters:
Returns:

Nothing is returned

Return type:

None

Raises:

pacman.exceptions.PacmanInvalidParameterException – when the algorithm cannot support the constraints demanded of it

pacman.utilities.utility_calls.check_constrained_value(value, current_value)[source]

Checks that the current value and a new value match

Parameters:
  • value – The value to check
  • current_value – The existing value
pacman.utilities.utility_calls.compress_bits_from_bit_array(bit_array, bit_positions)[source]

Compress specific positions from a bit array of 32 uint8 value, where is a 1 or 0, into a 32-bit value.

Parameters:
  • bit_array ([uint8]) – The array to extract the value from
  • bit_positions ([int]) – The positions of the bits to extract, each value being between 0 and 31
Return type:

int

pacman.utilities.utility_calls.compress_from_bit_array(bit_array)[source]

Compress a bit array of 32 uint8 values, where each is a 1 or 0, into a 32-bit value

Parameters:bit_array ([uint8]) – The array to compress
Return type:int
pacman.utilities.utility_calls.expand_to_bit_array(value)[source]

Expand a 32-bit value in to an array of length 32 of uint8 values, each of which is a 1 or 0

Parameters:value (int) – The value to expand
Return type:[uint8]
pacman.utilities.utility_calls.is_equal_or_None(a, b)[source]

If a and b are both not None, return True iff they are equal, otherwise return True

pacman.utilities.utility_calls.is_single(iterable)[source]

Test if there is exactly one item in the iterable

pacman.utilities.utility_calls.locate_constraints_of_type(constraints, constraint_type)[source]

Locates all constraints of a given type out of a list

Parameters:
  • constraints (iterable of pacman.model.constraints.AbstractConstraint) – The constraints to filter
  • constraint_type (pacman.model.constraints.partitioner_constraints.AbstractPartitionConstraint) – The type of constraints to return
Returns:

The constraints of constraint_type that are found in the constraints given

Return type:

iterable of pacman.model.constraints.AbstractConstraint

Raises:

None – no known exceptions

pacman.utilities.utility_calls.locate_first_constraint_of_type(constraints, constraint_type)[source]

Locates the first constraint of a given type out of a list

Parameters:
  • constraints (iterable of pacman.model.constraints.AbstractConstraint) – The constraints to select from
  • constraint_type (pacman.model.constraints.partitioner_constraints.AbstractPartitionConstraint) – The type of constraints to return
Returns:

The first constraint of constraint_type that was found in the constraints given

Return type:

pacman.model.constraints.AbstractConstraint

Raises:

pacman.exceptions.PacmanInvalidParameterException – if no such constraint is present

pacman.utilities.vertex_sorter module

class pacman.utilities.vertex_sorter.ConstraintOrder(constraint_class, relative_order, required_optional_properties=None)[source]

Bases: object

A constraint order definition for sorting

Parameters:
  • constraint_class – The class of the constraint
  • relative_order – The order of the constraint relative to other constraints to be sorted
  • required_optional_properties – Properties of the constraint instances that must not be None for the constraint to match this ordering
constraint_class

property method for the constraint class

relative_order

property method for the relative order

required_optional_properties

property method for the required optional properties

class pacman.utilities.vertex_sorter.VertexSorter(constraint_order)[source]

Bases: object

Sorts vertices based on constraints with given criteria

Parameters:constraint_order (list of ConstraintOrder) – The order in which the constraints are to be sorted
sort(vertices)[source]

Sort the given set of vertices by the constraint ordering

Parameters:vertices – The vertices to sort
Returns:The sorted list of vertices

Module contents

class pacman.utilities.ConstraintOrder(constraint_class, relative_order, required_optional_properties=None)[source]

Bases: object

A constraint order definition for sorting

Parameters:
  • constraint_class – The class of the constraint
  • relative_order – The order of the constraint relative to other constraints to be sorted
  • required_optional_properties – Properties of the constraint instances that must not be None for the constraint to match this ordering
constraint_class

property method for the constraint class

relative_order

property method for the relative order

required_optional_properties

property method for the required optional properties

class pacman.utilities.VertexSorter(constraint_order)[source]

Bases: object

Sorts vertices based on constraints with given criteria

Parameters:constraint_order (list of ConstraintOrder) – The order in which the constraints are to be sorted
sort(vertices)[source]

Sort the given set of vertices by the constraint ordering

Parameters:vertices – The vertices to sort
Returns:The sorted list of vertices