# Should you use JuMP?

JuMP is an algebraic modeling language for mathematical optimization written in the Julia language.

This page explains when you should consider using JuMP, and importantly, when you should *not* use JuMP.

## When should you use JuMP?

You should use JuMP if you have a constrained optimization problem for which you can formulate using the language of mathematical programming, that is:

- a set of decision variables
- a scalar- or vector-valued objective function
- a set of constraints.

Key reasons to use JuMP include:

- User friendliness
- JuMP has syntax that mimics natural mathematical expressions. (See the section on algebraic modeling languages.)

- Solver independence
- JuMP uses a generic solver-independent interface provided by the MathOptInterface package, making it easy to change between a number of open-source and commercial optimization software packages ("solvers"). The Supported solvers section contains a table of the currently supported solvers.

- Ease of embedding
- JuMP itself is written purely in Julia. Solvers are the only binary dependencies.
- JuMP provides automatic installation of many open-source solvers. This is different to modeling languages in Python which require you to download and install a solver yourself.
- Because it is embedded in a general-purpose programming language, JuMP makes it easy to solve optimization problems as part of a larger workflow, for example, inside a simulation, behind a web server, or as a subproblem in a decomposition algorithm. As a trade-off, JuMP's syntax is constrained by the syntax and functionality available in Julia.
- JuMP is MPL licensed, meaning that it can be embedded in commercial software that complies with the terms of the license.

- Speed
- Benchmarking has shown that JuMP can create problems at similar speeds to special-purpose modeling languages such as AMPL.
- JuMP communicates with most solvers in memory, avoiding the need to write intermediary files.

- Access to advanced algorithmic techniques
- JuMP supports efficient
*in-memory*re-solves of linear programs, which previously required using solver-specific or low-level C++ libraries. - JuMP provides access to solver-independent and solver-dependent Callbacks.

- JuMP supports efficient

## When should you not use JuMP?

JuMP supports a broad range of optimization classes. However, there are still some that it doesn't support, or that are better supported by other software packages.

### You want to optimize a complicated Julia function

Packages in Julia compose well. It's common for people to pick two unrelated packages and use them in conjunction to create novel behavior. JuMP isn't one of those packages.

If you want to optimize an ordinary differential equation from DifferentialEquations.jl or tune a neural network from Flux.jl, consider using other packages such as:

### Black-box, derivative free, or unconstrained optimization

JuMP does support nonlinear programs with constraints and objectives containing user-defined operators. However, the functions must be automatically differentiable, or need to provide explicit derivatives. (See User-defined operators for more information.)

If your function is a black-box that is non-differentiable (for example, it is the output of a simulation written in C++), JuMP is not the right tool for the job. This also applies if you want to use a derivative free method.

Even if your problem is differentiable, if it is unconstrained there is limited benefit (and downsides in the form of more overhead) to using JuMP over tools which are only concerned with function minimization.

Alternatives to consider are:

### Optimal control problems

JuMP supports formulating optimal control problems as large nonlinear programs (see, for example, Optimal control for a Space Shuttle reentry trajectory). However, the nonlinear interface has a number of limitations (for example, the need to write out the dynamics in algebraic form) that mean JuMP might not be the right tool for the job.

Alternatives to consider are:

### Disciplined convex programming

JuMP does not support disciplined convex programming (DCP).

Alternatives to consider are:

`Convex.jl`

is also built on MathOptInterface, and shares the same set of underlying solvers. However, you input problems differently, and Convex.jl checks that the problem is DCP.

### Stochastic programming

JuMP requires deterministic input data.

If you have stochastic input data, consider using a JuMP extension such as:

### Polyhedral computations

JuMP does not provide tools for working with the polyhedron formed by the set of linear constraints.

Alternatives to consider are:

- Polyhedra.jl (See the documentation to create a polyhedron from a JuMP model.)