Hexaly module

Hexaly 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 hxTimeLimit or hxSolution disappear (but mathematical operators are still available). The global variables must then be replaced by explicit calls to attributes and functions of types HexalyOptimizer, HxModel, HxParam or HxSolution.

Module functions

hexaly.create()

Creates a new optimizer. To be useful, the returned optimizer must be used within a with statement to be considered the active optimizer. 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 hexaly;
...

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

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