npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@davepagurek/qpsolver

v0.0.5

Published

Do you have some math to do and need a quadratic programming solver? Has the universe conspired to force you to do it in the browser, where you have none of the tools that actual mathematicians would use? I'm in the same boat!

Readme

@davepagurek/qpsolver

Do you have some math to do and need a quadratic programming solver? Has the universe conspired to force you to do it in the browser, where you have none of the tools that actual mathematicians would use? I'm in the same boat!

This library provides an interface to build up expressions you want to optimize. The underlying solver is the quadprog library, which is a JavaScript port of the R package quadprog, which is implemented in Fortran, and just takes in big matrices and vectors for all your terms. This library translates more readable expressions into that format.

Usage

Import QPSolver from the library and use it to create a new system. You can create variables using the solver's createVarible() method. You can then call .add(), .mult(), .sub(), and .div() to construct expressions based on your variables. To each operator, you can pass in other variables, expressions, or numbers.

Tell the system what to minimize with .addCost(), and then you can solve your system with .solve(). Afterwards, you can call .value() on a variable to find the value minimizing the system:

import { QPSolver } from '@davepagurek/qpsolver'

const solver = new QPSolver()
const x = solver.createVariable()

// Minimize x^2 + x
solver.addCost(x.mult(x).add(x))

solver.solve()
console.log(x.value()) // Logs -0.5

It also supports multiple variables:

import { QPSolver } from '@davepagurek/qpsolver'

const solver = new QPSolver()
const x1 = solver.createVariable()
const x2 = solver.createVariable()

// Minimize (x1 - 1)^2 + (x2 - 2)^2
solver.addCost(x1.sub(1).mult(x1.sub(1)))
solver.addCost(x2.sub(2).mult(x2.sub(2)))

solver.solve()
console.log(x1.value()) // Logs 1
console.log(x2.value()) // Logs 2

You can also create constraints by calling .gt(), .lt(), or .eq() on an expression and passing in another expression, variable, or number. You can attach it to the system via its addConstraint method:

import { QPSolver } from '@davepagurek/qpsolver'

const solver = new QPSolver()
const x = solver.createVariable()

// Minimize x^2 + x, given x >= 0
solver.addCost(x.mult(x).add(x))
solver.addConstraint(x.gt(0))

solver.solve()
console.log(x.value()) // Logs 0

Remember, this solves quadratic programming problems with linear constraints. That means:

  • Be careful dividing variables by other variables! If you end up with a rational expression, e.g. (x1 + 1) / (x2 + 1), the solver will throw an error.
  • You can't create cubic (or higher!) terms, that will also throw an error.