LocalSolver environment.
Main class of LocalSolver library. Here are described the basic steps for using LocalSolver:
- Build your model (LSModel) by creating some expressions (LSExpression).
- If desired, parameterize and add phases to the solver (LSParam, LSPhase).
- Run the solver (LocalSolver).
- Retrieve the best solution found by the solver (LSSolution).
- Consult the statistics of the resolution (LSStatistics).
Note that this API is not thread safe. If multiple threads access and modify a same LocalSolver environment, it must be synchronized. The only methods that can be used without synchronization are getState() and stop().
Please consult LSVersion for copyright and version info.
| localsolver::LocalSolver::~LocalSolver |
( |
| ) |
|
|
inline |
Deletes this LocalSolver environment and all associated objects.
In particular, the model, its expressions, the phases, the statistics, and the solution are deleted. The token license is then released.
| void localsolver::LocalSolver::saveEnvironment |
( |
const std::string & |
filename | ) |
const |
|
inline |
Exports the complete environment (model, parameters, solution, ..) in a file.
This method is useful to debug or replay a model in the same conditions.
Currently, this function supports 2 file formats : LSM and LSB. These two formats reproduce all the parameters and the features of this API. The main difference between LSM and LSB files is the way the fields are organized : LSB files are binary files. They are less readable but offer better performance and are more space-efficient than LSM files.
The chosen file format is determined by the file suffix. An exception is thrown if the provided file suffix is not supported. The suffix may optionally be followed by .gz. In that case, this function produces a compressed result (using deflate algorithm).
- Parameters
-
| filename | Name of the file. |
- See Also
- LocalSolver::loadEnvironment
- Since
- 3.0
| void localsolver::LocalSolver::loadEnvironment |
( |
const std::string & |
filename | ) |
|
|
inline |
Import a complete environment or a model from a file.
Only allowed in state S_Modeling. The current model must be empty.
Currently, this function supports 4 main file formats : LSM, LSB, LP and MPS. The first two are preferable since they are the native format of LocalSolver. The other ones are classically used by linear programming solvers. LocalSolver supports only a subset of features exposed by these last formats. Please refer to the documentation for more details on this subject.
The chosen file format is determined by the file suffix. An exception is thrown if the provided file suffix is not supported. The suffix may optionally be followed by .gz. In that case, this function uncompress the stream before reading.
- Parameters
-
| filename | Name of the file. |
- See Also
- LocalSolver::saveEnvironment
- Since
- 3.0
| void localsolver::LocalSolver::addCallback |
( |
LSCallbackType |
type, |
|
|
LSCallback |
callback, |
|
|
void * |
userdata |
|
) |
| |
|
inline |
Add a new callback for a specific event type.
The callback will be called each time the given event occurs. When a callback is called, the solver is paused. You can stop the resolution from a callback, retrieve the current solution, retrieve the statistics of the solver and, in general, call all the methods marked as "allowed in state {@link #S_Paused}".
The same callback can be used for different events.
Only allowed in states S_Stopped or S_Modeling.
- Parameters
-
| type | Event to watch. |
| callback | User callback. Cannot be null. |
| userdata | A pointer to a user structure. |
- Since
- 4.0