Optimization and root finding

Solve linear programs with linprog, find roots with fzero and fsolve, and minimize with fminbnd, fminunc, fminsearch and fmincon.

  • Existing MATLAB optimization code runs as written
  • Linear programs, root finding and nonlinear minimization
  • Exit flags and evaluation counts for every solve
  • Free to try, with nothing to install
Download RunMat

Explore the RunMat runtime

The feasible region of a two-product linear program with its optimal corner marked, drawn by RunMat from the saved analysis study
A weekly production plan as a linear program, solved with linprog and drawn by RunMat. The profit line touches the feasible region at (2, 6), for a profit of 36.

Why use RunMat for optimization

No toolbox to buy for linprog and fmincon

Solving a linear program or a constrained design problem usually means paying for an optimization toolbox, or waiting for a shared license. linprog, intlinprog, fmincon, fsolve and lsqnonlin are part of the RunMat runtime, free for individuals, education, research and smaller companies.

Runtime

Run hundreds of scenarios on every core

Solving the same model for hundreds of cost scenarios or start points one at a time keeps a single core busy. A parfor loop spreads the solves across every core and returns the same answers at any worker count.

Parallel

Know when a solve didn't converge

A solver that stops early can return a point that looks like an answer. Each solver returns its exit flag, iteration count and number of function evaluations with the result, so a failed solve is caught before its numbers are used.

Function reference

Re-solve when a price or limit changes

The objective, the limits and the solver call live in one script. When a cost or a capacity changes, edit the number and run it again, and each run keeps its inputs and answer for comparison.

Desktop app

Examples

Bar chart of the shadow price of each machine-hour limit, rendered by RunMat

Shadow prices

An hour on machine 2 is worth 1.50 and on machine 3 1.00; machine 1 has 2 idle hours.

Contours of Rosenbrock's function beside the evaluation count of each solver, rendered by RunMat

Three solvers on Rosenbrock

From (-1.2, 1): fminsearch takes 159 evaluations, fminunc 156, and 53 with a gradient.

Darcy friction factor against Reynolds number for four wall roughness values, rendered by RunMat

Pipe friction from Colebrook

One fzero call per point gives the friction factor across Reynolds number and roughness.

A circle and an exponential curve with the two solutions fsolve found, rendered by RunMat

Two equations, two unknowns

fsolve finds a different intersection from each of two starting points.

Surface area of a one-liter can against its radius, with the minimum marked, rendered by RunMat

Least metal for a one-liter can

fminbnd finds a radius of 5.42 cm, where the height equals the diameter.

Area contours of beam sections with the deflection and depth limits and the optimum marked, rendered by RunMat

Lightest cantilever section

fmincon finds 35 by 140 mm, held by the deflection and depth limits.

Starting points on a contour plot of peaks, colored by where fminunc stops, rendered by RunMat

Local and global minima

Of 81 starts on peaks, 19 reach the global minimum, 21 a local one and 41 drift away.

Feasible region of a small integer program with its integer points and both optima, rendered by RunMat

Whole units only

The best integer point, (4, 0), is worth 20; the relaxation's corner, (3, 1.5), is worth 21.

Error and function evaluations of fminunc at five tolerance settings, rendered by RunMat

Why the solver stopped

Past a tolerance of 1e-6 the error stays near 1e-5, the limit of finite-difference gradients.

Try it on your own data

Download RunMat
Read the docs