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 agentnum_agents
: int, number of agents in the systemfunction
: 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_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:
Receives the input position x from the inport.
Evaluates the fitness of the position using the provided function.
If the fitness is better than the current best fitness or if the process is not initialised, updates the best position and fitness.
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)¶