Clingo C API
C API for clingo providing high level functions to control grounding and solving.
Typedefs | Enumerations | Functions
Solver Configuration

Detailed Description

Configuration of search and enumeration algorithms.

Entries in a configuration are organized hierarchically. Subentries are either accessed by name for map entries or by offset for array entries. Value entries have a string value that can be inspected or modified.

For an example, see configuration.c.

Typedefs

typedef unsigned clingo_configuration_type_bitset_t
 Bitset for values of type clingo_configuration_type.
 
typedef struct clingo_configuration clingo_configuration_t
 Handle for to the solver configuration.
 

Enumerations

enum  clingo_configuration_type { clingo_configuration_type_value = 1, clingo_configuration_type_array = 2, clingo_configuration_type_map = 4 }
 Enumeration for entries of the configuration. More...
 

Functions

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_root (clingo_configuration_t *configuration, clingo_id_t *key)
 Get the root key of the configuration. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_type (clingo_configuration_t *configuration, clingo_id_t key, clingo_configuration_type_bitset_t *type)
 Get the type of a key. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_description (clingo_configuration_t *configuration, clingo_id_t key, char const **description)
 Get the description of an entry. More...
 

Functions to access arrays

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_array_size (clingo_configuration_t *configuration, clingo_id_t key, size_t *size)
 Get the size of an array entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_array_at (clingo_configuration_t *configuration, clingo_id_t key, size_t offset, clingo_id_t *subkey)
 Get the subkey at the given offset of an array entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_size (clingo_statistics_t *statistics, uint64_t key, size_t *size)
 Get the size of an array entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_at (clingo_statistics_t *statistics, uint64_t key, size_t offset, uint64_t *subkey)
 Get the subkey at the given offset of an array entry. More...
 

Functions to access maps

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_size (clingo_configuration_t *configuration, clingo_id_t key, size_t *size)
 Get the number of subkeys of a map entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_has_subkey (clingo_configuration_t *configuration, clingo_id_t key, char const *name, bool *result)
 Query whether the map has a key. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_subkey_name (clingo_configuration_t *configuration, clingo_id_t key, size_t offset, char const **name)
 Get the name associated with the offset-th subkey. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_at (clingo_configuration_t *configuration, clingo_id_t key, char const *name, clingo_id_t *subkey)
 Lookup a subkey under the given name. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_size (clingo_statistics_t *statistics, uint64_t key, size_t *size)
 Get the number of subkeys of a map entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_subkey_name (clingo_statistics_t *statistics, uint64_t key, size_t offset, char const **name)
 Get the name associated with the offset-th subkey. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_at (clingo_statistics_t *statistics, uint64_t key, char const *name, uint64_t *subkey)
 Lookup a subkey under the given name. More...
 

Functions to access values

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_is_assigned (clingo_configuration_t *configuration, clingo_id_t key, bool *assigned)
 Check whether a entry has a value. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_get_size (clingo_configuration_t *configuration, clingo_id_t key, size_t *size)
 Get the size of the string value of the given entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_get (clingo_configuration_t *configuration, clingo_id_t key, char *value, size_t size)
 Get the string value of the given entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_set (clingo_configuration_t *configuration, clingo_id_t key, char const *value)
 Set the value of an entry. More...
 

Enumeration Type Documentation

◆ clingo_configuration_type

Enumeration for entries of the configuration.

Enumerator
clingo_configuration_type_value 

the entry is a (string) value

clingo_configuration_type_array 

the entry is an array

clingo_configuration_type_map 

the entry is a map

Function Documentation

◆ clingo_configuration_array_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_array_at ( clingo_configuration_t configuration,
clingo_id_t  key,
size_t  offset,
clingo_id_t subkey 
)

Get the subkey at the given offset of an array entry.

Note
Some array entries, like fore example the solver configuration, can be accessed past there actual size to add subentries.
Precondition
The type of the entry must be clingo_configuration_type_array.
Parameters
[in]configurationthe target configuration
[in]keythe key
[in]offsetthe offset in the array
[out]subkeythe resulting subkey
Returns
whether the call was successful
Examples:
configuration.c.

◆ clingo_configuration_array_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_array_size ( clingo_configuration_t configuration,
clingo_id_t  key,
size_t *  size 
)

Get the size of an array entry.

Precondition
The type of the entry must be clingo_configuration_type_array.
Parameters
[in]configurationthe target configuration
[in]keythe key
[out]sizethe resulting size
Returns
whether the call was successful

◆ clingo_configuration_description()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_description ( clingo_configuration_t configuration,
clingo_id_t  key,
char const **  description 
)

Get the description of an entry.

Parameters
[in]configurationthe target configuration
[in]keythe key
[out]descriptionthe description
Returns
whether the call was successful

◆ clingo_configuration_map_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_at ( clingo_configuration_t configuration,
clingo_id_t  key,
char const *  name,
clingo_id_t subkey 
)

Lookup a subkey under the given name.

Precondition
The type of the entry must be clingo_configuration_type_map.
Note
Multiple levels can be looked up by concatenating keys with a period.
Parameters
[in]configurationthe target configuration
[in]keythe key
[in]namethe name to lookup the subkey
[out]subkeythe resulting subkey
Returns
whether the call was successful
Examples:
configuration.c, and statistics.c.

◆ clingo_configuration_map_has_subkey()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_has_subkey ( clingo_configuration_t configuration,
clingo_id_t  key,
char const *  name,
bool *  result 
)

Query whether the map has a key.

Precondition
The type of the entry must be clingo_configuration_type_map.
Note
Multiple levels can be looked up by concatenating keys with a period.
Parameters
[in]configurationthe target configuration
[in]keythe key
[in]namethe name to lookup the subkey
[out]resultwhether the key is in the map
Returns
whether the call was successful

◆ clingo_configuration_map_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_size ( clingo_configuration_t configuration,
clingo_id_t  key,
size_t *  size 
)

Get the number of subkeys of a map entry.

Precondition
The type of the entry must be clingo_configuration_type_map.
Parameters
[in]configurationthe target configuration
[in]keythe key
[out]sizethe resulting number
Returns
whether the call was successful

◆ clingo_configuration_map_subkey_name()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_map_subkey_name ( clingo_configuration_t configuration,
clingo_id_t  key,
size_t  offset,
char const **  name 
)

Get the name associated with the offset-th subkey.

Precondition
The type of the entry must be clingo_configuration_type_map.
Parameters
[in]configurationthe target configuration
[in]keythe key
[in]offsetthe offset of the name
[out]namethe resulting name
Returns
whether the call was successful

◆ clingo_configuration_root()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_root ( clingo_configuration_t configuration,
clingo_id_t key 
)

Get the root key of the configuration.

Parameters
[in]configurationthe target configuration
[out]keythe root key
Returns
whether the call was successful
Examples:
configuration.c, and statistics.c.

◆ clingo_configuration_type()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_type ( clingo_configuration_t configuration,
clingo_id_t  key,
clingo_configuration_type_bitset_t type 
)

Get the type of a key.

Note
The type is bitset, an entry can have multiple (but at least one) type.
Parameters
[in]configurationthe target configuration
[in]keythe key
[out]typethe resulting type
Returns
whether the call was successful

◆ clingo_configuration_value_get()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_get ( clingo_configuration_t configuration,
clingo_id_t  key,
char *  value,
size_t  size 
)

Get the string value of the given entry.

Precondition
The type of the entry must be clingo_configuration_type_value.
The given size must be larger or equal to size of the value.
Parameters
[in]configurationthe target configuration
[in]keythe key
[out]valuethe resulting string value
[in]sizethe size of the given char array
Returns
whether the call was successful

◆ clingo_configuration_value_get_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_get_size ( clingo_configuration_t configuration,
clingo_id_t  key,
size_t *  size 
)

Get the size of the string value of the given entry.

Precondition
The type of the entry must be clingo_configuration_type_value.
Parameters
[in]configurationthe target configuration
[in]keythe key
[out]sizethe resulting size
Returns
whether the call was successful

◆ clingo_configuration_value_is_assigned()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_is_assigned ( clingo_configuration_t configuration,
clingo_id_t  key,
bool *  assigned 
)

Check whether a entry has a value.

Precondition
The type of the entry must be clingo_configuration_type_value.
Parameters
[in]configurationthe target configuration
[in]keythe key
[out]assignedwhether the entry has a value
Returns
whether the call was successful

◆ clingo_configuration_value_set()

CLINGO_VISIBILITY_DEFAULT bool clingo_configuration_value_set ( clingo_configuration_t configuration,
clingo_id_t  key,
char const *  value 
)

Set the value of an entry.

Precondition
The type of the entry must be clingo_configuration_type_value.
Parameters
[in]configurationthe target configuration
[in]keythe key
[in]valuethe value to set
Returns
whether the call was successful
Examples:
configuration.c, and statistics.c.

◆ clingo_statistics_array_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_at ( clingo_statistics_t statistics,
uint64_t  key,
size_t  offset,
uint64_t *  subkey 
)

Get the subkey at the given offset of an array entry.

Precondition
The type of the entry must be clingo_statistics_type_array.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[in]offsetthe offset in the array
[out]subkeythe resulting subkey
Returns
whether the call was successful
Examples:
statistics.c.

◆ clingo_statistics_array_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_size ( clingo_statistics_t statistics,
uint64_t  key,
size_t *  size 
)

Get the size of an array entry.

Precondition
The type of the entry must be clingo_statistics_type_array.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[out]sizethe resulting size
Returns
whether the call was successful
Examples:
statistics.c.

◆ clingo_statistics_map_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_at ( clingo_statistics_t statistics,
uint64_t  key,
char const *  name,
uint64_t *  subkey 
)

Lookup a subkey under the given name.

Precondition
The type of the entry must be clingo_statistics_type_map.
Note
Multiple levels can be looked up by concatenating keys with a period.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[in]namethe name to lookup the subkey
[out]subkeythe resulting subkey
Returns
whether the call was successful
Examples:
statistics.c.

◆ clingo_statistics_map_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_size ( clingo_statistics_t statistics,
uint64_t  key,
size_t *  size 
)

Get the number of subkeys of a map entry.

Precondition
The type of the entry must be clingo_statistics_type_map.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[out]sizethe resulting number
Returns
whether the call was successful
Examples:
statistics.c.

◆ clingo_statistics_map_subkey_name()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_subkey_name ( clingo_statistics_t statistics,
uint64_t  key,
size_t  offset,
char const **  name 
)

Get the name associated with the offset-th subkey.

Precondition
The type of the entry must be clingo_statistics_type_map.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[in]offsetthe offset of the name
[out]namethe resulting name
Returns
whether the call was successful
Examples:
statistics.c.