|
Clingo
|
Functions to control the grounding and solving process. More...
Modules | |
| Symbolic Atom Inspection | |
| Inspection of atoms occurring in ground logic programs. | |
| Basic Shared Types | |
| Enumerations shared by various modules. | |
| Ground Program Inspection | |
| Functions and data structures to inspect ground programs. | |
| Ground Program Extension | |
| Add non-ground program representations (ASTs) to logic programs or extend the ground (aspif) program. | |
| Grounding | |
| Interact with a running ground call. | |
| Model Inspection | |
| Inspection of models and a high-level interface to add constraints during solving. | |
| Solving | |
| Interact with a running search. | |
| Solver Configuration | |
| Configuration of search and enumeration algorithms. | |
| Statistics | |
| Inspect search and problem stats. | |
| Theory Propagation | |
| Extend the search with propagators for arbitrary theories. | |
| Profile Grounding | |
| Profile the grounding process. | |
Typedefs | |
| typedef struct clingo_control | clingo_control_t |
| Control object holding grounding and solving state. | |
| typedef int | clingo_mode_t |
| The corresponding type to clingo_mode_e. | |
| typedef struct clingo_const_map | clingo_const_map_t |
| A map from constantns to their values. | |
| typedef unsigned | clingo_discard_type_t |
| Corresponding type to clingo_discard_type_e. | |
Enumerations | |
| enum | clingo_mode_e { clingo_mode_parse = 0 , clingo_mode_rewrite = 1 , clingo_mode_ground = 2 , clingo_mode_solve = 3 } |
| The available application modes. More... | |
| enum | clingo_discard_type_e { minimize = 1 , project = 2 } |
| Enumeration of discardable statements. | |
Functions | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_const_map_find (clingo_const_map_t const *map, char const *name, size_t name_size, clingo_symbol_t *symbol, bool *found) |
| Get the constant with the given name. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_const_map_at (clingo_const_map_t const *map, size_t index, clingo_string_t *name, clingo_symbol_t *symbol) |
| Get the name and value of the contstant at the given index. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_const_map_size (clingo_const_map_t const *map, size_t *size) |
| Get the size of the constant map. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_new (clingo_lib_t *lib, clingo_string_t const *arguments, size_t size, clingo_control_t **control) |
| Create a new control object. | |
| CLINGO_VISIBILITY_DEFAULT void | clingo_control_acquire (clingo_control_t *control) |
| Increment the reference count of the given control object. | |
| CLINGO_VISIBILITY_DEFAULT void | clingo_control_release (clingo_control_t *control) |
| Decrement the reference count of the given control object and destroy if zero. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_mode (clingo_control_t *control, clingo_mode_t *mode) |
| Get the configured mode. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_parse_files (clingo_control_t *control, clingo_string_t const *files, size_t size) |
| Extend the logic program with a program in a file. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_parse_string (clingo_control_t *control, char const *program, size_t size) |
| Extend the logic program with the given non-ground logic program in string form. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_ground (clingo_control_t *control, clingo_part_t const *parts, size_t size, clingo_ground_event_handler_t const *handler, void *data) |
| Ground the selected parts of the current (non-ground) logic program. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_start_ground (clingo_control_t *control, clingo_part_t const *parts, size_t size, clingo_ground_event_handler_t const *handler, void *data, clingo_ground_handle_t **handle) |
| Start grounding a program asynchronously. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_main (clingo_control_t *control) |
| Execute the default ground and solve flow after parsing. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_const_map (clingo_control_t *control, clingo_const_map_t const **map) |
| Get the map of constants. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_buffer (clingo_control_t *control, clingo_string_t *result) |
| Get the output of the text output. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_get_parts (clingo_control_t *control, clingo_part_t const **parts, size_t *size, bool *has_value) |
| Get the program parts to ground. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_set_parts (clingo_control_t *control, clingo_part_t const *parts, size_t size, bool has_value) |
| Set the program parts to ground. | |
| CLINGO_VISIBILITY_DEFAULT bool | clingo_control_discard (clingo_control_t *control, clingo_discard_type_t type) |
| Discard the statements of the given types. | |
| CLINGO_VISIBILITY_DEFAULT void | clingo_control_interrupt (clingo_control_t *control) |
| Interrupt the running search. | |
Functions to control the grounding and solving process.
For an example, see control.c.
| enum clingo_mode_e |
| CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_at | ( | clingo_const_map_t const * | map, |
| size_t | index, | ||
| clingo_string_t * | name, | ||
| clingo_symbol_t * | symbol | ||
| ) |
Get the name and value of the contstant at the given index.
| [in] | map | the target |
| [in] | index | the index of the elemnt |
| [out] | name | the name of the constant |
| [out] | symbol | the value of the constant |
| CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_find | ( | clingo_const_map_t const * | map, |
| char const * | name, | ||
| size_t | name_size, | ||
| clingo_symbol_t * | symbol, | ||
| bool * | found | ||
| ) |
Get the constant with the given name.
| [in] | map | the target |
| [in] | name | the name of the constant |
| [in] | name_size | the size of the name |
| [out] | symbol | the value of the constant |
| [out] | found | whether the constant was found |
| CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_size | ( | clingo_const_map_t const * | map, |
| size_t * | size | ||
| ) |
Get the size of the constant map.
| [in] | map | the target |
| [out] | size | the size of the map |
| CLINGO_VISIBILITY_DEFAULT void clingo_control_acquire | ( | clingo_control_t * | control | ) |
Increment the reference count of the given control object.
| [in] | control | the target |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_buffer | ( | clingo_control_t * | control, |
| clingo_string_t * | result | ||
| ) |
Get the output of the text output.
--text-buffer.| [in] | control | the target |
| [out] | result | the resulting string |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_const_map | ( | clingo_control_t * | control, |
| clingo_const_map_t const ** | map | ||
| ) |
Get the map of constants.
| [in] | control | the target |
| [out] | map | the map of constants |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_discard | ( | clingo_control_t * | control, |
| clingo_discard_type_t | type | ||
| ) |
Discard the statements of the given types.
| [in] | control | the target control |
| [in] | type | what to discard |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_get_parts | ( | clingo_control_t * | control, |
| clingo_part_t const ** | parts, | ||
| size_t * | size, | ||
| bool * | has_value | ||
| ) |
Get the program parts to ground.
| [in] | control | the target |
| [out] | parts | the resulting parts |
| [out] | size | the resulting parts |
| [out] | has_value | the resulting parts |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_ground | ( | clingo_control_t * | control, |
| clingo_part_t const * | parts, | ||
| size_t | size, | ||
| clingo_ground_event_handler_t const * | handler, | ||
| void * | data | ||
| ) |
Ground the selected parts of the current (non-ground) logic program.
After grounding, logic programs can be solved with clingo_control_solve().
#program specification are by default put into a program called base without arguments.| [in] | control | the target |
| [in] | parts | array of parts to ground |
| [in] | size | size of the parts array |
| [in] | handler | handler for grounding events |
| [in] | data | user data for ground_callback |
| CLINGO_VISIBILITY_DEFAULT void clingo_control_interrupt | ( | clingo_control_t * | control | ) |
Interrupt the running search.
It is generally better to use clingo_solve_handle_cancel(). This function is thread-safe.
| [in] | control | the target |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_main | ( | clingo_control_t * | control | ) |
Execute the default ground and solve flow after parsing.
| [in] | control | the target |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_mode | ( | clingo_control_t * | control, |
| clingo_mode_t * | mode | ||
| ) |
Get the configured mode.
| [in] | control | the target |
| [in] | mode | the mode |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_new | ( | clingo_lib_t * | lib, |
| clingo_string_t const * | arguments, | ||
| size_t | size, | ||
| clingo_control_t ** | control | ||
| ) |
Create a new control object.
A control object has to be freed using clingo_control_free().
--output) and clasp's options are supported as arguments, except basic options such as --help. Furthermore, a control object is blocked while a search call is active; you must not call any member function during search.| [in] | lib | clingo library object |
| [in] | arguments | string array of command line arguments |
| [in] | size | size of the arguments array |
| [out] | control | resulting control object |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_files | ( | clingo_control_t * | control, |
| clingo_string_t const * | files, | ||
| size_t | size | ||
| ) |
Extend the logic program with a program in a file.
| [in] | control | the target |
| [in] | files | the files to parse |
| [in] | size | the number of files to parse |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_string | ( | clingo_control_t * | control, |
| char const * | program, | ||
| size_t | size | ||
| ) |
Extend the logic program with the given non-ground logic program in string form.
After extending the logic program, the corresponding program parts are typically grounded with clingo_control_ground.
| [in] | control | the target |
| [in] | program | string representation of the program |
| [in] | size | the size of the program |
| CLINGO_VISIBILITY_DEFAULT void clingo_control_release | ( | clingo_control_t * | control | ) |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_set_parts | ( | clingo_control_t * | control, |
| clingo_part_t const * | parts, | ||
| size_t | size, | ||
| bool | has_value | ||
| ) |
Set the program parts to ground.
| [in] | control | the target |
| [in] | parts | the parts to set |
| [in] | size | the size of the parts |
| [in] | has_value | whether parts are available |
| CLINGO_VISIBILITY_DEFAULT bool clingo_control_start_ground | ( | clingo_control_t * | control, |
| clingo_part_t const * | parts, | ||
| size_t | size, | ||
| clingo_ground_event_handler_t const * | handler, | ||
| void * | data, | ||
| clingo_ground_handle_t ** | handle | ||
| ) |
Start grounding a program asynchronously.
The function returns a handle and immediately starts grounding in the background. The handle can be used to wait for the grounding to finish, get the result, or cancel the grounding. Stopping grounding leaves the program in an unpredictable state. There is currently no way to rollback a partially grounded program.
The returned handle must be released using clingo_ground_handle_close().
| [in] | control | the target |
| [in] | parts | array of parts to ground |
| [in] | size | size of the parts array |
| [in] | handler | handler for grounding events |
| [in] | data | user data for ground_callback |
| [out] | handle | the resulting ground handle |