Clingo C API
C API for clingo providing high level functions to control grounding and solving.
|
Add non-ground program representations (ASTs) to logic programs or extend the ground (aspif) program.
For an example about ground logic programs, see backend.c. For an example about non-ground logic programs, see ast.c and the Abstract Syntax Trees Version 2 module.
Typedefs | |
typedef struct clingo_backend | clingo_backend_t |
Handle to the backend to add directives in aspif format. | |
Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_begin (clingo_backend_t *backend) |
Prepare the backend for usage. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_end (clingo_backend_t *backend) |
Finalize the backend after using it. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_rule (clingo_backend_t *backend, bool choice, clingo_atom_t const *head, size_t head_size, clingo_literal_t const *body, size_t body_size) |
Add a rule to the program. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_weight_rule (clingo_backend_t *backend, 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) |
Add a weight rule to the program. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_minimize (clingo_backend_t *backend, clingo_weight_t priority, clingo_weighted_literal_t const *literals, size_t size) |
Add a minimize constraint (or weak constraint) to the program. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_project (clingo_backend_t *backend, clingo_atom_t const *atoms, size_t size) |
Add a projection directive. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_external (clingo_backend_t *backend, clingo_atom_t atom, clingo_external_type_t type) |
Add an external statement. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_assume (clingo_backend_t *backend, clingo_literal_t const *literals, size_t size) |
Add an assumption directive. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_heuristic (clingo_backend_t *backend, clingo_atom_t atom, clingo_heuristic_type_t type, int bias, unsigned priority, clingo_literal_t const *condition, size_t size) |
Add an heuristic directive. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_acyc_edge (clingo_backend_t *backend, int node_u, int node_v, clingo_literal_t const *condition, size_t size) |
Add an edge directive. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_backend_add_atom (clingo_backend_t *backend, clingo_symbol_t *symbol, clingo_atom_t *atom) |
Get a fresh atom to be used in aspif directives. More... | |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_acyc_edge | ( | clingo_backend_t * | backend, |
int | node_u, | ||
int | node_v, | ||
clingo_literal_t const * | condition, | ||
size_t | size | ||
) |
Add an edge directive.
[in] | backend | the target backend |
[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 |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_add_atom | ( | clingo_backend_t * | backend, |
clingo_symbol_t * | symbol, | ||
clingo_atom_t * | atom | ||
) |
Get a fresh atom to be used in aspif directives.
[in] | backend | the target backend |
[in] | symbol | optional symbol to associate the atom with |
[out] | atom | the resulting atom |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_assume | ( | clingo_backend_t * | backend, |
clingo_literal_t const * | literals, | ||
size_t | size | ||
) |
Add an assumption directive.
[in] | backend | the target backend |
[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 |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_begin | ( | clingo_backend_t * | backend | ) |
Prepare the backend for usage.
[in] | backend | the target backend |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_end | ( | clingo_backend_t * | backend | ) |
Finalize the backend after using it.
[in] | backend | the target backend |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_external | ( | clingo_backend_t * | backend, |
clingo_atom_t | atom, | ||
clingo_external_type_t | type | ||
) |
Add an external statement.
[in] | backend | the target backend |
[in] | atom | the external atom |
[in] | type | the type of the external statement |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_heuristic | ( | clingo_backend_t * | backend, |
clingo_atom_t | atom, | ||
clingo_heuristic_type_t | type, | ||
int | bias, | ||
unsigned | priority, | ||
clingo_literal_t const * | condition, | ||
size_t | size | ||
) |
Add an heuristic directive.
[in] | backend | the target backend |
[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 |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_minimize | ( | clingo_backend_t * | backend, |
clingo_weight_t | priority, | ||
clingo_weighted_literal_t const * | literals, | ||
size_t | size | ||
) |
Add a minimize constraint (or weak constraint) to the program.
[in] | backend | the target backend |
[in] | priority | the priority of the constraint |
[in] | literals | the weighted literals whose sum to minimize |
[in] | size | the number of weighted literals |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_project | ( | clingo_backend_t * | backend, |
clingo_atom_t const * | atoms, | ||
size_t | size | ||
) |
Add a projection directive.
[in] | backend | the target backend |
[in] | atoms | the atoms to project on |
[in] | size | the number of atoms |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_rule | ( | clingo_backend_t * | backend, |
bool | choice, | ||
clingo_atom_t const * | head, | ||
size_t | head_size, | ||
clingo_literal_t const * | body, | ||
size_t | body_size | ||
) |
Add a rule to the program.
[in] | backend | the target backend |
[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 |
CLINGO_VISIBILITY_DEFAULT bool clingo_backend_weight_rule | ( | clingo_backend_t * | backend, |
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 | ||
) |
Add a weight rule to the program.
[in] | backend | the target backend |
[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 |