public class LocalSolver
extends java.lang.Object
LSModel) by creating some expressions (LSExpression).LSParam, LSPhase).LocalSolver).LSSolution).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.
| Constructor and Description |
|---|
LocalSolver()
Constructs a complete LocalSolver environment and take a token license.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCallback(LSCallbackType type,
LSCallback callback)
Adds a new callback for a specific event type.
|
LSInconsistency |
computeInconsistency()
Computes an inconsistency core for this model.
|
LSPhase |
createPhase()
Adds a new phase to this LocalSolver environment.
|
void |
delete()
Deletes the LocalSolver objects and release the license token.
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getInfo()
Returns useful info about the search while running.
|
LSModel |
getModel()
Gets the model associated to this LocalSolver environment.
|
int |
getNbPhases()
Gets the number of phases.
|
LSParam |
getParam()
Gets the parameters of this LocalSolver environment.
|
LSPhase |
getPhase(int phaseIndex)
Gets the phase with the given index.
|
LSSolution |
getSolution()
Gets the best solution found by the solver.
|
LSState |
getState()
Gets the state of this LocalSolver environment.
|
LSStatistics |
getStatistics()
Gets the statistics of this LocalSolver environment.
|
int |
hashCode() |
void |
loadEnvironment(java.lang.String filename)
Import a complete environment or a model from a file.
|
boolean |
removeCallback(LSCallbackType type,
LSCallback callback)
Removes the callback for the given event type.
|
void |
saveEnvironment(java.lang.String filename)
Exports the complete environment (model, parameters, solution, ..) in a
file.
|
void |
solve()
Solves the model.
|
void |
stop()
Aborts the resolution previously launched using
solve(). |
java.lang.String |
toString() |
public LocalSolver()
public void delete()
public LSState getState()
LSState.Running.public LSModel getModel()
solve().public LSParam getParam()
public void solve()
public LSInconsistency computeInconsistency()
LSState.Stopped.public void stop()
solve(). If no
resolution was launched, this method does nothing. Called from another
thread, this method enables users to stop the resolution properly.
Solution and statistics remain valid. This method can be called in any
state, notably in state LSState.Running.public LSPhase createPhase()
LSState.Stopped.public LSPhase getPhase(int phaseIndex)
LSState.Paused or LSState.Stopped.phaseIndex - Index of the phase.public int getNbPhases()
LSState.Paused
or LSState.Stopped.public LSSolution getSolution()
LSState.Paused or LSState.Stopped.public LSStatistics getStatistics()
LSState.Paused or LSState.Stopped. Note that for
performance reasons, this function always returns the same object.LSStatisticspublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getInfo()
LSState.Paused or LSState.Stopped. Useful for debugging
or logging purposes. Here are some explanations about the output String:
public void saveEnvironment(java.lang.String filename)
filename - Name of the file.loadEnvironment(java.lang.String)public void loadEnvironment(java.lang.String filename)
LSState.Modeling. The current model must be empty.
Currently, this function supports 2 file formats : LSM and LSB.
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.filename - Name of the file.saveEnvironment(java.lang.String)public void addCallback(LSCallbackType type, LSCallback callback)
The same callback can be used for different events. Only allowed in
states LSState.Stopped or LSState.Modeling.
Note: When a callback is called, the solver is paused.
In that state, you can call all the methods marked as "allowed in state
LSState.Paused". Calling any other method will throw an error.
For example, you can stop the resolution from a callback, retrieve the
current solution or retrieve the statistics of the solver but you can't
remove a constraint.
type - Event to watch.callback - Callback. Cannot be null.LSCallbackpublic boolean removeCallback(LSCallbackType type, LSCallback callback)
type - Event.callback - User callback to delete.addCallback(localsolver.LSCallbackType, localsolver.LSCallback),
LSCallbackpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object