LSBBModel Class

class localsolverblackbox::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.



call Creates a call expression.
createNativeFunction Creates a native function.
createEvaluationPoint Creates an evaluation point.
boolVar Creates a boolean decision.
intVar Creates an integer decision.
floatVar Creates a float decision.
addObjective Sets the given expression to be the current objective to optimize.
close Closes the model.
isClosed Returns true if the model is closed, false otherwise.


LSBBExpression call()

Creates a call expression.

LSBBExpression createNativeFunction(LSBBNativeFunction *func)

Creates a native function.

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

Note 1: Most of the time your native function will be called when the solver is in state S_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().

Note 2: LocalSolverBlackBox does not manage memory of objects created outside of its environment. Thus, you have to explicitly delete your LSBBNativeFunction at the end of the search.

Return:The expression associated to the function.
Parameters:func - Native function to call.

LSBBEvaluationPoint createEvaluationPoint(LSBBExpression expr)

Creates an evaluation point.

Once it is instantiated, you have to set the values for the function’s arguments and the value returned by the function at this point. Only allowed in state S_Stopped.

Return:An evaluation point associated with the function.
Parameters:expr - Expression of type O_NativeFunction.

LSBBExpression boolVar()

Creates a boolean decision.

Binary decision variable with domain [0.1].


LSBBExpression intVar(lsint minValue, lsint maxValue)

Creates an integer decision.

Decision variable with domain [min,max].


LSBBExpression floatVar(lsdouble minValue, lsdouble maxValue)

Creates a float decision.

Decision variable with domain [min,max].


void addObjective(LSBBExpression expr, LSBBObjectiveDirection dir)

Sets the given expression to be the current objective to optimize.

Only allowed in state S_Modeling.

  • expr - Expression of type O_Call.
  • dir - Optimization direction of this objective.

void close()

Closes the model.

Only allowed in state S_Modeling. Once the model is closed, no expression, constraints or objectives can be added. The model must be closed before starting its resolution.

bool isClosed() const

Returns true if the model is closed, false otherwise.

Return:True if the model is closed.