Clingo
|
Class to control a running search. More...
#include <solve.hh>
Classes | |
class | iterator |
Iterator to iterate over models found during solving. More... | |
struct | sentinel |
Sentinel indicating that models have been exhausted. More... | |
Public Types | |
using | difference_type = iterator::difference_type |
The difference type. | |
using | value_type = iterator::value_type |
The value type, which are models. | |
using | reference = iterator::reference |
The reference type. | |
using | pointer = iterator::pointer |
The pointer type. | |
Public Member Functions | |
SolveHandle (clingo_solve_handle_t *hnd) | |
Constructor from the underlying C representation. | |
auto | get () const -> SolveResult |
Get the solve result. | |
void | cancel () |
Cancel the current search. | |
void | close () |
Close the solve handle. | |
void | resume () |
Resume the current search. | |
auto | model () -> std::optional< ConstModel > |
Get the current model. | |
auto | last () const -> std::optional< ConstModel > |
Get the last model. | |
auto | core () const -> ProgramLiteralSpan |
Get the unsatisfiable core. | |
auto | wait (std::optional< double > timeout) -> bool |
Wait for the next model or solve result. | |
auto | begin () -> iterator |
Get an iterator to iterate over models found during solving. | |
auto | end () -> sentinel |
Get a sentinel to indicate that all models have been exhausted. | |
Friends | |
class | Control |
auto | c_cast (SolveHandle const &x) -> clingo_solve_handle_t * |
Cast the solve handle to its C representation. | |
Class to control a running search.
|
inlineexplicit |
Constructor from the underlying C representation.
For internal use.
hnd | the C representation of the solve handle |
|
inline |
Cancel the current search.
This is a blocking operation.
|
inline |
Close the solve handle.
This is a blocking operation.
Closing a solver handle guarantees that the destructor of the solve handle does not throw.
|
inline |
Get the unsatisfiable core.
This function can be called when the search was reported unsatisfiable. It contains a subset of the assumptions that made the problem unsatisfiable. The set is not necessarily minimal.
|
inline |
Get the solve result.
This is a blocking operation and should always be called at the end of a search.
|
inline |
Get the last model.
This function can be called after all models have been enumerated. This is particularly useful when optimizing to inpsect the optimal model.
|
inline |
Get the current model.
Return std::optional if no model is available. This can happen if models are exhausted or in an asynchronous context where the next model has not yet been found.
|
inline |
Resume the current search.
In a asynchronous context, this will start the search for the next model. Otherwise, it is a no-op.
Wait for the next model or solve result.
If yielding is active, waits for the next model. Otherwise, waits for the solve result.
If no timeout is given, waits until the model or result is available. Otherwise, waits for the given timeout in seconds. A value of zero can be used for polling.
timeout | the timeout in seconds |
|
friend |
Cast the solve handle to its C representation.
x | the solve handle to cast |