pacman.model.constraints.key_allocator_constraints package

Module contents

class pacman.model.constraints.key_allocator_constraints.AbstractKeyAllocatorConstraint[source]

Bases: pacman.model.constraints.abstract_constraint.AbstractConstraint

A constraint on key allocation

class pacman.model.constraints.key_allocator_constraints.ContiguousKeyRangeContraint[source]

Bases: pacman.model.constraints.key_allocator_constraints.abstract_key_allocator_constraint.AbstractKeyAllocatorConstraint

Key allocator constraint that keeps the keys allocated to a contiguous range. Without this constraint, keys can be allocated across the key space.


All current key allocators always allocate contiguous keys.

class pacman.model.constraints.key_allocator_constraints.FixedKeyFieldConstraint(fields)[source]

Bases: pacman.model.constraints.key_allocator_constraints.abstract_key_allocator_constraint.AbstractKeyAllocatorConstraint

Constraint that indicates fields in the mask of a key.

Parameters:fields (iterable(Field)) – any fields that define regions in the mask with further limitations

if any of the fields are outside of the mask i.e.,:

mask & field.value != field.value

or if any of the field masks overlap i.e.,:

field.value & other_field.value != 0

Any fields in the mask, i.e., ranges of the mask that have further limitations

Returns:Iterable of fields, ordered by mask with the highest bit range first
Return type:list(Field)
class pacman.model.constraints.key_allocator_constraints.FixedKeyAndMaskConstraint(keys_and_masks, key_list_function=None)[source]

Bases: pacman.model.constraints.key_allocator_constraints.abstract_key_allocator_constraint.AbstractKeyAllocatorConstraint

Key allocator constraint that fixes the key and mask of an edge.


Used for neuron-connected input (“sensory neurons”) and output (“motor neurons”) devices.

  • keys_and_masks (iterable(BaseKeyAndMask)) – The key and mask combinations to fix
  • key_list_function (callable(iterable(tuple( BaseKeyAndMask, MachineEdge, int)), iterable(int))) – Optional function which will be called to translate the keys_and_masks list into individual keys. If missing, the keys will be generated by iterating through the keys_and_masks list directly. The function parameters are: * An iterable of keys and masks * A machine edge * Number of keys to generate (may be None)

A function to call to generate the keys

Returns:A python function, or None if the default function can be used
Return type:callable(iterable(tuple(BaseKeyAndMask, MachineEdge, int)), iterable(int))

The keys and masks to be fixed

Returns:An iterable of key and mask combinations
Return type:iterable(BaseKeyAndMask)
class pacman.model.constraints.key_allocator_constraints.FixedMaskConstraint(mask)[source]

Bases: pacman.model.constraints.key_allocator_constraints.abstract_key_allocator_constraint.AbstractKeyAllocatorConstraint

A key allocator that fixes the mask to be assigned to an edge.


Used for some neuron-connected output devices.

Parameters:mask (int) – the mask to be used during key allocation

The mask to be used

Return type:int
class pacman.model.constraints.key_allocator_constraints.ShareKeyConstraint(other_partitions)[source]

Bases: pacman.model.constraints.key_allocator_constraints.abstract_key_allocator_constraint.AbstractKeyAllocatorConstraint

Constraint to allow the same keys to be allocated to multiple edges via partitions.


This constraint appears to be unused.

Parameters:other_partitions (list(AbstractSingleSourcePartition)) – the other edges which keys are shared with.

the other edges which keys are shared with

Return type:list(AbstractSingleSourcePartition)