PySelectorModel

Full Name

neuroptimiser.core.models.PySelectorModel

Description

class PySelectorModel[source]

Bases: PyLoihiProcessModel

Selector model for low-level selection in perturbation-based nheuristics

This model implements a selector process that evaluates the fitness of positions and selects the best one based on a given function. This is intended to be used in conjunction with a perturbation-based nheuristic process inside a NeuroHeuristicUnit.

See also

neuroptimiser.core.processes.Selector

Process that selects the best position based on a fitness function.

__init__(proc_params)[source]

Initialises the selector model with the given parameters.

Parameters:

proc_params (dict) –

A dictionary containing the parameters for the process model. It should include:
  • agent_id: int, identifier of the agent

  • num_agents: int, number of agents in the system

  • function: callable, function to evaluate the fitness of a position

fp: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'numpy.float32'>, precision=None)
fp_out: PyOutPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyOutPortVectorDense'>, d_type=<class 'numpy.float32'>, precision=None)
implements_process

alias of Selector

implements_protocol

alias of LoihiProtocol

p: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'numpy.float32'>, precision=None)
p_out: PyOutPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyOutPortVectorDense'>, d_type=<class 'numpy.float32'>, precision=None)
required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
run_spk()[source]

Runs the selector process model.

The process is summarised as follows:
  1. Receives the input position x from the inport.

  2. Evaluates the fitness of the position using the provided function.

  3. If the fitness is better than the current best fitness or if the process is not initialised, updates the best position and fitness.

  4. Sends the updated-best position and fitness to the outports.

x_in: PyInPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyInPortVectorDense'>, d_type=<class 'numpy.float32'>, precision=None)