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 observe ground directives as they are passed to the solver.
Not all callbacks have to be implemented and can be set to NULL if not needed. If one of the callbacks in the struct fails, grounding is stopped. If a non-recoverable clingo API call fails, a callback must return false. Otherwise clingo_error_unknown should be set and false returned.
Public Attributes | |
bool(* | init_program )(bool incremental, void *data) |
Called once in the beginning. More... | |
bool(* | begin_step )(void *data) |
Marks the beginning of a block of directives passed to the solver. More... | |
bool(* | end_step )(void *data) |
Marks the end of a block of directives passed to the solver. More... | |
bool(* | rule )(bool choice, clingo_atom_t const *head, size_t head_size, clingo_literal_t const *body, size_t body_size, void *data) |
Observe rules passed to the solver. More... | |
bool(* | weight_rule )(bool choice, clingo_atom_t const *head, size_t head_size, clingo_weight_t lower_bound, clingo_weighted_literal_t const *body, size_t body_size, void *data) |
Observe weight rules passed to the solver. More... | |
bool(* | minimize )(clingo_weight_t priority, clingo_weighted_literal_t const *literals, size_t size, void *data) |
Observe minimize constraints (or weak constraints) passed to the solver. More... | |
bool(* | project )(clingo_atom_t const *atoms, size_t size, void *data) |
Observe projection directives passed to the solver. More... | |
bool(* | output_atom )(clingo_symbol_t symbol, clingo_atom_t atom, void *data) |
Observe shown atoms passed to the solver. More... | |
bool(* | output_term )(clingo_symbol_t symbol, clingo_literal_t const *condition, size_t size, void *data) |
Observe shown terms passed to the solver. More... | |
bool(* | output_csp )(clingo_symbol_t symbol, int value, clingo_literal_t const *condition, size_t size, void *data) |
Observe shown csp variables passed to the solver. More... | |
bool(* | external )(clingo_atom_t atom, clingo_external_type_t type, void *data) |
Observe external statements passed to the solver. More... | |
bool(* | assume )(clingo_literal_t const *literals, size_t size, void *data) |
Observe assumption directives passed to the solver. More... | |
bool(* | heuristic )(clingo_atom_t atom, clingo_heuristic_type_t type, int bias, unsigned priority, clingo_literal_t const *condition, size_t size, void *data) |
Observe heuristic directives passed to the solver. More... | |
bool(* | acyc_edge )(int node_u, int node_v, clingo_literal_t const *condition, size_t size, void *data) |
Observe edge directives passed to the solver. More... | |
bool(* | theory_term_number )(clingo_id_t term_id, int number, void *data) |
Observe numeric theory terms. More... | |
bool(* | theory_term_string )(clingo_id_t term_id, char const *name, void *data) |
Observe string theory terms. More... | |
bool(* | theory_term_compound )(clingo_id_t term_id, int name_id_or_type, clingo_id_t const *arguments, size_t size, void *data) |
Observe compound theory terms. More... | |
bool(* | theory_element )(clingo_id_t element_id, clingo_id_t const *terms, size_t terms_size, clingo_literal_t const *condition, size_t condition_size, void *data) |
Observe theory elements. More... | |
bool(* | theory_atom )(clingo_id_t atom_id_or_zero, clingo_id_t term_id, clingo_id_t const *elements, size_t size, void *data) |
Observe theory atoms without guard. More... | |
bool(* | theory_atom_with_guard )(clingo_id_t atom_id_or_zero, clingo_id_t term_id, clingo_id_t const *elements, size_t size, clingo_id_t operator_id, clingo_id_t right_hand_side_id, void *data) |
Observe theory atoms with guard. More... | |
bool(* clingo_ground_program_observer::acyc_edge) (int node_u, int node_v, clingo_literal_t const *condition, size_t size, void *data) |
Observe edge directives passed to the solver.
[in] | node_u | the start vertex of the edge |
[in] | node_v | the end vertex of the edge |
[in] | condition | the condition under which the edge is part of the graph |
[in] | size | the number of atoms in the condition |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::assume) (clingo_literal_t const *literals, size_t size, void *data) |
Observe assumption directives passed to the solver.
[in] | literals | the literals to assume (positive literals are true and negative literals false for the next solve call) |
[in] | size | the number of atoms |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::begin_step) (void *data) |
Marks the beginning of a block of directives passed to the solver.
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::end_step) (void *data) |
Marks the end of a block of directives passed to the solver.
This function is called before solving starts.
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::external) (clingo_atom_t atom, clingo_external_type_t type, void *data) |
Observe external statements passed to the solver.
[in] | atom | the external atom |
[in] | type | the type of the external statement |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::heuristic) (clingo_atom_t atom, clingo_heuristic_type_t type, int bias, unsigned priority, clingo_literal_t const *condition, size_t size, void *data) |
Observe heuristic directives passed to the solver.
[in] | atom | the target atom |
[in] | type | the type of the heuristic modification |
[in] | bias | the heuristic bias |
[in] | priority | the heuristic priority |
[in] | condition | the condition under which to apply the heuristic modification |
[in] | size | the number of atoms in the condition |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::init_program) (bool incremental, void *data) |
Called once in the beginning.
If the incremental flag is true, there can be multiple calls to clingo_control_solve().
[in] | incremental | whether the program is incremental |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::minimize) (clingo_weight_t priority, clingo_weighted_literal_t const *literals, size_t size, void *data) |
Observe minimize constraints (or weak constraints) passed to the solver.
[in] | priority | the priority of the constraint |
[in] | literals | the weighted literals whose sum to minimize |
[in] | size | the number of weighted literals |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::output_atom) (clingo_symbol_t symbol, clingo_atom_t atom, void *data) |
Observe shown atoms passed to the solver.
[in] | symbol | the symbolic representation of the atom |
[in] | atom | the aspif atom (0 for facts) |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::output_csp) (clingo_symbol_t symbol, int value, clingo_literal_t const *condition, size_t size, void *data) |
Observe shown csp variables passed to the solver.
[in] | symbol | the symbolic representation of the variable |
[in] | value | the value of the variable |
[in] | condition | the literals of the condition |
[in] | size | the size of the condition |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::output_term) (clingo_symbol_t symbol, clingo_literal_t const *condition, size_t size, void *data) |
Observe shown terms passed to the solver.
[in] | symbol | the symbolic representation of the term |
[in] | condition | the literals of the condition |
[in] | size | the size of the condition |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::project) (clingo_atom_t const *atoms, size_t size, void *data) |
Observe projection directives passed to the solver.
[in] | atoms | the atoms to project on |
[in] | size | the number of atoms |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::rule) (bool choice, clingo_atom_t const *head, size_t head_size, clingo_literal_t const *body, size_t body_size, void *data) |
Observe rules passed to the solver.
[in] | choice | determines if the head is a choice or a disjunction |
[in] | head | the head atoms |
[in] | head_size | the number of atoms in the head |
[in] | body | the body literals |
[in] | body_size | the number of literals in the body |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::theory_atom) (clingo_id_t atom_id_or_zero, clingo_id_t term_id, clingo_id_t const *elements, size_t size, void *data) |
Observe theory atoms without guard.
[in] | atom_id_or_zero | the id of the atom or zero for directives |
[in] | term_id | the term associated with the atom |
[in] | elements | the elements of the atom |
[in] | size | the number of elements |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::theory_atom_with_guard) (clingo_id_t atom_id_or_zero, clingo_id_t term_id, clingo_id_t const *elements, size_t size, clingo_id_t operator_id, clingo_id_t right_hand_side_id, void *data) |
Observe theory atoms with guard.
[in] | atom_id_or_zero | the id of the atom or zero for directives |
[in] | term_id | the term associated with the atom |
[in] | elements | the elements of the atom |
[in] | size | the number of elements |
[in] | operator_id | the id of the operator (a string term) |
[in] | right_hand_side_id | the id of the term on the right hand side of the atom |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::theory_element) (clingo_id_t element_id, clingo_id_t const *terms, size_t terms_size, clingo_literal_t const *condition, size_t condition_size, void *data) |
Observe theory elements.
element_id | the id of the element | |
terms | the term tuple of the element | |
terms_size | the number of terms in the tuple | |
condition | the condition of the elemnt | |
condition_size | the number of literals in the condition | |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::theory_term_compound) (clingo_id_t term_id, int name_id_or_type, clingo_id_t const *arguments, size_t size, void *data) |
Observe compound theory terms.
The name_id_or_type gives the type of the compound term:
[in] | term_id | the id of the term |
[in] | name_id_or_type | the name or type of the term |
[in] | arguments | the arguments of the term |
[in] | size | the number of arguments |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::theory_term_number) (clingo_id_t term_id, int number, void *data) |
Observe numeric theory terms.
[in] | term_id | the id of the term |
[in] | number | the value of the term |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::theory_term_string) (clingo_id_t term_id, char const *name, void *data) |
Observe string theory terms.
[in] | term_id | the id of the term |
[in] | name | the value of the term |
[in] | data | user data for the callback |
bool(* clingo_ground_program_observer::weight_rule) (bool choice, clingo_atom_t const *head, size_t head_size, clingo_weight_t lower_bound, clingo_weighted_literal_t const *body, size_t body_size, void *data) |
Observe weight rules passed to the solver.
[in] | choice | determines if the head is a choice or a disjunction |
[in] | head | the head atoms |
[in] | head_size | the number of atoms in the head |
[in] | lower_bound | the lower bound of the weight rule |
[in] | body | the weighted body literals |
[in] | body_size | the number of weighted literals in the body |
[in] | data | user data for the callback |