Clingo
Loading...
Searching...
No Matches
Solver Configuration

Configuration of search and enumeration algorithms. More...

Classes

struct  clingo_config_entry
 Callback interface for custom configuration entries. More...
 

Typedefs

typedef unsigned clingo_config_type_bitset_t
 Bitset for values of type clingo_config_type_e.
 
typedef struct clingo_config clingo_config_t
 Handle for to the solver configuration.
 
typedef struct clingo_config_entry clingo_config_entry_t
 Callback interface for custom configuration entries.
 

Enumerations

enum  clingo_config_type_e { clingo_config_type_value = 1 , clingo_config_type_array = 2 , clingo_config_type_map = 4 }
 Enumeration for entries of the configuration. More...
 

Functions

CLINGO_VISIBILITY_DEFAULT bool clingo_config_add (clingo_config_t *config, clingo_id_t parent, char const *name, size_t name_size, char const *description, size_t description_size, clingo_config_entry_t const *entry, void *data)
 Add a custom configuration entry under a parent key.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_root (clingo_config_t const *config, clingo_id_t *key)
 Get the root key of the configuration.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_type (clingo_config_t const *config, clingo_id_t key, clingo_config_type_bitset_t *type)
 Get the type of a key.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_description (clingo_config_t const *config, clingo_id_t key, clingo_string_t *description)
 Get the description of an entry.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_control_config (clingo_control_t *control, clingo_config_t **config)
 Get the configuration object.
 

Functions to access arrays

CLINGO_VISIBILITY_DEFAULT bool clingo_config_array_size (clingo_config_t const *config, clingo_id_t key, size_t *size)
 Get the size of an array entry.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_array_at (clingo_config_t const *config, clingo_id_t key, size_t offset, clingo_id_t *subkey)
 Get the subkey at the given offset of an array entry.
 

Functions to access maps

CLINGO_VISIBILITY_DEFAULT bool clingo_config_map_size (clingo_config_t const *config, clingo_id_t key, size_t *size)
 Get the number of subkeys of a map entry.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_map_subkey_name (clingo_config_t const *config, clingo_id_t key, size_t offset, clingo_string_t *name)
 Get the name associated with the offset-th subkey.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_map_at (clingo_config_t const *config, clingo_id_t key, char const *name, size_t size, clingo_id_t *subkey, bool *has_subkey)
 Lookup a subkey under the given name.
 

Functions to access values

CLINGO_VISIBILITY_DEFAULT bool clingo_config_value_get (clingo_config_t const *config, clingo_id_t key, clingo_string_t *value, bool *has_value)
 Get the string value of the given entry.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_value_set (clingo_config_t *config, clingo_id_t key, char const *value, size_t size)
 Set the value of an entry.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_config_to_string (clingo_config_t const *config, clingo_id_t key, clingo_string_builder_t *builder)
 Get the string representation of the given theory element.
 

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

Typedef Documentation

◆ clingo_config_entry_t

Callback interface for custom configuration entries.

This struct allows users to define custom configuration entries by providing function pointers for querying and manipulating the entry. The data pointer is passed to each callback and can be used to store user-defined state.

On each configuration path, there can be at most one array entry. If present, the array index is passed to all entries following an array entry in the path. It is up to the entry implementation to interpret an absent index (i.e., when index is NULL).

All callbacks are optional; if a callback is NULL, the corresponding operation is not supported for this entry.

Enumeration Type Documentation

◆ clingo_config_type_e

Enumeration for entries of the configuration.

Enumerator
clingo_config_type_value 

the entry is a (string) value

clingo_config_type_array 

the entry is an array

clingo_config_type_map 

the entry is a map

Function Documentation

◆ clingo_config_add()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_add ( clingo_config_t config,
clingo_id_t  parent,
char const *  name,
size_t  name_size,
char const *  description,
size_t  description_size,
clingo_config_entry_t const *  entry,
void *  data 
)

Add a custom configuration entry under a parent key.

The entry is defined by the provided callbacks and user data. The API takes ownership of the data pointer and will call the free callback (if non-NULL) when the entry is removed or the configuration is destroyed.

Parameters
[in]configthe configuration object
[in]parentthe parent key under which to add the entry
[in]namethe name of the new entry (not null-terminated)
[in]name_sizethe length of the name string
[in]descriptionthe description of the entry (not null-terminated)
[in]description_sizethe length of the description string
[in]entrypointer to the entry callbacks struct
[in]datauser data pointer for the entry callbacks
Returns
true on success, false on error

◆ clingo_config_array_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_array_at ( clingo_config_t const *  config,
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_config_type_array.
Parameters
[in]configthe target configuration
[in]keythe key
[in]offsetthe offset in the array
[out]subkeythe resulting subkey
Returns
whether the call was successful

◆ clingo_config_array_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_array_size ( clingo_config_t const *  config,
clingo_id_t  key,
size_t *  size 
)

Get the size of an array entry.

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

◆ clingo_config_description()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_description ( clingo_config_t const *  config,
clingo_id_t  key,
clingo_string_t description 
)

Get the description of an entry.

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

◆ clingo_config_map_at()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_map_at ( clingo_config_t const *  config,
clingo_id_t  key,
char const *  name,
size_t  size,
clingo_id_t subkey,
bool *  has_subkey 
)

Lookup a subkey under the given name.

Precondition
The type of the entry must be clingo_config_type_map.
Note
Multiple levels can be looked up by concatenating keys with a period.
Parameters
[in]configthe target configuration
[in]keythe key
[in]namethe name to look up the subkey
[in]sizethe size of the name
[out]subkeythe resulting subkey
[out]has_subkeywhether the map has the subkey
Returns
whether the call was successful

◆ clingo_config_map_size()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_map_size ( clingo_config_t const *  config,
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_config_type_map.
Parameters
[in]configthe target configuration
[in]keythe key
[out]sizethe resulting number
Returns
whether the call was successful

◆ clingo_config_map_subkey_name()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_map_subkey_name ( clingo_config_t const *  config,
clingo_id_t  key,
size_t  offset,
clingo_string_t name 
)

Get the name associated with the offset-th subkey.

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

◆ clingo_config_root()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_root ( clingo_config_t const *  config,
clingo_id_t key 
)

Get the root key of the configuration.

Parameters
[in]configthe target configuration
[out]keythe root key
Returns
whether the call was successful

◆ clingo_config_to_string()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_to_string ( clingo_config_t const *  config,
clingo_id_t  key,
clingo_string_builder_t builder 
)

Get the string representation of the given theory element.

Parameters
[in]configthe target configuration
[in]keythe key
[in]builderthe builder
Returns
whether the call was successful

◆ clingo_config_type()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_type ( clingo_config_t const *  config,
clingo_id_t  key,
clingo_config_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]configthe target configuration
[in]keythe key
[out]typethe resulting type
Returns
whether the call was successful

◆ clingo_config_value_get()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_value_get ( clingo_config_t const *  config,
clingo_id_t  key,
clingo_string_t value,
bool *  has_value 
)

Get the string value of the given entry.

Precondition
The type of the entry must be clingo_config_type_value.
Parameters
[in]configthe target configuration
[in]keythe key
[out]valuethe resulting string value
[out]has_valuewhether the config entry has a value
Returns
whether the call was successful

◆ clingo_config_value_set()

CLINGO_VISIBILITY_DEFAULT bool clingo_config_value_set ( clingo_config_t config,
clingo_id_t  key,
char const *  value,
size_t  size 
)

Set the value of an entry.

Precondition
The type of the entry must be clingo_config_type_value.
Parameters
[in]configthe target configuration
[in]keythe key
[in]valuethe value to set
[in]sizethe size of the value
Returns
whether the call was successful

◆ clingo_control_config()

CLINGO_VISIBILITY_DEFAULT bool clingo_control_config ( clingo_control_t *  control,
clingo_config_t **  config 
)

Get the configuration object.

Parameters
[in]controlthe target
[out]configthe configuration
Returns
whether the call was successful