lava.lib.optimization.solvers.generic

lava.lib.optimization.solvers.generic.builder

digraph inheritance60098c4c59 { bgcolor=transparent; rankdir=TB; size=""; "SolverProcessBuilder" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.builder.SolverProcessBuilder",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="Builder to dynamically create the process and model for the solver of an"]; }
class lava.lib.optimization.solvers.generic.builder.SolverProcessBuilder

Bases: object

Builder to dynamically create the process and model for the solver of an optimization problem.

create_solver_model(target_cost, requirements, protocol)

Create and set the model class for the solver process in the building pipeline.

Parameters:
  • target_cost (int) – A cost value provided by the user as a target for the solution to be found by the solver, when a solution with such cost is found and read, execution ends.

  • requirements (ty.List[AbstractComputeResource]) – Specifies which resources the ProcessModel requires.

  • protocol (AbstractSyncProtocol) – The SyncProtocol that the ProcessModel implements.

create_solver_process(problem, backend, hyperparameters)

Create and set a solver process for the specified optimization problem.

Parameters:
  • problem (OptimizationProblem) – Optimization problem defined by cost and constraints which will be used to ensemble the necessary variables and ports with their shape and initial values deriving from the problem specification.

  • hyperparameters (dict) – A dictionary specifying values for temperature and init_value. Both are array-like of. init_value defines initial values for the variables defining the problem. The temperature provides the level of noise.

property solver_model: AbstractProcessModel

Returns the solver process model if already created.

property solver_process: AbstractProcess

Returns the solver process if already created.

verify_model_exists()

Assert the solver process model has already been created.

verify_process_exists()

Assert the solver process has already been created.

lava.lib.optimization.solvers.generic.dataclasses

digraph inheritance80c89834d6 { bgcolor=transparent; rankdir=TB; size=""; "ConstraintEnforcing" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.dataclasses.ConstraintEnforcing",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="Processes implementing an optimization problem's constraints and their"]; "CostMinimizer" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.dataclasses.CostMinimizer",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="Processes implementing an optimization problem's cost function."]; "ProximalGradientMinimizer" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.dataclasses.ProximalGradientMinimizer",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="ProximalGradientMinimizer(augmented_terms: lava.lib.optimization.solvers.generic.hierarchical_processes.AugmentedTermsProcess)"]; "VariablesImplementation" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.dataclasses.VariablesImplementation",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="Processes implementing the variables of an optimization problem."]; }
class lava.lib.optimization.solvers.generic.dataclasses.ConstraintEnforcing(continuous=None, discrete=None, mixed=None)

Bases: object

Processes implementing an optimization problem’s constraints and their enforcing.

continuous: ContinuousConstraintsProcess = None
discrete: DiscreteConstraintsProcess = None
mixed: MixedConstraintsProcess = None
property state_in
property state_out
property variables_assignment
class lava.lib.optimization.solvers.generic.dataclasses.CostMinimizer(coefficients_2nd_order)

Bases: object

Processes implementing an optimization problem’s cost function.

coefficients_2nd_order: Sparse
property gradient_out

Port sending gradient descent components to the dynamical systems.

property state_in

Port receiving input from dynamical systems representing variables.

class lava.lib.optimization.solvers.generic.dataclasses.ProximalGradientMinimizer(augmented_terms)

Bases: object

augmented_terms: AugmentedTermsProcess
class lava.lib.optimization.solvers.generic.dataclasses.VariablesImplementation(continuous=None, discrete=None)

Bases: object

Processes implementing the variables of an optimization problem.

continuous: ContinuousVariablesProcess = None
discrete: DiscreteVariablesProcess = None
property gradient_in
property gradient_in_cont
property importances
property local_cost
property state_out
property state_out_cont
property variables_assignment
property variables_assignment_cont

lava.lib.optimization.solvers.generic.hierarchical_processes

digraph inheritance55c0c7bfb3 { 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"]; "AugmentedTermsProcess" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.AugmentedTermsProcess",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="Process implementing cost coefficients as synapses."]; "AbstractProcess" -> "AugmentedTermsProcess" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContinuousConstraintsProcess" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.ContinuousConstraintsProcess",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="Process implementing continuous constraints via neurons and synapses."]; "AbstractProcess" -> "ContinuousConstraintsProcess" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContinuousVariablesProcess" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.ContinuousVariablesProcess",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="Process which implementation holds the evolution of continuous"]; "AbstractProcess" -> "ContinuousVariablesProcess" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CostConvergenceChecker" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.CostConvergenceChecker",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="Process that continuously monitors cost convergence."]; "AbstractProcess" -> "CostConvergenceChecker" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteConstraintsProcess" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.DiscreteConstraintsProcess",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="Process implementing discrete constraints via synapses."]; "AbstractProcess" -> "DiscreteConstraintsProcess" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteVariablesProcess" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.DiscreteVariablesProcess",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="Process which implementation holds the evolution of discrete variables"]; "AbstractProcess" -> "DiscreteVariablesProcess" [arrowsize=0.5,style="setlinewidth(0.5)"]; "MixedConstraintsProcess" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.MixedConstraintsProcess",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="Process implementing continuous constraints via neurons and synapses."]; "AbstractProcess" -> "MixedConstraintsProcess" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NEBMAbstract" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.NEBMAbstract",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="Event-driven stochastic discrete dynamical system with two outputs."]; "AbstractProcess" -> "NEBMAbstract" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NEBMSimulatedAnnealingAbstract" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.NEBMSimulatedAnnealingAbstract",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="Event-driven stochastic discrete dynamical system with two outputs."]; "AbstractProcess" -> "NEBMSimulatedAnnealingAbstract" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SatConvergenceChecker" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.SatConvergenceChecker",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="Process that continuously monitors satisfiability convergence."]; "AbstractProcess" -> "SatConvergenceChecker" [arrowsize=0.5,style="setlinewidth(0.5)"]; "StochasticIntegrateAndFire" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.hierarchical_processes.StochasticIntegrateAndFire",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="Event-driven stochastic discrete dynamical system with two outputs."]; "AbstractProcess" -> "StochasticIntegrateAndFire" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.lib.optimization.solvers.generic.hierarchical_processes.AugmentedTermsProcess(*args, **kwargs)

Bases: AbstractProcess

Process implementing cost coefficients as synapses.

class lava.lib.optimization.solvers.generic.hierarchical_processes.ContinuousConstraintsProcess(shape_in, shape_out, problem, backend, hyperparameters=None, name=None, log_config=None)

Bases: AbstractProcess

Process implementing continuous constraints via neurons and synapses.

class lava.lib.optimization.solvers.generic.hierarchical_processes.ContinuousVariablesProcess(shape, problem, backend, hyperparameters=None, name=None, log_config=None)

Bases: AbstractProcess

Process which implementation holds the evolution of continuous variables on the solver of an optimization problem.

class lava.lib.optimization.solvers.generic.hierarchical_processes.CostConvergenceChecker(shape, name=None, log_config=None)

Bases: AbstractProcess

Process that continuously monitors cost convergence.

cost_components

Additive contributions to the total cost.

Type:

InPort

cost_out_last_bytes

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.

Type:

OutPort

cost_out_first_byte

Notifies the next process about the detection of a better cost. Messages the first byte of the new best cost.

Type:

OutPort

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.

class lava.lib.optimization.solvers.generic.hierarchical_processes.DiscreteConstraintsProcess(*args, **kwargs)

Bases: AbstractProcess

Process implementing discrete constraints via synapses.

class lava.lib.optimization.solvers.generic.hierarchical_processes.DiscreteVariablesProcess(shape, cost_diagonal=None, hyperparameters=None, name=None, log_config=None)

Bases: AbstractProcess

Process which implementation holds the evolution of discrete variables on the solver of an optimization problem.

a_in

The addition of all inputs (per dynamical system) at this timestep will be received by this port.

Type:

InPort

s_out

The payload to be exchanged between the underlying dynamical systems when these fire.

Type:

OutPort

local_cost

The cost components per dynamical system underlying these variables, i.e., c_i = sum_j{Q_{ij} cdot x_i} will be sent through this port. The cost integrator will then complete the cost computation by adding all contributions, i.e., x^T cdot Q cdot x = sum_i{c_i}.

Type:

OutPort

variable_assignment

Holds the current value assigned to the variables by the solver network.

Type:

Var

class lava.lib.optimization.solvers.generic.hierarchical_processes.MixedConstraintsProcess(*args, **kwargs)

Bases: AbstractProcess

Process implementing continuous constraints via neurons and synapses.

class lava.lib.optimization.solvers.generic.hierarchical_processes.NEBMAbstract(*, temperature, refract, refract_counter, shape=(1,), init_state=0, input_duration=6, min_state=1000, min_integration=-1000, cost_diagonal=0, name=None, log_config=None, init_value=0)

Bases: AbstractProcess

Event-driven stochastic discrete dynamical system with two outputs.

The main output is intended as input to other dynamical systems on the network, whilst the second output is to transfer local information to be integrated by an auxiliary dynamical system or circuit.

added_input

The addition of all inputs (per dynamical system) at this timestep will be received by this port.

Type:

InPort

replace_assignment

Todo: deprecate

Type:

InPort

messages

The payload to be sent to other dynamical systems when firing.

Type:

OutPort

local_cost

the cost component corresponding to this dynamical system, i.e., c_i = sum_j{Q_{ij} cdot x_i} will be sent through this port. The cost integrator will then complete the cost computation by adding all contributions, i.e., x^T cdot Q cdot x = sum_i{c_i}.

Type:

OutPort

class lava.lib.optimization.solvers.generic.hierarchical_processes.NEBMSimulatedAnnealingAbstract(*, max_temperature=10, min_temperature=0, delta_temperature=1, exp_temperature=None, steps_per_temperature=100, refract_scaling=14, refract, shape=(1,), init_state=0, min_integration=-1000, cost_diagonal=0, name=None, log_config=None, init_value=0, annealing_schedule='linear', neuron_model)

Bases: AbstractProcess

Event-driven stochastic discrete dynamical system with two outputs.

The main output is intended as input to other dynamical systems on the network, whilst the second output is to transfer local information to be integrated by an auxiliary dynamical system or circuit.

added_input

The addition of all inputs (per dynamical system) at this timestep will be received by this port.

Type:

InPort

replace_assignment

Todo: deprecate

Type:

InPort

messages

The payload to be sent to other dynamical systems when firing.

Type:

OutPort

local_cost

the cost component corresponding to this dynamical system, i.e., c_i = sum_j{Q_{ij} cdot x_i} will be sent through this port. The cost integrator will then complete the cost computation by adding all contributions, i.e., x^T cdot Q cdot x = sum_i{c_i}.

Type:

OutPort

class lava.lib.optimization.solvers.generic.hierarchical_processes.SatConvergenceChecker(*args, **kwargs)

Bases: AbstractProcess

Process that continuously monitors satisfiability convergence.

class lava.lib.optimization.solvers.generic.hierarchical_processes.StochasticIntegrateAndFire(*, step_size, shape=(1,), init_state=0, noise_amplitude=1, noise_precision=8, sustained_on_tau=-3, threshold=10, cost_diagonal=0, name=None, log_config=None, init_value=0)

Bases: AbstractProcess

Event-driven stochastic discrete dynamical system with two outputs.

The main output is intended as input to other dynamical systems on the network, whilst the second output is to transfer local information to be integrated by an auxiliary dynamical system or circuit.

added_input

The addition of all inputs (per dynamical system) at this timestep will be received by this port.

Type:

InPort

replace_assignment

Todo: deprecate

Type:

InPort

messages

The payload to be sent to other dynamical systems when firing.

Type:

OutPort

local_cost

the cost component corresponding to this dynamical system, i.e., c_i = sum_j{Q_{ij} cdot x_i} will be sent through this port. The cost integrator will then complete the cost computation by adding all contributions, i.e., x^T cdot Q cdot x = sum_i{c_i}.

Type:

OutPort

lava.lib.optimization.solvers.generic.processes

lava.lib.optimization.solvers.generic.solver

digraph inheritance504d5dfd6c { bgcolor=transparent; rankdir=TB; size=""; "CostIntegratorNcModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.CostIntegratorNcModel",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"]; "NEBMNcModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.NEBMNcModel",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"]; "NEBMSimulatedAnnealingNcModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.NEBMSimulatedAnnealingNcModel",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"]; "NcL2ModelPG" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.NcL2ModelPG",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"]; "NcL2ModelPI" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.NcL2ModelPI",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"]; "NcModelDense" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.NcModelDense",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"]; "NcModelSparse" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.NcModelSparse",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"]; "OptimizationSolver" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.OptimizationSolver",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="Generic solver for constrained optimization problems defined by"]; "ReadGateCModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.ReadGateCModel",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"]; "SolverConfig" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.SolverConfig",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="Dataclass to store and validate OptimizationSolver configurations."]; "SolverReport" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.solver.SolverReport",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="Dataclass to store OptimizationSolver results."]; }
class lava.lib.optimization.solvers.generic.solver.CostIntegratorNcModel

Bases: object

class lava.lib.optimization.solvers.generic.solver.NEBMNcModel

Bases: object

class lava.lib.optimization.solvers.generic.solver.NEBMSimulatedAnnealingNcModel

Bases: object

class lava.lib.optimization.solvers.generic.solver.NcL2ModelPG

Bases: object

class lava.lib.optimization.solvers.generic.solver.NcL2ModelPI

Bases: object

class lava.lib.optimization.solvers.generic.solver.NcModelDense

Bases: object

class lava.lib.optimization.solvers.generic.solver.NcModelSparse

Bases: object

class lava.lib.optimization.solvers.generic.solver.OptimizationSolver(problem)

Bases: object

Generic solver for constrained optimization problems defined by variables, cost and constraints.

The problem should behave according to the OptimizationProblem’s interface so that the Lava solver can be built correctly.

A Lava OptimizationSolverProcess and a Lava OptimizationSolverModel will be created from the problem specification. The dynamics of such process implements the algorithms that search a solution to the problem and reports it to the user.

solve(config=SolverConfig(timeout=1000.0, target_cost=0, backend=<class 'lava.magma.core.resources.CPU'>, hyperparameters=None, probe_cost=False, probe_state=False, probe_time=False, probe_energy=False, log_level=40, folded_compilation=False))

Create solver from problem spec and run until it has either minimized the cost to the target_cost or ran for a number of time steps provided by the timeout parameter.

Parameters:

config (SolverConfig, optional) – Solver configuration used. Refers to SolverConfig documentation.

Returns:

report – An object containing all the data generated by the execution.

Return type:

SolverReport

class lava.lib.optimization.solvers.generic.solver.ReadGateCModel

Bases: object

class lava.lib.optimization.solvers.generic.solver.SolverConfig(timeout=1000.0, target_cost=0, backend=<class 'lava.magma.core.resources.CPU'>, hyperparameters=None, probe_cost=False, probe_state=False, probe_time=False, probe_energy=False, log_level=40, folded_compilation=False)

Bases: object

Dataclass to store and validate OptimizationSolver configurations.

Parameters:
  • timeout (int) – Maximum number of iterations (timesteps) to be run. If set to -1 then the solver will run continuously in non-blocking mode until a solution is found.

  • target_cost (int, optional) – A cost value provided by the user as a target for the solution to be found by the solver, when a solution with such cost is found and read, execution ends.

  • backend (BACKENDS, optional) – Specifies the backend where the main solver network will be deployed.

  • hyperparameters (Union[Dict, List[Dict], None]) – ty.Union[ty.Dict, ty.Dict[str, ty.Union[int, npt.ArrayLike]]], optional. A dictionary specifying values for steps_to_fire, noise_amplitude, step_size and init_value. All but the last are integers, the initial value is an array-like of initial values for the variables defining the problem.

  • probe_cost (bool) – A boolean flag to request cost tracking through time.

  • probe_time (bool) – A boolean flag to request time profiling, available only on “Loihi2” backend.

  • probe_energy (bool) – A boolean flag to request time profiling, available only on “Loihi2” backend.

  • log_level (int) – Select log verbosity (40: default, 20: verbose).

  • folded_compilation (bool) – A boolean flag to enable folded compilation, available only on “Loihi2” backend. Default value is False.

backend

alias of CPU

folded_compilation: bool = False
hyperparameters: Union[Dict, List[Dict]] = None
log_level: int = 40
probe_cost: bool = False
probe_energy: bool = False
probe_state: bool = False
probe_time: bool = False
target_cost: int = 0
timeout: int = 1000.0
class lava.lib.optimization.solvers.generic.solver.SolverReport(problem=None, best_cost=None, best_state=None, best_timestep=None, cost_timeseries=None, state_timeseries=None, solver_config=None, profiler=None)

Bases: object

Dataclass to store OptimizationSolver results.

Parameters:
  • best_cost (int) – Best cost found during the execution.

  • best_state (np.ndarray) – Candidate solution associated to the best cost.

  • best_timestep (int) – Execution timestep during which the best solution was found.

  • solver_config (SolverConfig) – Solver configuraiton used. Refers to SolverConfig documentation.

  • profiler (Profiler) – Profiler instance containing time, energy and activity measurements.

best_cost: int = None
best_state: ndarray = None
best_timestep: int = None
cost_timeseries: ndarray = None
problem: OptimizationProblem = None
profiler: Profiler = None
solver_config: SolverConfig = None
state_timeseries: ndarray = None
lava.lib.optimization.solvers.generic.solver.solve(problem, config=SolverConfig(timeout=1000.0, target_cost=0, backend=<class 'lava.magma.core.resources.CPU'>, hyperparameters=None, probe_cost=False, probe_state=False, probe_time=False, probe_energy=False, log_level=40, folded_compilation=False))

Solve the given optimization problem using the passed configuration, and returns the best candidate solution.

Parameters:
  • problem (OptimizationProblem) – Optimization problem to be solved.

  • config (SolverConfig, optional) – Solver configuraiton used. Refers to SolverConfig documentation.

Return type:

ndarray

lava.lib.optimization.solvers.generic.sub_process_models

digraph inheritance1c1c3884e4 { 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)"]; "AbstractSubProcessModel" [URL="../../lava/lava.magma.core.model.sub.html#lava.magma.core.model.sub.model.AbstractSubProcessModel",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 base class for any ProcessModel that derives the behavior of"]; "AbstractProcessModel" -> "AbstractSubProcessModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContinuousConstraintsModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.ContinuousConstraintsModel",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="Model for the ContinuousConstraints process."]; "AbstractSubProcessModel" -> "ContinuousConstraintsModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContinuousVariablesModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.ContinuousVariablesModel",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="Model for the ContinuousVariables process."]; "AbstractSubProcessModel" -> "ContinuousVariablesModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CostConvergenceCheckerModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.CostConvergenceCheckerModel",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="Model for the CostConvergence process."]; "AbstractSubProcessModel" -> "CostConvergenceCheckerModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DiscreteVariablesModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.DiscreteVariablesModel",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="Model for the DiscreteVariables process."]; "AbstractSubProcessModel" -> "DiscreteVariablesModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NEBMAbstractModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.NEBMAbstractModel",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 for an NEBM process."]; "AbstractSubProcessModel" -> "NEBMAbstractModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NEBMSimulatedAnnealingAbstractModel" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.NEBMSimulatedAnnealingAbstractModel",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 for an NEBM process with Simulated Annealing."]; "AbstractSubProcessModel" -> "NEBMSimulatedAnnealingAbstractModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NetL2" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.NetL2",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"]; "StochasticIntegrateAndFireModelSCIF" [URL="../lava-lib-optimization/lava.lib.optimization.solvers.generic.html#lava.lib.optimization.solvers.generic.sub_process_models.StochasticIntegrateAndFireModelSCIF",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="Model for the StochasticIntegrateAndFire process."]; "AbstractSubProcessModel" -> "StochasticIntegrateAndFireModelSCIF" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class lava.lib.optimization.solvers.generic.sub_process_models.ContinuousConstraintsModel(proc)

Bases: AbstractSubProcessModel

Model for the ContinuousConstraints process.

implements_process

alias of ContinuousConstraintsProcess

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
class lava.lib.optimization.solvers.generic.sub_process_models.ContinuousVariablesModel(proc)

Bases: AbstractSubProcessModel

Model for the ContinuousVariables process.

implements_process

alias of ContinuousVariablesProcess

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
class lava.lib.optimization.solvers.generic.sub_process_models.CostConvergenceCheckerModel(proc)

Bases: AbstractSubProcessModel

Model for the CostConvergence process.

The model composes a CostIntegrator unit with incomming connections, in this way, downstream processes can be directly connected to the CostConvergence process.

implements_process

alias of CostConvergenceChecker

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
class lava.lib.optimization.solvers.generic.sub_process_models.DiscreteVariablesModel(proc)

Bases: AbstractSubProcessModel

Model for the DiscreteVariables process.

The model composes a population of StochasticIntegrateAndFire units and connects them via Dense processes as to represent integer or binary variables.

implements_process

alias of DiscreteVariablesProcess

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
class lava.lib.optimization.solvers.generic.sub_process_models.NEBMAbstractModel(proc)

Bases: AbstractSubProcessModel

ProcessModel for an NEBM process.

implements_process

alias of NEBMAbstract

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.Loihi2NeuroCore'>]
class lava.lib.optimization.solvers.generic.sub_process_models.NEBMSimulatedAnnealingAbstractModel(proc)

Bases: AbstractSubProcessModel

ProcessModel for an NEBM process with Simulated Annealing.

implements_process

alias of NEBMSimulatedAnnealingAbstract

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.Loihi2NeuroCore'>]
class lava.lib.optimization.solvers.generic.sub_process_models.NetL2

Bases: object

class lava.lib.optimization.solvers.generic.sub_process_models.StochasticIntegrateAndFireModelSCIF(proc)

Bases: AbstractSubProcessModel

Model for the StochasticIntegrateAndFire process. The process is just a wrapper over the QuboScif process. # Todo deprecate in favour of QuboScif.

implements_process

alias of StochasticIntegrateAndFire

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.Loihi2NeuroCore'>]