This page is for an old version of Hexaly Optimizer. We recommend that you update your version and read the documentation for the latest stable release.

LSBBModel Class

class localsolver.LSBBModel

Mathematical optimization model. A model is composed of a native function (the blackbox), a number of decisions and a function call that associates the decisions and the function. Once your optimization model is created and closed, the solver can be launched to resolve it. Note that you cannot modify a model which has been closed.

See:LSBBExpression
See:LSBBOperator

Summary

Methods
GetLocalSolverBlackBox Returns the LocalSolverBlackBox object associated to this model.
Call Creates a call expression.
CreateNativeFunction Creates a native function.
Bool Creates a boolean decision.
Int Creates an integer decision.
Float Creates a float decision.
AddObjective Setss the given expression to be the list of objectives to optimize.
Close Closes the model.
IsClosed Returns true if the model is closed, false otherwise.

Instance methods

LocalSolverBlackBox GetLocalSolverBlackBox()

Returns the LocalSolverBlackBox object associated to this model.

Returns:LocalSolverBlackBox object
Return type:LocalSolverBlackBox
LBBExpression Call()

Creates a call expression. First operand must be an LSBBExpression of type LSBBOperator.NativeFunction. The other operands must be booleans, integers or doubles decisions.

Returns:Expression of type LSBBOperator.Call
Return type:LSBBExpression
LSBBExpression CreateNativeFunction(LSBBNativeFunction function)

Creates a native function. The provided function must take the native context (LSBBNativeContext) associated to the function as single argument and must return a double value.

Once you instanciated it, you have to pass arguments to your function and call it. For that, you have to create expressions of type LSBBOperator.Call. The first operand must be your native function. The other operands must be LSBBExpressions. Their value will be made accessible to your function through the native context.

Note 1: Most of the time your native function will be called when the solver is in state LSBBState.Running. Do not attempt to call any method of the solver (to retrieve statistics, values of LSBBExpressions or whatever) in that state or an exception will be thrown. The only accessible function is :LocalSolverBlackBox.Stop().

Arguments:function (LSBBNativerFunction) – Function to call.
Returns:Expression of type LSBBOperator.NativeFunction.
Return type:LSBBExpression
LBBExpression Bool()

Creates a boolean decision. Binary decision variable with domain [0.1].

Returns:Expression of type LSBBOperator.Bool
Return type:LSBBExpression
LBBExpression Int(long min, long max)

Creates an integer decision. Decision variable with domain [min,max]. Bounds of the variable must be booleans or integers.

Returns:Expression of type LSBBOperator.Int
Return type:LSBBExpression
LBBExpression Float(double min, double max)

Creates a float decision. Decision variable with domain [min,max]. Bounds of the variable must be booleans, integers or doubles.

Returns:Expression of type LSBBOperator.Float
Return type:LSBBExpression
void AddObjective(LSBBExpression expr, LSBBObjectiveDirection direction)

Setss the given expression to be the list of objectives to optimize. A same expression can be added more than once. Only allowed in state LSState.Modeling.

Arguments:
void Close()

Closes the model. Only allowed in state LSBBState.Modeling. Once the model is closed, no expression, constraints or objectives can be added. The model must be closed before starting its resolution. When the model is closed, the state of the LocalSolver changed from LSBBState.Modeling to LSBBState.Stopped.

bool IsClosed()

Returns true if the model is closed, false otherwise.

Returns:True if the model is closed.
Return type:bool