1#ifndef CLINGO_PROPAGATE_H
2#define CLINGO_PROPAGATE_H
8#include <clingo/base.h>
9#include <clingo/core.h>
10#include <clingo/shared.h>
11#include <clingo/symbol.h>
13typedef struct clingo_control clingo_control_t;
80 bool *is_conflicting);
struct clingo_base clingo_base_t
Object to inspect symbolic atoms in a program—the relevant Herbrand base gringo uses to instantiate p...
Definition base.h:70
struct clingo_lib clingo_lib_t
A library object storing global information.
Definition core.h:176
int32_t clingo_literal_t
Signed integer type used for aspif and solver literals.
Definition core.h:78
uint32_t clingo_id_t
Unsigned integer type used in various places.
Definition core.h:82
int32_t clingo_weight_t
Signed integer type for weights in sum aggregates and minimize constraints.
Definition core.h:84
CLINGO_VISIBILITY_DEFAULT bool clingo_control_register_propagator(clingo_control_t *control, clingo_propagator_t const *propagator, void *data)
Register a custom propagator with the control object.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_add_weight_constraint(clingo_propagate_init_t *init, clingo_literal_t solver_literal, clingo_weighted_literal_t const *literals, size_t size, clingo_weight_t bound, clingo_weight_constraint_type_t type, bool compare_equal, bool *result)
Add the given weight constraint to the solver.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_truth_value(clingo_assignment_t const *assignment, clingo_literal_t literal, clingo_truth_value_t *value)
Determine the truth value of a given literal.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_add_watch(clingo_propagate_control_t *control, clingo_literal_t literal)
Add a watch for the solver literal in the given phase.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_assignment(clingo_propagate_init_t const *init, clingo_assignment_t const **assignment)
Get the top level assignment solver.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_is_fixed(clingo_assignment_t const *assignment, clingo_literal_t literal, bool *is_fixed)
Check if a literal has a fixed truth value.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_set_undo_mode(clingo_propagate_init_t *init, clingo_propagator_undo_mode_t mode)
Configure when to call the undo method of the propagator.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_has_conflict(clingo_assignment_t const *assignment, bool *is_conflicting)
Check if the given assignment is conflicting.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_solver_literal(clingo_propagate_init_t const *init, clingo_literal_t aspif_literal, clingo_literal_t *solver_literal)
Map the given program literal or condition id to its solver literal.
struct clingo_propagate_control clingo_propagate_control_t
This object can be used to add clauses and propagate literals while solving.
Definition propagate.h:450
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_trail_begin(clingo_assignment_t const *assignment, uint32_t level, uint32_t *offset)
Returns the offset of the decision literal with the given decision level in the trail.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_propagate(clingo_propagate_control_t *control, bool *result)
Propagate implied literals (resulting from added clauses).
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_remove_watch(clingo_propagate_control_t *control, clingo_literal_t literal)
Removes the watch (if any) for the given solver literal.
int clingo_weight_constraint_type_t
Corresponding type to clingo_weight_constraint_type_e.
Definition propagate.h:230
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_trail_end(clingo_assignment_t const *assignment, uint32_t level, uint32_t *offset)
Returns the offset following the last literal with the given decision level.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_has_watch(clingo_propagate_control_t const *control, clingo_literal_t literal, bool *has_watch)
Check whether a literal is watched in the current solver thread.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_add_literal(clingo_propagate_init_t *init, bool freeze, clingo_literal_t *solver_literal)
Add a literal to the solver.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_add_minimize(clingo_propagate_init_t *init, clingo_literal_t solver_literal, clingo_weight_t weight, clingo_weight_t priority)
Add the given literal to minimize to the solver.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_size(clingo_assignment_t const *assignment, size_t *size)
The number of (positive) literals in the assignment.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_number_of_threads(clingo_propagate_init_t const *init, clingo_id_t *threads)
Get the number of threads used in subsequent solving.
void(* clingo_propagator_undo_callback_t)(clingo_propagate_control_t const *, clingo_literal_t const *, size_t, void *)
Typedef for clingo_propagator::undo().
Definition propagate.h:547
int clingo_propagator_undo_mode_t
Corresponding type to clingo_propagator_undo_mode_e.
Definition propagate.h:221
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_is_false(clingo_assignment_t const *assignment, clingo_literal_t literal, bool *is_false)
Check if a literal has a fixed truth value.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_add_watch_to_thread(clingo_propagate_init_t *init, clingo_literal_t solver_literal, clingo_id_t thread_id)
Add a watch for the solver literal in the given phase to the given solver thread.
struct clingo_assignment clingo_assignment_t
Represents a (partial) assignment of a particular solver.
Definition propagate.h:46
struct clingo_propagate_init clingo_propagate_init_t
Object to initialize a user-defined propagator before each solving step.
Definition propagate.h:243
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_base(clingo_propagate_init_t const *init, clingo_base_t const **base)
Get an object to inspect the base.
bool(* clingo_propagator_init_callback_t)(clingo_propagate_init_t *, void *)
Typedef for clingo_propagator::init().
Definition propagate.h:540
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_get_undo_mode(clingo_propagate_init_t const *init, clingo_propagator_undo_mode_t *mode)
Get the current undo mode of the propagator.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_trail_size(clingo_assignment_t const *assignment, uint32_t *size)
Returns the number of literals in the trail, i.e., the number of assigned literals.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_trail_at(clingo_assignment_t const *assignment, uint32_t offset, clingo_literal_t *literal)
Returns the literal at the given position in the trail.
int clingo_propagator_check_mode_t
Corresponding type to clingo_propagator_check_mode_e.
Definition propagate.h:213
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_get_check_mode(clingo_propagate_init_t const *init, clingo_propagator_check_mode_t *mode)
Get the current check mode of the propagator.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_thread_id(clingo_propagate_control_t const *control, clingo_id_t *thread_id)
Get the id of the underlying solver thread.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_propagate(clingo_propagate_init_t *init, bool *result)
Propagates consequences of the underlying problem excluding registered propagators.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_assignment(clingo_propagate_control_t const *control, clingo_assignment_t const **assignment)
Get the assignment associated with the underlying solver.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_add_literal(clingo_propagate_control_t *control, clingo_literal_t *result)
Adds a new volatile literal to the underlying solver thread.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_remove_watch(clingo_propagate_init_t *init, clingo_literal_t solver_literal)
Remove the watch for the solver literal in the given phase.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_decision(clingo_assignment_t const *assignment, uint32_t level, clingo_literal_t *literal)
Determine the decision literal given a decision level.
int clingo_truth_value_t
Corresponding type to clingo_truth_value_e.
Definition propagate.h:55
bool(* clingo_propagator_check_callback_t)(clingo_propagate_control_t *, void *)
Typedef for clingo_propagator::check().
Definition propagate.h:551
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_set_check_mode(clingo_propagate_init_t *init, clingo_propagator_check_mode_t mode)
Configure when to call the check method of the propagator.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_is_true(clingo_assignment_t const *assignment, clingo_literal_t literal, bool *is_true)
Check if a literal is true.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_add_watch(clingo_propagate_init_t *init, clingo_literal_t solver_literal)
Add a watch for the solver literal in the given phase.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_remove_watch_from_thread(clingo_propagate_init_t *init, clingo_literal_t solver_literal, uint32_t thread_id)
Remove the watch for the solver literal in the given phase from the given solver thread.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_freeze_literal(clingo_propagate_init_t *init, clingo_literal_t solver_literal)
Freeze the given solver literal.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_at(clingo_assignment_t const *assignment, size_t offset, clingo_literal_t *literal)
The (positive) literal at the given offset in the assignment.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_has_literal(clingo_assignment_t const *assignment, clingo_literal_t literal, bool *is_valid)
Check if the given literal is part of a (partial) assignment.
clingo_propagator_check_mode_e
Supported check modes for propagators.
Definition propagate.h:205
clingo_truth_value_e
Represents three-valued truth values.
Definition propagate.h:49
int clingo_clause_type_t
Corresponding type to clingo_clause_type_e.
Definition propagate.h:447
clingo_clause_type_e
Enumeration of clause types determining the lifetime of a clause.
Definition propagate.h:438
clingo_propagator_undo_mode_e
Undo modes for propagators.
Definition propagate.h:216
struct clingo_propagator clingo_propagator_t
An instance of this struct has to be registered with a solver to implement a custom propagator.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_is_total(clingo_assignment_t const *assignment, bool *is_total)
Check if the assignment is total, i.e.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_library(clingo_propagate_init_t const *init, clingo_lib_t **lib)
Get the underlying library object.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_level(clingo_assignment_t const *assignment, clingo_literal_t literal, uint32_t *level)
Determine the decision level of a given literal.
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_control_add_clause(clingo_propagate_control_t *control, clingo_literal_t const *literals, size_t size, clingo_clause_type_t type, bool *result)
Add the given clause to the solver.
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_decision_level(clingo_assignment_t const *assignment, uint32_t *level)
Get the current decision level.
bool(* clingo_propagator_propagate_callback_t)(clingo_propagate_control_t *, clingo_literal_t const *, size_t, void *)
Typedef for clingo_propagator::propagate().
Definition propagate.h:543
CLINGO_VISIBILITY_DEFAULT bool clingo_propagate_init_add_clause(clingo_propagate_init_t *init, clingo_literal_t const *literals, size_t size, bool *result)
Add the given clause to the solver.
clingo_weight_constraint_type_e
Enumeration of weight_constraint_types.
Definition propagate.h:224
CLINGO_VISIBILITY_DEFAULT bool clingo_assignment_root_level(clingo_assignment_t const *assignment, uint32_t *level)
Get the current root level.
@ clingo_propagator_check_mode_both
call clingo_propagator::check() on propagation fixpoints and total assignments
Definition propagate.h:209
@ clingo_propagator_check_mode_none
do not call clingo_propagator::check() at all
Definition propagate.h:206
@ clingo_propagator_check_mode_fixpoint
call clingo_propagator::check() on propagation fixpoints
Definition propagate.h:208
@ clingo_propagator_check_mode_total
call clingo_propagator::check() on total assignments
Definition propagate.h:207
@ clingo_truth_value_false
false
Definition propagate.h:52
@ clingo_truth_value_true
true
Definition propagate.h:51
@ clingo_truth_value_free
no truth value
Definition propagate.h:50
@ clingo_clause_type_learnt
clause is subject to the solvers deletion policy
Definition propagate.h:439
@ clingo_clause_type_volatile
like clingo_clause_type_learnt but the clause is deleted after a solving step
Definition propagate.h:441
@ clingo_clause_type_static
clause is not subject to the solvers deletion policy
Definition propagate.h:440
@ clingo_clause_type_volatile_static
like clingo_clause_type_static but the clause is deleted after a solving step
Definition propagate.h:443
@ clingo_propagator_undo_mode_default
call clingo_propagator::undo() for non-empty change lists
Definition propagate.h:217
@ clingo_propagator_undo_mode_always
also call clingo_propagator::check() when check has been called
Definition propagate.h:218
@ clingo_weight_constraint_type_implication_right
the literal implies the weight constraint
Definition propagate.h:226
@ clingo_weight_constraint_type_implication_left
the weight constraint implies the literal
Definition propagate.h:225
@ clingo_weight_constraint_type_equivalence
the weight constraint is equivalent to the literal
Definition propagate.h:227
An instance of this struct has to be registered with a solver to implement a custom propagator.
Definition propagate.h:557
void(* free)(void *data)
Free the propagator.
Definition propagate.h:656
bool(* check)(clingo_propagate_control_t *control, void *data)
This function is similar to clingo_propagate_control_propagate() but is called without a change set o...
Definition propagate.h:637
bool(* init)(clingo_propagate_init_t *init, void *data)
This function is called once before each solving step.
Definition propagate.h:569
void(* undo)(clingo_propagate_control_t const *control, clingo_literal_t const *changes, size_t size, void *data)
Called whenever a solver undoes assignments to watched solver literals.
Definition propagate.h:624
bool(* propagate)(clingo_propagate_control_t *control, clingo_literal_t const *changes, size_t size, void *data)
Can be used to propagate solver literals given a partial assignment.
Definition propagate.h:611
bool(* decide)(clingo_id_t thread_id, clingo_assignment_t const *assignment, clingo_literal_t fallback, void *data, clingo_literal_t *decision)
This function allows a propagator to implement domain-specific heuristics.
Definition propagate.h:652
A literal with an associated weight.
Definition core.h:86