Clingo C API
C API for clingo providing high level functions to control grounding and solving.
Public Attributes | List of all members
clingo_ground_program_observer Struct Reference

Detailed Description

An instance of this struct has to be registered with a solver to observe ground directives as they are passed to the solver.

Note
This interface is closely modeled after the aspif format. For more information please refer to the specification of the aspif format.

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.

See also
clingo_control_register_observer()

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...
 

Member Data Documentation

◆ acyc_edge

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.

Parameters
[in]node_uthe start vertex of the edge
[in]node_vthe end vertex of the edge
[in]conditionthe condition under which the edge is part of the graph
[in]sizethe number of atoms in the condition
[in]datauser data for the callback
Returns
whether the call was successful

◆ assume

bool(* clingo_ground_program_observer::assume) (clingo_literal_t const *literals, size_t size, void *data)

Observe assumption directives passed to the solver.

Parameters
[in]literalsthe literals to assume (positive literals are true and negative literals false for the next solve call)
[in]sizethe number of atoms
[in]datauser data for the callback
Returns
whether the call was successful

◆ begin_step

bool(* clingo_ground_program_observer::begin_step) (void *data)

Marks the beginning of a block of directives passed to the solver.

See also
end_step
Parameters
[in]datauser data for the callback
Returns
whether the call was successful

◆ end_step

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.

See also
begin_step
Parameters
[in]datauser data for the callback
Returns
whether the call was successful

◆ external

bool(* clingo_ground_program_observer::external) (clingo_atom_t atom, clingo_external_type_t type, void *data)

Observe external statements passed to the solver.

Parameters
[in]atomthe external atom
[in]typethe type of the external statement
[in]datauser data for the callback
Returns
whether the call was successful

◆ heuristic

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.

Parameters
[in]atomthe target atom
[in]typethe type of the heuristic modification
[in]biasthe heuristic bias
[in]prioritythe heuristic priority
[in]conditionthe condition under which to apply the heuristic modification
[in]sizethe number of atoms in the condition
[in]datauser data for the callback
Returns
whether the call was successful

◆ init_program

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().

Parameters
[in]incrementalwhether the program is incremental
[in]datauser data for the callback
Returns
whether the call was successful

◆ minimize

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.

Parameters
[in]prioritythe priority of the constraint
[in]literalsthe weighted literals whose sum to minimize
[in]sizethe number of weighted literals
[in]datauser data for the callback
Returns
whether the call was successful

◆ output_atom

bool(* clingo_ground_program_observer::output_atom) (clingo_symbol_t symbol, clingo_atom_t atom, void *data)

Observe shown atoms passed to the solver.

Note
Facts do not have an associated aspif atom. The value of the atom is set to zero.
Parameters
[in]symbolthe symbolic representation of the atom
[in]atomthe aspif atom (0 for facts)
[in]datauser data for the callback
Returns
whether the call was successful

◆ output_csp

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.

Parameters
[in]symbolthe symbolic representation of the variable
[in]valuethe value of the variable
[in]conditionthe literals of the condition
[in]sizethe size of the condition
[in]datauser data for the callback
Returns
whether the call was successful

◆ output_term

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.

Parameters
[in]symbolthe symbolic representation of the term
[in]conditionthe literals of the condition
[in]sizethe size of the condition
[in]datauser data for the callback
Returns
whether the call was successful

◆ project

bool(* clingo_ground_program_observer::project) (clingo_atom_t const *atoms, size_t size, void *data)

Observe projection directives passed to the solver.

Parameters
[in]atomsthe atoms to project on
[in]sizethe number of atoms
[in]datauser data for the callback
Returns
whether the call was successful

◆ rule

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.

Parameters
[in]choicedetermines if the head is a choice or a disjunction
[in]headthe head atoms
[in]head_sizethe number of atoms in the head
[in]bodythe body literals
[in]body_sizethe number of literals in the body
[in]datauser data for the callback
Returns
whether the call was successful

◆ theory_atom

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.

Parameters
[in]atom_id_or_zerothe id of the atom or zero for directives
[in]term_idthe term associated with the atom
[in]elementsthe elements of the atom
[in]sizethe number of elements
[in]datauser data for the callback
Returns
whether the call was successful

◆ theory_atom_with_guard

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.

Parameters
[in]atom_id_or_zerothe id of the atom or zero for directives
[in]term_idthe term associated with the atom
[in]elementsthe elements of the atom
[in]sizethe number of elements
[in]operator_idthe id of the operator (a string term)
[in]right_hand_side_idthe id of the term on the right hand side of the atom
[in]datauser data for the callback
Returns
whether the call was successful

◆ theory_element

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.

Parameters
element_idthe id of the element
termsthe term tuple of the element
terms_sizethe number of terms in the tuple
conditionthe condition of the elemnt
condition_sizethe number of literals in the condition
[in]datauser data for the callback
Returns
whether the call was successful

◆ theory_term_compound

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:

  • if it is -1, then it is a tuple
  • if it is -2, then it is a set
  • if it is -3, then it is a list
  • otherwise, it is a function and name_id_or_type refers to the id of the name (in form of a string term)
Parameters
[in]term_idthe id of the term
[in]name_id_or_typethe name or type of the term
[in]argumentsthe arguments of the term
[in]sizethe number of arguments
[in]datauser data for the callback
Returns
whether the call was successful

◆ theory_term_number

bool(* clingo_ground_program_observer::theory_term_number) (clingo_id_t term_id, int number, void *data)

Observe numeric theory terms.

Parameters
[in]term_idthe id of the term
[in]numberthe value of the term
[in]datauser data for the callback
Returns
whether the call was successful

◆ theory_term_string

bool(* clingo_ground_program_observer::theory_term_string) (clingo_id_t term_id, char const *name, void *data)

Observe string theory terms.

Parameters
[in]term_idthe id of the term
[in]namethe value of the term
[in]datauser data for the callback
Returns
whether the call was successful

◆ weight_rule

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.

Parameters
[in]choicedetermines if the head is a choice or a disjunction
[in]headthe head atoms
[in]head_sizethe number of atoms in the head
[in]lower_boundthe lower bound of the weight rule
[in]bodythe weighted body literals
[in]body_sizethe number of weighted literals in the body
[in]datauser data for the callback
Returns
whether the call was successful

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