LocalSolver 9.5¶
Caution
This update introduces a number of breaking changes in the APIs.
Release notes
- Native functions have been replaced by external functions which offer additional functionalities.
- The black-box API has been merged with the rest of the LocalSolver API and offers additional functionalities.
- LocalSolver functions have been renamed lambda functions.
- The solver API has been extended to support custom log writers.
External Functions¶
Native functions have been replaced by external functions. With this change comes the ability to specify the return type of your function (integer or double) which can help the solver better perform for your particular problem.
Native contexts have been replaced by external argument values which serve the same purpose of carrying the values of the arguments passed to the external function.
You can now provide additional data for your external function: a lower bound, an upper bound, and whether or not the function may return a NaN value. This is made possible thanks to the external context associated with your function. This too can help the solver with performance but you must be careful about the data your provide. If a function returns an unexpected value, the solver will throw an exception.
For more details about external functions, please check out the section on external functions in the advanced features.
Black-box optimization¶
Black-box functions were previously contained to their own black-box API but have now been merged with the rest of LocalSolver’s API. While this does not mean any functional change for now, we aim to integrate most of LocalSolver features with the black-box optimization process in the future.
As with external functions, what was known as the black-box native context has been replaced by black-box argument values. The new black-box context, can now be used to provide data for your function (bounds and whether or not the function may return a NaN value). It can also be used to parameterize the optimization process by setting a maximum number of calls to the optimized function.
When a model contains a black-box function, LocalSolver will automatically make use of its black-box optimization solver.
Note that only the following operators are allowed in a black-box model: bool, integers and float variables, as well as constants and black-box functions.
For more details about black-box functions, please check out the section on black-box optimization in the advanced features.
Lambda Functions¶
To avoid any confusions with external and black-box functions, what was known as functions in LocalSolver has been renamed to lambda functions. Unfortunately, this means that all models making use of this type of expression must be updated to work with LocalSolver 9.5.
API Changes¶
LSP¶
- Replaced the built-in method
nativeFunction()
byintExternalFunction()
anddoubleExternalFunction()
. These methods enable you to specify the return type of the function when it is added to the model. - The context of the function can be accessed by addressing the
context
field of the function expression.
Python¶
- Added support for Python 3.8 and 3.9.
- Replaced the method
LSModel.create_native_function()
by the two following methods: - Replaced the operator
NATIVE_FUNCTION
byEXTERNAL_FUNCTION
. - Replaced the class
LSNativeContext
byLSExternalArgumentValues
. - Added
LSExpression.get_external_context()
andLSExpression.external_context
to access the context of external functions. - Added
LSModel.create_double_blackbox_function()
to create black-box functions. - Added the operator
BLACKBOX_FUNCTION
. - Replaced the class
LSBBNativeContext
byLSBlackBoxArgumentValues
. - Added
LSExpression.get_blackbox_context()
andLSExpression.blackbox_context
to access the context of black-box functions. - Replaced the method
LSModel.create_function
byLSModel.create_lambda_function()
. - Added the methods
LSParam.set_log_writer()
,LSParam.get_log_writer()
and the attributeLSParam.log_writer
C++¶
- Replaced the interface
LSNativeFunction
byLSExternalFunction
interface. - Replaced the operator
O_NativeFunction
byO_ExternalFunction
. - Replaced the method
LSModel::createNativeFunction()
byLSModel::createExternalFunction()
. - Replaced the class
LSNativeContext
byLSExternalArgumentValues
. - Added
LSExpression::getExternalContext()
to access the context of external functions. - Added the
LSBlackBoxFunction
interface. - Added the operator
O_BlackBoxFunction
. - Added
LSModel::createBlackBoxFunction()
to create black-box functions. - Replaced the class
LSBBNativeContext
byLSBlackBoxArgumentValues
. - Added
LSExpression::getBlackBoxContext()
to access the context of black-box functions. - Replaced
LSModel::createFunction()
byLSModel::createLambdaFunction()
. - Added
LSParam::setLogWriter()
andLSParam::getLogWriter()
.
C#¶
- Dropped support for .NET Framework 4.0 and older.
- Replaced the delegate
LSNativeFunction
by the two delegates:LSIntExternalFunction
andLSDoubleExternalFunction
. - Replaced the operator
NativeFunction
byExternalFunction
. - Replaced the method
LSModel.CreateNativeFunction()
by the two following methods: - Replaced the class
LSNativeContext
byLSExternalArgumentValues
. - Added
LSExpression.GetExternalContext()
to access the context of external functions. - Added the delegate
LSDoubleBlackBoxFunction
. - Added the operator
BlackBoxFunction
. - Added
LSModel.CreateDoubleBlackBoxFunction()
to create black-box functions. - Replaced the class
LSBBNativeContext
byLSBlackBoxArgumentValues
. - Added
LSExpression.GetBlackBoxContext()
to access the context of black-box functions. - Replaced the method
LSModel.CreateFunction()
byLSModel.CreateLambdaFunction()
. - Added
LSParam.SetLogWriter()
andLSParam.GetLogWriter()
.
Java¶
- Replaced the interface
LSNativeFunction
by the two interfaces:LSIntExternalFunction
andLSDoubleExternalFunction
. - Replaced the operator
NativeFunction
byExternalFunction
. - Replaced the method
LSModel.createNativeFunction()
by the two following methods:LSModel.createIntExternalFunction()
,LSModel.createDoubleExternalFunction()
.
- Replaced the class
LSNativeContext
byLSExternalArgumentValues
. - Added
LSExpression.getExternalContext()
to access the context of external functions. - Added the interface
LSDoubleBlackBoxFunction
. - Added the operator
BlackBoxFunction
. - Added
LSModel.createDoubleBlackBoxFunction
to create black-box functions. - Replaced the class
LSBBNativeContext
byLSBlackBoxArgumentValues
. - Added
LSExpression.getBlackBoxContext()
to access the context of black-box functions. - Replaced the method
LSModel.createFunction
byLSModel.createLambdaFunction()
. AllLSFunction
interfaces have also been renamed toLSLambdaFunction
. - Added
LSParam.setLogWriter()
andLSParam.getLogWriter()
.