This repository provides a toolkit for modeling and solving optimization problems, with a focus on energy-based models. It includes:
- A Rust/Node.js library for defining and evaluating quadratic energy functions.
- Theoretical documentation and examples of optimization models from physics, finance, and machine learning.
library/
: Rust + Neon-based Node.js library for optimization models.theory/
: Mathematical background and model documentation (model.md
).simulation/
: (Currently empty) Intended for simulation scripts or notebooks.
The core model minimizes an energy function of the form:
This generalizes many problems, including portfolio optimization, spin glasses, neural networks, and image segmentation. See theory/model.md
for details and examples.
The library/
folder contains a Rust library with Neon bindings for Node.js. Main features:
- Define a model with parameters (alpha, beta, A, b, C)
- Compute the energy (score) for a given configuration
Requirements: Node.js and Rust (platform support)
cd library
npm install
npm run build
const { createModel } = require('./index.node');
const alpha = 1.0, beta = 0.5;
const a = [[1, 0], [0, 1]];
const b = [1, -1];
const c = [0.2, 0.3];
const model = createModel(alpha, beta, a, b, c);
console.log(model.score); // Energy value
npm install
: Installs dependencies and builds the addonnpm run build
: Release buildnpm run debug
: Debug buildnpm run cross
: Cross-compile for other platformsnpm test
: Run Rust unit tests
See theory/model.md
for:
- Mathematical formulation
- Convex vs. non-convex cases
- Example models: Markowitz, Ising, Hopfield, Graph Cuts, etc.
ISC