Clingo C API
C API for clingo providing high level functions to control grounding and solving.
|
An instance of this struct has to be registered with a solver to implement a custom propagator.
Not all callbacks have to be implemented and can be set to NULL if not needed.
Public Attributes | |
bool(* | init )(clingo_propagate_init_t *init, void *data) |
This function is called once before each solving step. More... | |
bool(* | propagate )(clingo_propagate_control_t *control, clingo_literal_t const *changes, size_t size, void *data) |
Can be used to propagate solver literals given a partial assignment. More... | |
void(* | undo )(clingo_propagate_control_t const *control, clingo_literal_t const *changes, size_t size, void *data) |
Called whenever a solver undoes assignments to watched solver literals. More... | |
bool(* | check )(clingo_propagate_control_t *control, void *data) |
This function is similar to clingo_propagate_control_propagate() but is called without a change set on propagation fixpoints. More... | |
bool(* | decide )(clingo_id_t thread_id, clingo_assignment_t const *assignment, clingo_literal_t fallback, void *data, clingo_literal_t *decision) |
This function allows a propagator to implement domain-specific heuristics. More... | |
bool(* clingo_propagator::check) (clingo_propagate_control_t *control, void *data) |
This function is similar to clingo_propagate_control_propagate() but is called without a change set on propagation fixpoints.
When exactly this function is called, can be configured using the clingo_propagate_init_set_check_mode() function.
[in] | control | control object for the target solver |
[in] | data | user data for the callback |
bool(* clingo_propagator::decide) (clingo_id_t thread_id, clingo_assignment_t const *assignment, clingo_literal_t fallback, void *data, clingo_literal_t *decision) |
This function allows a propagator to implement domain-specific heuristics.
It is called whenever propagation reaches a fixed point and should return a free solver literal that is to be assigned true. In case multiple propagators are registered, this function can return 0 to let a propagator registered later make a decision. If all propagators return 0, then the fallback literal is
[in] | thread_id | the solver's thread id |
[in] | assignment | the assignment of the solver |
[in] | fallback | the literal choosen by the solver's heuristic |
[out] | decision | the literal to make true |
bool(* clingo_propagator::init) (clingo_propagate_init_t *init, void *data) |
This function is called once before each solving step.
It is used to map relevant program literals to solver literals, add watches for solver literals, and initialize the data structures used during propagation.
[in] | init | initizialization object |
[in] | data | user data for the callback |
bool(* clingo_propagator::propagate) (clingo_propagate_control_t *control, clingo_literal_t const *changes, size_t size, void *data) |
Can be used to propagate solver literals given a partial assignment.
Called during propagation with a non-empty array of watched solver literals that have been assigned to true since the last call to either propagate, undo, (or the start of the search) - the change set. Only watched solver literals are contained in the change set. Each literal in the change set is true w.r.t. the current assignment. clingo_propagate_control_add_clause() can be used to add clauses. If a clause is unit resulting, it can be propagated using clingo_propagate_control_propagate(). If the result of either of the two methods is false, the propagate function must return immediately.
The following snippet shows how to use the methods to add clauses and propagate consequences within the callback. The important point is to return true (true to indicate there was no error) if the result of either of the methods is false.
[in] | control | control object for the target solver |
[in] | changes | the change set |
[in] | size | the size of the change set |
[in] | data | user data for the callback |
void(* clingo_propagator::undo) (clingo_propagate_control_t const *control, clingo_literal_t const *changes, size_t size, void *data) |
Called whenever a solver undoes assignments to watched solver literals.
This callback is meant to update assignment dependent state in the propagator.
[in] | control | control object for the target solver |
[in] | changes | the change set |
[in] | size | the size of the change set |
[in] | data | user data for the callback |