lava.lib.optimization.solvers.generic.cost_integrator

lava.lib.optimization.solvers.generic.cost_integrator.models

digraph inheritance5384cb5d13 { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "AbstractProcessModel" [URL="../../lava/lava.magma.core.model.html#lava.magma.core.model.model.AbstractProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents a model that implements the behavior of a Process."]; "ABC" -> "AbstractProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AbstractPyProcessModel" [URL="../../lava/lava.magma.core.model.py.html#lava.magma.core.model.py.model.AbstractPyProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract interface for Python ProcessModels."]; "AbstractProcessModel" -> "AbstractPyProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ABC" -> "AbstractPyProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CostIntegratorModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.cost_integrator.html#lava.lib.optimization.solvers.generic.cost_integrator.models.CostIntegratorModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="CPU model for the CostIntegrator process."]; "PyLoihiProcessModel" -> "CostIntegratorModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PyLoihiProcessModel" [URL="../../lava/lava.magma.core.model.py.html#lava.magma.core.model.py.model.PyLoihiProcessModel",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="ProcessModel to simulate a Process on Loihi using CPU."]; "AbstractPyProcessModel" -> "PyLoihiProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.lib.optimization.solvers.generic.cost_integrator.models.CostIntegratorModel(proc_params=None)

Bases: PyLoihiProcessModel

CPU model for the CostIntegrator process.

The process adds up local cost components from downstream units comming as spike payload. It has a cost_min variable which keeps track of the best cost seen so far, if the new cost is better, the minimum cost is updated and send as an output spike to an upstream process. Note that cost_min is divided into the first and last three bytes. cost_min = cost_min_first_byte << 24 + cost_min_last_bytes

cost_first_byte: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'int'>, precision=8)
cost_in: PyInPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyInPortVectorDense'>, d_type=<class 'int'>, precision=None)
cost_last_bytes: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'int'>, precision=24)
cost_min_first_byte: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'int'>, precision=8)
cost_min_last_bytes: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'int'>, precision=24)
cost_out_first_byte: PyOutPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyOutPortVectorDense'>, d_type=<class 'int'>, precision=None)
cost_out_last_bytes: PyOutPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyOutPortVectorDense'>, d_type=<class 'int'>, precision=None)
implements_process

alias of CostIntegrator

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
run_spk()

Execute spiking phase, integrate input, update dynamics and send messages out.

lava.lib.optimization.solvers.generic.cost_integrator.process

digraph inheritance741b5b575e { bgcolor=transparent; rankdir=TB; size=""; "AbstractProcess" [URL="../../lava/lava.magma.core.process.html#lava.magma.core.process.process.AbstractProcess",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The notion of a Process is inspired by the Communicating Sequential"]; "CostIntegrator" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.cost_integrator.html#lava.lib.optimization.solvers.generic.cost_integrator.process.CostIntegrator",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Node that integrates cost components and produces output when a better"]; "AbstractProcess" -> "CostIntegrator" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.lib.optimization.solvers.generic.cost_integrator.process.CostIntegrator(*, shape=(1,), min_cost=0, name=None, log_config=None)

Bases: AbstractProcess

Node that integrates cost components and produces output when a better cost is found.

Parameters:
  • shape (tuple(int)) – The expected number and topology of the input cost components.

  • name (str, optional) – Name of the Process. Default is ‘Process_ID’, where ID is an integer value that is determined automatically. log_config: Configuration options for logging.

  • InPorts

  • -------

  • cost_in – input to be additively integrated.

  • OutPorts

  • --------

  • cost_out_last_bytes (OutPort) – Notifies the next process about the detection of a better cost. Messages the last 3 byte of the new best cost. Total cost = cost_out_first_byte << 24 + cost_out_last_bytes.

  • cost_out_first_byte (OutPort) – Notifies the next process about the detection of a better cost. Messages the first byte of the new best cost.

  • Vars

  • ----

  • cost – Holds current cost as addition of input spikes’ payloads

  • cost_min_last_bytes – Current minimum cost, i.e., the lowest reported cost so far. Saves the last 3 bytes. cost_min = cost_min_first_byte << 24 + cost_min_last_bytes

  • cost_min_first_byte – Current minimum cost, i.e., the lowest reported cost so far. Saves the first byte.