Clingo
|
Interact with a running search. More...
Classes | |
struct | clingo_solve_event_handler |
The solve event handler interface. More... | |
Typedefs | |
typedef unsigned | clingo_solve_result_bitset_t |
Corresponding type to clingo_solve_result_e. | |
typedef unsigned | clingo_solve_mode_bitset_t |
Corresponding type to clingo_solve_mode_e. | |
typedef struct clingo_solve_event_handler | clingo_solve_event_handler_t |
The solve event handler interface. | |
typedef struct clingo_solve_handle | clingo_solve_handle_t |
Search handle to a solve call. | |
Enumerations | |
enum | clingo_solve_result_e { clingo_solve_result_empty = 0 , clingo_solve_result_satisfiable = 1 , clingo_solve_result_unsatisfiable = 2 , clingo_solve_result_exhausted = 4 , clingo_solve_result_interrupted = 8 } |
Enumeration of bit masks for solve call results. More... | |
enum | clingo_solve_mode_e { clingo_solve_mode_default = 0 , clingo_solve_mode_async = 1 , clingo_solve_mode_yield = 2 , clingo_solve_mode_lock = 4 } |
Enumeration of solve modes. More... | |
Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_get (clingo_solve_handle_t *handle, clingo_solve_result_bitset_t *result) |
Get the next solve result. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_wait (clingo_solve_handle_t *handle, double timeout, bool *result) |
Wait for the specified amount of time to check if the next result is ready. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_model (clingo_solve_handle_t *handle, clingo_model_t const **model) |
Get the next model (or zero if there are no more models). | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_core (clingo_solve_handle_t *handle, clingo_literal_t const **literals, size_t *size) |
When a problem is unsatisfiable, get a subset of the assumptions that made the problem unsatisfiable. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_last (clingo_solve_handle_t *handle, clingo_model_t const **model) |
When a problem is satisfiable and the search is finished, get the last computed model. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_resume (clingo_solve_handle_t *handle) |
Discards the last model and starts the search for the next one. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_cancel (clingo_solve_handle_t *handle) |
Stop the running search and block until done. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_solve_handle_close (clingo_solve_handle_t *handle) |
Stops the running search and releases the handle. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_control_solve (clingo_control_t *control, clingo_solve_mode_bitset_t mode, clingo_literal_t const *assumptions, size_t assumptions_size, clingo_solve_event_handler_t const *handler, void *data, clingo_solve_handle_t **handle) |
Solve the currently grounded logic program enumerating its models. | |
Interact with a running search.
clingo_solve_handle_t objects can be used for both synchronous and asynchronous search, as well as iteratively receiving models and solve results.
For an example showing how to solve asynchronously, see solve.c.
typedef struct clingo_solve_handle clingo_solve_handle_t |
Search handle to a solve call.
enum clingo_solve_mode_e |
Enumeration of bit masks for solve call results.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_solve | ( | clingo_control_t * | control, |
clingo_solve_mode_bitset_t | mode, | ||
clingo_literal_t const * | assumptions, | ||
size_t | assumptions_size, | ||
clingo_solve_event_handler_t const * | handler, | ||
void * | data, | ||
clingo_solve_handle_t ** | handle | ||
) |
Solve the currently grounded logic program enumerating its models.
See the Solving module for more information.
[in] | control | the target |
[in] | mode | configures the search mode |
[in] | assumptions | array of assumptions to solve under |
[in] | assumptions_size | number of assumptions |
[in] | handler | the event handler to register |
[in] | data | the user data for the event handler |
[out] | handle | handle to the current search to enumerate models |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_cancel | ( | clingo_solve_handle_t * | handle | ) |
Stop the running search and block until done.
[in] | handle | the target |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_close | ( | clingo_solve_handle_t * | handle | ) |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_core | ( | clingo_solve_handle_t * | handle, |
clingo_literal_t const ** | literals, | ||
size_t * | size | ||
) |
When a problem is unsatisfiable, get a subset of the assumptions that made the problem unsatisfiable.
If the program is not unsatisfiable, an empty core is returned.
[in] | handle | the target |
[out] | literals | array of literals in the core |
[out] | size | the size of the core |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_get | ( | clingo_solve_handle_t * | handle, |
clingo_solve_result_bitset_t * | result | ||
) |
Get the next solve result.
Blocks until the result is ready. When yielding partial solve results can be obtained, i.e., when a model is ready, the result will be satisfiable but neither the search exhausted nor the optimality proven.
[in] | handle | the target |
[out] | result | the solve result |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_last | ( | clingo_solve_handle_t * | handle, |
clingo_model_t const ** | model | ||
) |
When a problem is satisfiable and the search is finished, get the last computed model.
If the program is unsatisfiable or the search is not finished, model is set to NULL.
[in] | handle | the target |
[out] | model | the last computed model (or NULL if the program is unsatisfiable or the search is still ongoing) |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_model | ( | clingo_solve_handle_t * | handle, |
clingo_model_t const ** | model | ||
) |
Get the next model (or zero if there are no more models).
[in] | handle | the target |
[out] | model | the model (it is NULL if there are no more models) |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_resume | ( | clingo_solve_handle_t * | handle | ) |
Discards the last model and starts the search for the next one.
If the search has been started asynchronously, this function continues the search in the background.
[in] | handle | the target |
CLINGO_VISIBILITY_DEFAULT bool clingo_solve_handle_wait | ( | clingo_solve_handle_t * | handle, |
double | timeout, | ||
bool * | result | ||
) |
Wait for the specified amount of time to check if the next result is ready.
If the time is set to zero, this function can be used to poll if the search is still active. If the time is negative, the function blocks until the search is finished.
[in] | handle | the target |
[in] | timeout | the maximum time to wait |
[out] | result | whether the search has finished |