LocalSolver logo
is now
Hexaly logo

We're excited to share that we are moving forward. We're leaving behind the LocalSolver brand and transitioning to our new identity: Hexaly. This represents a leap forward in our mission to enable every organization to make better decisions faster when faced with operational and strategic challenges.


LocalSolver module

Localsolver module contains all the functions, types and objects that are used to start, control and query the optimization process.

Unlike the other modules, you don’t have to write any special import to use the features of this module. Most of the functions and objects are directly exposed as global variables. These variables and the modeling operators are detailed in the page Builtin functions and variables.

The use of the main mode is the only case that requires an explicit inclusion of this module. In the latter case, the global variables like lsTimeLimit or lsSolution disappear (but mathematical operators are still available). The global variables must then be replaced by explicit calls to attributes and functions of types LocalSolver, LSModel, LSParam or LSSolution.

Module functions

localsolver.create()

Creates a new optimization solver. To be useful, the returned solver must be used within a with statement to be considered the active solver. Otherwise, you will not be able to use the mathematical modeling functions (such as sum, min, max, bool, list) nor the keywords minimize, maximize, constraint:

use localsolver;
...

// As there is no active solver, the global mathematical operators will throw exceptions.
ls = localsolver.create();
maximize bool() + int(0, 100); // Error

// For the duration of the ``with statement``, ``ls`` is considered the active solver.
// The solver and all its resources are also automatically released at the end of the with.
with(ls = localsolver.create()) {
    maximize bool() + int(0, 100);
}