Clingo
Loading...
Searching...
No Matches
CppClingo::Control::SolveHandle Class Referenceabstract

A handle to control a running search. More...

#include <solver.hh>

Public Member Functions

virtual ~SolveHandle ()=default
 The default destructor.
 
auto get () -> SolveResult
 Get the result of a search.
 
void cancel ()
 Cancel the current search.
 
void resume ()
 Resume search after a model has been found to start search for the next one.
 
auto model () -> Model const *
 Get the current model or a nullptr if there is none.
 
auto last () -> Model const *
 Get the last model after the search has finished.
 
auto core () -> PrgLitSpan
 Get a subset of the assumptions that made the problem unsatisfiable.
 
auto wait (double timeout) -> bool
 Wait for the given amount of time or until the next result is ready.
 

Detailed Description

A handle to control a running search.

Member Function Documentation

◆ cancel()

void CppClingo::Control::SolveHandle::cancel ( )
inline

Cancel the current search.

This call blocks until search has stopped.

◆ core()

auto CppClingo::Control::SolveHandle::core ( ) -> PrgLitSpan
inline

Get a subset of the assumptions that made the problem unsatisfiable.

The subset is called an unsatisfiable core and is not necessarily subset minimal.

Returns
the core

◆ get()

auto CppClingo::Control::SolveHandle::get ( ) -> SolveResult
inline

Get the result of a search.

This call blocks until search has completed.

Returns
the solve result

◆ last()

auto CppClingo::Control::SolveHandle::last ( ) -> Model const *
inline

Get the last model after the search has finished.

Returns null if the problem is unsatisfiable.

Returns
the model or null

◆ model()

auto CppClingo::Control::SolveHandle::model ( ) -> Model const *
inline

Get the current model or a nullptr if there is none.

The function blocks until a model is ready or the search space has been exhausted.

The function returns null if the search space has been exhausted or the search was not started in yield mode.

Returns
the model or null

◆ resume()

void CppClingo::Control::SolveHandle::resume ( )
inline

Resume search after a model has been found to start search for the next one.

To ease writing while loops, this function can also be called initially.

◆ wait()

auto CppClingo::Control::SolveHandle::wait ( double  timeout) -> bool
inline

Wait for the given amount of time or until the next result is ready.

The next result is either a model (if yielding was enabled) or a solve result.

The function blocks for at most the given amount of time and returns whether the next result is ready. If the timeout is zero, it can be used for polling for a result. If the timeout is negative, it blocks until the next result is ready.


The documentation for this class was generated from the following file: