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

Detailed Description

Inspect search and problem statistics.

For an example, see statistics.c.

Typedefs

typedef int clingo_statistics_type_t
 Corresponding type to clingo_statistics_type.
 
typedef struct clingo_statistic clingo_statistics_t
 Handle for the solver statistics.
 

Enumerations

enum  clingo_statistics_type_e { clingo_statistics_type_empty = 0, clingo_statistics_type_value = 1, clingo_statistics_type_array = 2, clingo_statistics_type_map = 3 }
 Enumeration for entries of the statistics. More...
 

Functions

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_root (clingo_statistics_t const *statistics, uint64_t *key)
 Get the root key of the statistics. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_type (clingo_statistics_t const *statistics, uint64_t key, clingo_statistics_type_t *type)
 Get the type of a key. More...
 

Functions to access arrays

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_size (clingo_statistics_t const *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 const *statistics, uint64_t key, size_t offset, uint64_t *subkey)
 Get the subkey at the given offset of an array entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_push (clingo_statistics_t *statistics, uint64_t key, clingo_statistics_type_t type, uint64_t *subkey)
 Create the subkey at the end of an array entry. More...
 

Functions to access maps

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_size (clingo_statistics_t const *statistics, uint64_t key, size_t *size)
 Get the number of subkeys of a map entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_has_subkey (clingo_statistics_t const *statistics, uint64_t key, char const *name, bool *result)
 Test if the given map contains a specific subkey. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_subkey_name (clingo_statistics_t const *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 const *statistics, uint64_t key, char const *name, uint64_t *subkey)
 Lookup a subkey under the given name. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_add_subkey (clingo_statistics_t *statistics, uint64_t key, char const *name, clingo_statistics_type_t type, uint64_t *subkey)
 Add a subkey with the given name. More...
 

Functions to inspect and change values

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_value_get (clingo_statistics_t const *statistics, uint64_t key, double *value)
 Get the value of the given entry. More...
 
CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_value_set (clingo_statistics_t *statistics, uint64_t key, double value)
 Set the value of the given entry. More...
 

Enumeration Type Documentation

◆ clingo_statistics_type_e

Enumeration for entries of the statistics.

Enumerator
clingo_statistics_type_empty 

the entry is invalid (has neither of the types below)

clingo_statistics_type_value 

the entry is a (double) value

clingo_statistics_type_array 

the entry is an array

clingo_statistics_type_map 

the entry is a map

Function Documentation

◆ clingo_statistics_array_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_at ( clingo_statistics_t const *  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_push()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_array_push ( clingo_statistics_t statistics,
uint64_t  key,
clingo_statistics_type_t  type,
uint64_t *  subkey 
)

Create the subkey at the end 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]typethe type of the new subkey
[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 const *  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_add_subkey()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_add_subkey ( clingo_statistics_t statistics,
uint64_t  key,
char const *  name,
clingo_statistics_type_t  type,
uint64_t *  subkey 
)

Add a subkey with the given name.

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

◆ clingo_statistics_map_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_at ( clingo_statistics_t const *  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_has_subkey()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_has_subkey ( clingo_statistics_t const *  statistics,
uint64_t  key,
char const *  name,
bool *  result 
)

Test if the given map contains a specific subkey.

Precondition
The type of the entry must be clingo_statistics_type_map.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[in]namename of the subkey
[out]resulttrue if the map has a subkey with the given name
Returns
whether the call was successful

◆ clingo_statistics_map_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_map_size ( clingo_statistics_t const *  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 const *  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.

◆ clingo_statistics_root()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_root ( clingo_statistics_t const *  statistics,
uint64_t *  key 
)

Get the root key of the statistics.

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

◆ clingo_statistics_type()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_type ( clingo_statistics_t const *  statistics,
uint64_t  key,
clingo_statistics_type_t type 
)

Get the type of a key.

Parameters
[in]statisticsthe target statistics
[in]keythe key
[out]typethe resulting type
Returns
whether the call was successful
Examples:
statistics.c.

◆ clingo_statistics_value_get()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_value_get ( clingo_statistics_t const *  statistics,
uint64_t  key,
double *  value 
)

Get the value of the given entry.

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

◆ clingo_statistics_value_set()

CLINGO_VISIBILITY_DEFAULT bool clingo_statistics_value_set ( clingo_statistics_t statistics,
uint64_t  key,
double  value 
)

Set the value of the given entry.

Precondition
The type of the entry must be clingo_statistics_type_value.
Parameters
[in]statisticsthe target statistics
[in]keythe key
[out]valuethe new value
Returns
whether the call was successful
Examples:
statistics.c.