Ceres.js Logo

Ceres.js

Numerical Optimization Library in JavaScript

Introduction

Ceres.js is a javascript port of the Ceres solver. Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It can be used to solve Non-linear Least Squares problems with bounds constraints and general unconstrained optimization problems. It is a mature, feature rich, and performant library.

About

Ceres.js is a port of the Ceres solver. There are js libraries such as math.js and algebrite.js that do have some capabilities to solve LINEAR systems of equations. The purpose of Ceres.js is to have a robust solver for the non-linear equations. The authors are not aware of another js library that solves systems of non-linear equations numerically. Ceres js works best when you give it a set of equations F(x)=0 with an zero solution. If you need to do constrained maximization or minimization there is another library Alglib.js that can do that.

Key Questions:

Do you have a single equation or a system of multiple equations? Ceres.js will work with both but may be overkill for the single equation.

Are you trying to find the zeros of that system, F(x)=0, or seeing to minimize a cost function? Ceres.js finds the zeros of a system.

Are your equations linear or non-linear? Ceres.js will solve both linear and non-linear. If you only have linear equations there are likely more optimized solvers to do that job.

Examples

User Defined Function

This is an example of the solution of the user defined function using Ceres.js

JSON Syntax Demo Function

This is an example using the JSON syntax with Ceres.js

Powell Function

This is an example of the solution of the powell function using Ceres.js

Quadratic Function

This is an example of the solution of the quadratic function using Ceres.js

Rosebrock Function

This is an example of the solution of the Rosenbrock function using Ceres.js

Documentation

The Ceres class starts an instance of the Ceres solver. It has several methods for configuration, interaction, and operation as detailed below.

Exported Modules:

Class: Ceres

Code Generator

y=2 \cdot x^2-8 \cdot x-3

y = x+2

x = ??; Guess = 4

y = ??; Guess = 1