Skip to content

Latest commit

 

History

History
96 lines (70 loc) · 4.1 KB

optimization.rst

File metadata and controls

96 lines (70 loc) · 4.1 KB

Neuromorphic Constraint Optimization

A library of solvers that leverage neuromorphic hardware for constrained optimization.

Constrained optimization searches for the values of input variables that minimize or maximize a given objective function, while the variables are subject to constraints. This kind of problem is ubiquitous throughout scientific domains and industries. Constrained optimization is a promising application for neuromorphic computing as it naturally aligns with the dynamics of spiking neural networks. When individual neurons represent states of variables, the neuronal connections can directly encode constraints between the variables: in its simplest form, recurrent inhibitory synapses connect neurons that represent mutually exclusive variable states, while recurrent excitatory synapses link neurons representing reinforcing states. Implemented on massively parallel neuromorphic hardware, such a spiking neural network can simultaneously evaluate conflicts and cost functions involving many variables, and update all variables accordingly. This allows a quick convergence towards an optimal state. In addition, the fine-scale timing dynamics of SNNs allow them to readily escape from local minima.

This Lava repository currently provides constraint optimization solvers that leverage the benefits of neuromorphic computing for the following problems:

  1. Quadratic Programming (QP).

In the future, the library will be extended by solvers targeting further constraint optimization problems that are relevant for robotics and operations research. The current focus lies on solvers for the following problems:

  1. Constraint Satisfaction Problems (CSP).
  2. Quadratic Unconstrained Binary Optimization (QUBO).
  3. Integer Linear Programming (ILP).
  4. Linear Programming (LP).
  5. Mixed-Integer Linear Programming (MILP).
  6. Mixed-Integer Quadratic Programming (MIQP).
Overview_Solvers

Tutorials

QP Solver

  1. [Solving LASSO.](https://github.com/lava-nc/lava-optimization/tree/main/tutorials/qp/tutorial_01_solving_lasso.ipynb)

Example

QP Solver

import numpy as np
from lava.lib.optimization.problems.problems import QP
from lava.lib.optimization.solvers.qp.solver import QPSolver

Q = np.array([[100, 0, 0], [0, 15, 0], [0, 0, 5]])
p = np.array([[1, 2, 1]]).T
A = -np.array([[1, 2, 2], [2, 100, 3]])
k = -np.array([[-50, 50]]).T

alpha, beta = 0.001, 1
alpha_d, beta_g = 10000, 10000
iterations = 400
problem = QP(Q, p, A, k)
solver = QPSolver(
alpha=alpha,
beta=beta,
alpha_decay_schedule=alpha_d,
beta_growth_schedule=beta_g,
)
solver.solve(problem, iterations=iterations)

Coming up next: CSPSolver

from lava.lib.optimization import CspSolver

variables = ['var1', 'var2', 'var3']
domains = dict(var1 = {0, 1, 2}, var2 = {'a', 'b', 'c'}, var3 ={'red', 'blue', 'green'})
solver = CspSolver(problem=(variables, domains, constraints))
solution, t_sol = solver.solve(timeout=5000, backend='Loihi1')
solution, t_sol = solver.solve(timeout=5000, backend='Loihi2', profile=True)
print(solver.time_to_solution)
print(solver.energy_to_solution)

Requirements

  1. Working installation of Lava [see Lava installation tutorial.](https://github.com/lava-nc/lava/blob/main/src/lava/tutorials/in_depth/tutorial01_installing_lava.ipynb)

Setup

  1. Clone the lava-optimization repository.
  2. Add lava-optimization/src to your PYTHONPATH variable. For example, run "export PYTHONPATH=$PYTHONPATH:$(pwd)" from lava-optimization/src/ on your terminal (You should do this only after having added Lava to your PYTHONPATH. This order is required for namespaces to be well defined).