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 assum
,min
,max
,bool
,list
) nor the keywordsminimize
,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); }