All Projects → lava-nc → lava-optimization

lava-nc / lava-optimization

Licence: BSD-3-Clause license
Constraint Optimization with Lava

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to lava-optimization

lava
A Software Framework for Neuromorphic Computing
Stars: ✭ 256 (+1013.04%)
Mutual labels:  neuromorphic, neuromorphic-computing
stlbfgs
C++ L-BFGS implementation using plain STL
Stars: ✭ 21 (-8.7%)
Mutual labels:  solver
mSAT
A modular sat/smt solver with proof output.
Stars: ✭ 91 (+295.65%)
Mutual labels:  solver
pyaer
Low-level Python APIs for Accessing Neuromorphic Devices.
Stars: ✭ 20 (-13.04%)
Mutual labels:  neuromorphic-computing
SkytilsMod
A Hypixel Skyblock Utilities mod
Stars: ✭ 236 (+926.09%)
Mutual labels:  solver
norse
Deep learning for spiking neural networks
Stars: ✭ 59 (+156.52%)
Mutual labels:  neuromorphic-computing
SiEPIC Photonics Package
A Python (v3.6.5) package that provides a set of basic functions commonly used in integrated photonics.
Stars: ✭ 22 (-4.35%)
Mutual labels:  solver
CapMonsterCloud
a C# wrapper for CapMonster Cloud API
Stars: ✭ 17 (-26.09%)
Mutual labels:  solver
Hodoku
Hodoku is a solver/generator/trainer/analyzer for standard sudoku.
Stars: ✭ 49 (+113.04%)
Mutual labels:  solver
dae-cpp
A simple but powerful C++ DAE (Differential Algebraic Equation) solver
Stars: ✭ 33 (+43.48%)
Mutual labels:  solver
flipy
A Python linear programming interface library
Stars: ✭ 23 (+0%)
Mutual labels:  solver
sudokufx
AR Sudoku grabber and solver using JavaCV, JavaFX and Scala
Stars: ✭ 64 (+178.26%)
Mutual labels:  solver
odex-js
Bulirsch-Stoer integration of systems of ordinary differential equations in JavaScript
Stars: ✭ 52 (+126.09%)
Mutual labels:  solver
libdnf
Package management library.
Stars: ✭ 157 (+582.61%)
Mutual labels:  solver
philsol
Simple python library for calculating the modes of electromagnetic waveguides using finite difference frequency domain method.
Stars: ✭ 21 (-8.7%)
Mutual labels:  solver
WarpPI
WarpPI Calculator, Step-by-step algebra calculator for Raspberry Pi. (abandoned project)
Stars: ✭ 93 (+304.35%)
Mutual labels:  solver
PyMiniSolvers
A Python API for the MiniSat and MiniCard constraint solvers.
Stars: ✭ 18 (-21.74%)
Mutual labels:  solver
blt
Lattice-based integer linear programming solver
Stars: ✭ 60 (+160.87%)
Mutual labels:  solver
ruzzle-solver
A python script that solves ruzzle boards
Stars: ✭ 46 (+100%)
Mutual labels:  solver
backtrex
Backtracking behaviour to solve discrete problems by brute force
Stars: ✭ 22 (-4.35%)
Mutual labels:  solver

Neuromorphic Constraint Optimization Library

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:

  • 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:

  • Constraint Satisfaction Problems (CSP)
  • Quadratic Unconstrained Binary Optimization (QUBO)
  • Integer Linear Programming (ILP)
  • Linear Programming (LP)
  • Mixed-Integer Linear Programming (MILP)
  • Mixed-Integer Quadratic Programming (MIQP)

Overview_Solvers

Tutorials

QP Solver

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 = CSP(variables, domains, constraints)
solution, t_sol = solver.solve(problem, timeout=5000, backend='Loihi2', profile=True)
print(solver.time_to_solution[-1], solver.energy_to_solution[-1])

Requirements

Installation

[Linux/MacOS]

cd $HOME
git clone [email protected]:lava-nc/lava-optimization.git
cd lava-optimization
pip install "poetry>=1.1.13"
poetry config virtualenvs.in-project true
poetry install
source .venv/bin/activate
pytest

[Windows]

# Commands using PowerShell
cd $HOME
git clone git@github.com:lava-nc/lava-optimization.git
cd lava-optimization
python3 -m venv .venv
.venv\Scripts\activate
pip install -U pip
pip install "poetry>=1.1.13"
poetry config virtualenvs.in-project true
poetry install
pytest

You should expect the following output after running the unit tests:

$ pytest
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/user/src/lava-optimization, configfile: pyproject.toml, testpaths: tests
plugins: cov-3.0.0
collected 14 items                                                                                                                                                            

tests/lava/lib/optimization/solvers/qp/test_models.py .......                                                                                                           [ 50%]
tests/lava/lib/optimization/solvers/qp/test_process.py .......                                                                                                          [100%]

---------- coverage: platform linux, python 3.8.10-final-0 -----------
Name                                                Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------------
src/lava/lib/optimization/__init__.py                   0      0   100%
src/lava/lib/optimization/problems/__init__.py          0      0   100%
src/lava/lib/optimization/problems/problems.py         43     29    33%   48-107, 111, 115, 119, 123, 127
src/lava/lib/optimization/solvers/__init__.py           0      0   100%
src/lava/lib/optimization/solvers/qp/__init__.py        0      0   100%
src/lava/lib/optimization/solvers/qp/models.py        136      4    97%   97-98, 102-104
src/lava/lib/optimization/solvers/qp/processes.py      75      0   100%
src/lava/lib/optimization/solvers/qp/solver.py         26     18    31%   42-45, 62-104
---------------------------------------------------------------------------------
TOTAL                                                 280     51    82%

Required test coverage of 45.0% reached. Total coverage: 81.79%

=============== 14 passed in 8.95s ==============================================

[Alternative] Installing Lava via Conda

If you use the Conda package manager, you can simply install the Lava package via:

conda install lava-optimization -c conda-forge

Alternatively with intel numpy and scipy:

conda create -n lava-optimization python=3.9 -c intel
conda activate lava-optimization
conda install -n lava-optimization -c intel numpy scipy
conda install -n lava-optimization -c conda-forge lava-optimization --freeze-installed
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].