Clingo
Loading...
Searching...
No Matches
propagate.hh
1#pragma once
2
3#include <clingo/base.hh>
4#include <clingo/core.hh>
5
6#include <clingo/propagate.h>
7
8namespace Clingo {
9
14
22
28
35
44
52class Trail {
53 public:
57 using size_type = std::size_t;
59 using difference_type = std::ptrdiff_t;
63 using pointer = Detail::ArrowProxy<value_type>;
65 using iterator = Detail::RandomAccessIterator<Trail>;
66
72 explicit Trail(clingo_assignment_t const *assignment) : assignment_{assignment} {}
73
79 [[nodiscard]] auto at(size_type index) const -> value_type {
80 return Detail::call<clingo_assignment_trail_at>(assignment_, index);
81 }
82
84 [[nodiscard]] auto operator[](size_type index) const -> value_type { return at(index); }
85
89 [[nodiscard]] auto size() const -> size_type { return Detail::call<clingo_assignment_trail_size>(assignment_); }
90
94 [[nodiscard]] auto begin() const -> iterator { return iterator{*this, 0}; }
95
99 [[nodiscard]] auto end() const -> iterator { return iterator{*this, size()}; }
100
106 return iterator{*this, Detail::call<clingo_assignment_trail_begin>(assignment_, level)};
107 }
108
113 [[nodiscard]] auto end(ProgramId level) const -> iterator {
114 return iterator{*this, Detail::call<clingo_assignment_trail_end>(assignment_, level)};
115 }
116
121 [[nodiscard]] auto level(ProgramId level) const { return std::ranges::subrange{begin(level), end(level)}; }
122
123 private:
124 clingo_assignment_t const *assignment_;
125};
126
141 public:
145 using size_type = std::size_t;
147 using difference_type = std::ptrdiff_t;
151 using pointer = Detail::ArrowProxy<value_type>;
153 using iterator = Detail::RandomAccessIterator<Assignment>;
154
156 explicit Assignment(clingo_assignment_t const *assignment) : assignment_(assignment) {}
157
164 [[nodiscard]] auto size() const -> size_type { return Detail::call<clingo_assignment_size>(assignment_); }
165
170 [[nodiscard]] auto at(size_type size) const -> value_type {
171 return Detail::call<clingo_assignment_at>(assignment_, size);
172 }
173
175 [[nodiscard]] auto operator[](size_type size) const -> value_type { return at(size); }
176
182 return Detail::call<clingo_assignment_decision>(assignment_, level);
183 }
184
189 return Detail::call<clingo_assignment_decision_level>(assignment_);
190 }
191
195 [[nodiscard]] auto has_conflict() const -> bool {
196 return Detail::call<clingo_assignment_has_conflict>(assignment_);
197 }
198
202 [[nodiscard]] auto contains(SolverLiteral lit) const -> bool {
203 return Detail::call<clingo_assignment_has_literal>(assignment_, lit);
204 }
205
210 [[nodiscard]] auto is_false(SolverLiteral lit) const -> bool {
211 return Detail::call<clingo_assignment_is_false>(assignment_, lit);
212 }
213
218 [[nodiscard]] auto is_fixed(SolverLiteral lit) const -> bool {
219 return Detail::call<clingo_assignment_is_fixed>(assignment_, lit);
220 }
221
226 [[nodiscard]] auto is_free(SolverLiteral lit) const -> bool {
227 return Detail::call<clingo_assignment_truth_value>(assignment_, lit) == clingo_truth_value_free;
228 }
229
234 [[nodiscard]] auto is_true(SolverLiteral lit) const -> bool {
235 return Detail::call<clingo_assignment_is_true>(assignment_, lit);
236 }
237
243 [[nodiscard]] auto is_total() const -> bool { return Detail::call<clingo_assignment_is_total>(assignment_); }
244
249 [[nodiscard]] auto level(SolverLiteral lit) const -> ProgramId {
250 return Detail::call<clingo_assignment_level>(assignment_, lit);
251 }
252
260 [[nodiscard]] auto value(SolverLiteral lit) const -> std::optional<bool> {
261 clingo_truth_value_t res = Detail::call<clingo_assignment_truth_value>(assignment_, lit);
262 switch (res) {
264 return true;
265 }
267 return false;
268 }
269 default: {
270 return std::nullopt;
271 }
272 }
273 }
274
282 return Detail::call<clingo_assignment_root_level>(assignment_);
283 }
284
288 [[nodiscard]] auto trail() const -> Trail { return Trail{assignment_}; }
289
293 [[nodiscard]] auto begin() const -> iterator { return iterator{*this, 0}; }
294
298 [[nodiscard]] auto end() const -> iterator { return iterator{*this, size()}; }
299
300 private:
301 clingo_assignment_t const *assignment_;
302};
303
319 public:
324
329 return Assignment{Detail::call<clingo_propagate_init_assignment>(init_)};
330 }
331
336 return Library{Detail::call<clingo_propagate_init_library>(init_), true};
337 }
338
342 [[nodiscard]] auto base() const -> Base { return Base{Detail::call<clingo_propagate_init_base>(init_)}; }
343
348 return static_cast<PropagatorCheckMode>(Detail::call<clingo_propagate_init_get_check_mode>(init_));
349 }
350
355 Detail::handle_error(
357 }
358
363 return Detail::call<clingo_propagate_init_number_of_threads>(init_);
364 }
365
370 return static_cast<PropagatorUndoMode>(Detail::call<clingo_propagate_init_get_undo_mode>(init_));
371 }
372
376 void undo_mode(PropagatorUndoMode mode) const {
377 Detail::handle_error(
379 }
380
390 return Detail::call<clingo_propagate_init_add_clause>(init_, literals.data(), literals.size());
391 }
392
404
412 [[nodiscard]] auto add_literal(bool freeze = true) const -> SolverLiteral {
413 return Detail::call<clingo_propagate_init_add_literal>(init_, freeze);
414 }
415
421 void add_minimize(SolverLiteral literal, Weight weight, Weight priority) const {
422 Detail::handle_error(clingo_propagate_init_add_minimize(init_, literal, weight, priority));
423 }
424
435 void add_watch(SolverLiteral literal, std::optional<ProgramId> thread_id = std::nullopt) const {
436 if (thread_id) {
437 Detail::handle_error(clingo_propagate_init_add_watch_to_thread(init_, literal, *thread_id));
438 } else {
439 Detail::handle_error(clingo_propagate_init_add_watch(init_, literal));
440 }
441 }
442
452 WeightConstraintType type, bool compare_equal) const -> bool {
453 return Detail::call<clingo_propagate_init_add_weight_constraint>(init_, literal, literals.data(),
454 literals.size(), bound, type, compare_equal);
455 }
456
462 void freeze_literal(SolverLiteral literal) const {
463 Detail::handle_error(clingo_propagate_init_freeze_literal(init_, literal));
464 }
465
472 [[nodiscard]] auto propagate() const -> bool { return Detail::call<clingo_propagate_init_propagate>(init_); }
473
480 void remove_watch(SolverLiteral literal, std::optional<ProgramId> thread_id) const {
481 if (thread_id) {
482 Detail::handle_error(clingo_propagate_init_remove_watch_from_thread(init_, literal, *thread_id));
483 } else {
484 Detail::handle_error(clingo_propagate_init_remove_watch(init_, literal));
485 }
486 }
487
493 return Detail::call<clingo_propagate_init_solver_literal>(init_, literal);
494 }
495
496 private:
498};
499
505 public:
510
518 return Detail::call<clingo_propagate_control_add_literal>(ctl_);
519 }
520
531 return Detail::call<clingo_propagate_control_add_clause>(ctl_, literals.data(), literals.size(),
532 static_cast<clingo_clause_type_t>(flags));
533 }
534
547
556 return add_clause(Detail::transform(literals, [](auto const &lit) { return -lit; }), flags);
557 }
558
562 void add_watch(SolverLiteral literal) const {
563 Detail::handle_error(clingo_propagate_control_add_watch(ctl_, literal));
564 }
565
570 [[nodiscard]] auto has_watch(SolverLiteral literal) const -> bool {
571 return Detail::call<clingo_propagate_control_has_watch>(ctl_, literal);
572 }
573
581 [[nodiscard]] auto propagate() const -> bool { return Detail::call<clingo_propagate_control_propagate>(ctl_); }
582
586 void remove_watch(SolverLiteral lit) const {
587 Detail::handle_error(clingo_propagate_control_remove_watch(ctl_, lit));
588 }
589
594 return Assignment{Detail::call<clingo_propagate_control_assignment>(ctl_)};
595 }
596
600 [[nodiscard]] auto thread_id() const -> ProgramId { return Detail::call<clingo_propagate_control_thread_id>(ctl_); }
601
602 private:
604};
605
608 public:
610 Propagator() = default;
614 virtual ~Propagator() = default;
615
619 void init(PropagateInit init) { do_init(init); }
620
632
644 void undo(ProgramId thread_id, Assignment assignment, ProgramLiteralSpan changes) {
645 do_undo(thread_id, assignment, changes);
646 }
647
657 void check(PropagateControl ctl) { do_check(ctl); }
658
659 private:
660 virtual void do_init([[maybe_unused]] PropagateInit init) {}
661 virtual void do_propagate([[maybe_unused]] PropagateControl ctl, [[maybe_unused]] ProgramLiteralSpan changes) {}
662 virtual void do_undo([[maybe_unused]] uint32_t thread_id, [[maybe_unused]] Assignment assignment,
664 virtual void do_check([[maybe_unused]] PropagateControl ctl) {}
665};
666
668class Heuristic : public Propagator {
669 public:
671 Heuristic() = default;
672
682 auto decide(ProgramId thread_id, Assignment assignment, SolverLiteral literal) -> SolverLiteral {
683 return do_decide(thread_id, assignment, literal);
684 }
685
686 private:
687 virtual auto do_decide([[maybe_unused]] uint32_t thread_id, [[maybe_unused]] Assignment assignment,
689 return literal;
690 }
691};
692
694
695namespace Detail {
696
697inline static constexpr auto c_propagator = clingo_propagator_t{
698 [](clingo_propagate_init_t *init, void *data) -> bool {
699 auto &self = *static_cast<Propagator *>(data);
700 CLINGO_TRY {
701 self.init(PropagateInit{init});
702 }
703 CLINGO_CATCH;
704 },
705 [](clingo_propagate_control_t *control, clingo_literal_t const *changes, size_t size, void *data) -> bool {
706 auto &self = *static_cast<Propagator *>(data);
707 CLINGO_TRY {
708 self.propagate(PropagateControl{control}, SolverLiteralSpan{changes, size});
709 }
710 CLINGO_CATCH;
711 },
712 [](clingo_propagate_control_t const *control, clingo_literal_t const *changes, size_t size, void *data) {
713 auto &self = *static_cast<Propagator *>(data);
714 try {
715 uint32_t thread_id = Detail::call<clingo_propagate_control_thread_id>(control);
716 clingo_assignment_t const *assignment = Detail::call<clingo_propagate_control_assignment>(control);
717 self.undo(thread_id, Assignment{assignment}, SolverLiteralSpan{changes, size});
718 } catch (std::exception const &e) {
719 printf("panic: %s\n", e.what());
720 std::abort();
721 }
722 },
723 [](clingo_propagate_control_t *control, void *data) -> bool {
724 auto &self = *static_cast<Propagator *>(data);
725 CLINGO_TRY {
726 self.check(PropagateControl{control});
727 }
728 CLINGO_CATCH;
729 },
730 nullptr,
731 [](void *data) { std::ignore = std::unique_ptr<Propagator>(static_cast<Propagator *>(data)); },
732};
733
734inline static constexpr auto c_heuristic = clingo_propagator_t{
735 c_propagator.init,
736 c_propagator.propagate,
737 c_propagator.undo,
738 c_propagator.check,
739 [](clingo_id_t thread_id, clingo_assignment_t const *assignment, clingo_literal_t fallback, void *data,
740 clingo_literal_t *decision) -> bool {
741 auto &self = *static_cast<Propagator *>(data);
742 CLINGO_TRY {
743 // NOLINTBEGIN
744 *decision = static_cast<Heuristic &>(self).decide(thread_id, Assignment{assignment}, fallback);
745 // NOLINTEND
746 }
747 CLINGO_CATCH;
748 },
749 c_propagator.free,
750};
751
752} // namespace Detail
753
754} // namespace Clingo
Represents a (partial) assignment of a particular solver.
Definition propagate.hh:140
value_type reference
The reference type, which simply refers to the value type.
Definition propagate.hh:149
auto has_conflict() const -> bool
Check if the assignment is conflicting.
Definition propagate.hh:195
SolverLiteral value_type
The value type, which is a solver literal.
Definition propagate.hh:143
auto contains(SolverLiteral lit) const -> bool
Check whether the assignment contains the given literal.
Definition propagate.hh:202
auto is_free(SolverLiteral lit) const -> bool
Check if the truth value of the given literal is free.
Definition propagate.hh:226
auto begin() const -> iterator
Get an iterator to the beginning of the assignment.
Definition propagate.hh:293
auto trail() const -> Trail
Get the trail of the assignment.
Definition propagate.hh:288
auto size() const -> size_type
Get the size of the assignment.
Definition propagate.hh:164
auto decision(ProgramId level) const -> SolverLiteral
Get the decision literal for the given decision level.
Definition propagate.hh:181
auto is_fixed(SolverLiteral lit) const -> bool
Check if the truth value of the given literal is fixed.
Definition propagate.hh:218
auto value(SolverLiteral lit) const -> std::optional< bool >
Get the truth value of the given literal.
Definition propagate.hh:260
auto is_total() const -> bool
Check whether the assignment is total.
Definition propagate.hh:243
Assignment(clingo_assignment_t const *assignment)
Construct an assignment from the underlying C representation.
Definition propagate.hh:156
auto at(size_type size) const -> value_type
Get the literal at the given index in the assignment.
Definition propagate.hh:170
Detail::RandomAccessIterator< Assignment > iterator
The iterator type, which is a random access iterator over the assignment.
Definition propagate.hh:153
auto level(SolverLiteral lit) const -> ProgramId
Get the level on which the given literal was assigned.
Definition propagate.hh:249
std::ptrdiff_t difference_type
The difference type.
Definition propagate.hh:147
auto end() const -> iterator
Get an iterator to the end of the assignment.
Definition propagate.hh:298
auto decision_level() const -> ProgramId
Get the current decision level.
Definition propagate.hh:188
auto root_level() const -> ProgramId
Get the root level of the assignment.
Definition propagate.hh:281
auto is_true(SolverLiteral lit) const -> bool
Check if the given literal is true.
Definition propagate.hh:234
auto is_false(SolverLiteral lit) const -> bool
Check if the given literal is false.
Definition propagate.hh:210
std::size_t size_type
The size type.
Definition propagate.hh:145
auto operator[](size_type size) const -> value_type
Get the literal at the given index in the assignment.
Definition propagate.hh:175
Detail::ArrowProxy< value_type > pointer
The pointer type, which is a proxy to the value type.
Definition propagate.hh:151
A base that maps signatures to atom bases, and captures term and theory bases.
Definition base.hh:608
Interface for user-defined propagators with a decision heuristic.
Definition propagate.hh:668
Heuristic()=default
The default constructor.
auto decide(ProgramId thread_id, Assignment assignment, SolverLiteral literal) -> SolverLiteral
Callback to decide on the next literal to assign.
Definition propagate.hh:682
The main library class for managing global information and logging.
Definition core.hh:471
Class to control propagation of a user-defined propagator.
Definition propagate.hh:504
auto add_clause(SolverLiteralSpan literals, ClauseFlags flags=ClauseFlags::none) const -> bool
Add a clause to the solver.
Definition propagate.hh:530
auto thread_id() const -> ProgramId
Get the thread id of the current solver.
Definition propagate.hh:600
auto add_clause(SolverLiteralList literals, ClauseFlags flags=ClauseFlags::none) const -> bool
Add a clause to the solver.
Definition propagate.hh:544
auto propagate() const -> bool
Propagate consequences of previously added clauses.
Definition propagate.hh:581
PropagateControl(clingo_propagate_control_t *ctl)
Constructor from the underlying C representation.
Definition propagate.hh:509
auto add_literal() const -> SolverLiteral
Add solver local literal to the solver.
Definition propagate.hh:517
void remove_watch(SolverLiteral lit) const
Remove a watch for the given solver literal.
Definition propagate.hh:586
auto assignment() const -> Assignment
Get the assignment of the current solver.
Definition propagate.hh:593
auto add_nogood(SolverLiteralSpan literals, ClauseFlags flags=ClauseFlags::none) const -> bool
Add a nogood to the solver.
Definition propagate.hh:555
void add_watch(SolverLiteral literal) const
Add a watch for the given solver literal.
Definition propagate.hh:562
auto has_watch(SolverLiteral literal) const -> bool
Check whether the given solver literal is watched.
Definition propagate.hh:570
Object to initialize a user-defined propagator before each solving step.
Definition propagate.hh:318
auto add_clause(SolverLiteralSpan literals) const -> bool
Add a clause to the solver.
Definition propagate.hh:389
PropagateInit(clingo_propagate_init_t *init)
Constructor from the underlying C representation.
Definition propagate.hh:323
auto propagate() const -> bool
Propagate consequences of the underlying problem.
Definition propagate.hh:472
auto add_literal(bool freeze=true) const -> SolverLiteral
Add a literal to the solver.
Definition propagate.hh:412
auto library() const -> Library
Get the library object associated with the propagator.
Definition propagate.hh:335
void freeze_literal(SolverLiteral literal) const
Freeze the given literal in the solver.
Definition propagate.hh:462
void add_minimize(SolverLiteral literal, Weight weight, Weight priority) const
Add a weighted literal to minimize to the solver.
Definition propagate.hh:421
void remove_watch(SolverLiteral literal, std::optional< ProgramId > thread_id) const
Remove a watch for the given solver literal.
Definition propagate.hh:480
auto check_mode() const -> PropagatorCheckMode
Get the check mode of the propagator.
Definition propagate.hh:347
void undo_mode(PropagatorUndoMode mode) const
Set the undo mode of the propagator.
Definition propagate.hh:376
auto assignment() const -> Assignment
Get the assignment of the current solver.
Definition propagate.hh:328
auto add_weight_constraint(SolverLiteral literal, WeightedLiteralSpan literals, Weight bound, WeightConstraintType type, bool compare_equal) const -> bool
Add a weight constraint to the solver.
Definition propagate.hh:451
auto solver_literal(ProgramLiteral literal) const -> SolverLiteral
Map a program literal to a solver literal.
Definition propagate.hh:492
auto undo_mode() const -> PropagatorUndoMode
Get the undo mode of the propagator.
Definition propagate.hh:369
auto base() const -> Base
Get the base object associated with the propagator.
Definition propagate.hh:342
void check_mode(PropagatorCheckMode mode)
Set the check mode of the propagator.
Definition propagate.hh:354
auto number_of_threads() const -> ProgramId
Get the number of threads used in subsequent solving.
Definition propagate.hh:362
auto add_clause(SolverLiteralList literals) const -> bool
Add a clause to the solver.
Definition propagate.hh:401
void add_watch(SolverLiteral literal, std::optional< ProgramId > thread_id=std::nullopt) const
Add a watch for the given solver literal.
Definition propagate.hh:435
Interface for user-defined propagators.
Definition propagate.hh:607
void check(PropagateControl ctl)
Callback that is called on propagation fixpoints or total assignments.
Definition propagate.hh:657
void init(PropagateInit init)
Callback to initialize the propagator before each solving step.
Definition propagate.hh:619
Propagator()=default
The default constructor.
void propagate(PropagateControl ctl, ProgramLiteralSpan changes)
Callback to propagate consequences of the given literals.
Definition propagate.hh:631
Propagator(Propagator &&other)=delete
Disable copy and move operations.
void undo(ProgramId thread_id, Assignment assignment, ProgramLiteralSpan changes)
Called when the solver backtracks to a previous decision level.
Definition propagate.hh:644
virtual ~Propagator()=default
The default destructor.
A trail is a sequence of solver literals.
Definition propagate.hh:52
value_type reference
The reference type, which simply refers to the value type.
Definition propagate.hh:61
auto end(ProgramId level) const -> iterator
Get an iterator to the end of the given decision level.
Definition propagate.hh:113
Trail(clingo_assignment_t const *assignment)
Construct a trail from the underlying C representation.
Definition propagate.hh:72
Detail::RandomAccessIterator< Trail > iterator
The iterator type, which is a random access iterator over the trail.
Definition propagate.hh:65
auto size() const -> size_type
Get the size of the trail.
Definition propagate.hh:89
auto operator[](size_type index) const -> value_type
Get the literal at the given index in the trail.
Definition propagate.hh:84
auto level(ProgramId level) const
Get the subrange of the literals of the given decision level.
Definition propagate.hh:121
std::ptrdiff_t difference_type
The difference type.
Definition propagate.hh:59
Detail::ArrowProxy< value_type > pointer
The pointer type, which is a proxy to the value type.
Definition propagate.hh:63
auto begin() const -> iterator
Get an iterator to the beginning of the trail.
Definition propagate.hh:94
SolverLiteral value_type
The value type is a solver literal.
Definition propagate.hh:55
auto at(size_type index) const -> value_type
Get the literal at the given index in the trail.
Definition propagate.hh:79
auto begin(ProgramId level) const -> iterator
Get an iterator to the beginning of the given decision level.
Definition propagate.hh:105
std::size_t size_type
The size type.
Definition propagate.hh:57
auto end() const -> iterator
Get an iterator to the end of the trail.
Definition propagate.hh:99
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
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_set_undo_mode(clingo_propagate_init_t *init, clingo_propagator_undo_mode_t mode)
Configure when to call the undo method of the propagator.
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_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_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.
int clingo_propagator_undo_mode_t
Corresponding type to clingo_propagator_undo_mode_e.
Definition propagate.h:221
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
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_remove_watch(clingo_propagate_init_t *init, clingo_literal_t solver_literal)
Remove the watch for the solver literal in the given phase.
int clingo_truth_value_t
Corresponding type to clingo_truth_value_e.
Definition propagate.h:55
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_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.
int clingo_clause_type_t
Corresponding type to clingo_clause_type_e.
Definition propagate.h:447
@ 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_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
@ tuple
Theory tuples "(t1,...,tn)".
clingo_literal_t SolverLiteral
A solver literal.
Definition core.hh:399
std::initializer_list< SolverLiteral const > SolverLiteralList
A list of solver literals.
Definition core.hh:403
clingo_weight_t Weight
A weight used in sum aggregates and minimize constraints.
Definition core.hh:408
clingo_literal_t ProgramLiteral
A program literal.
Definition core.hh:392
std::span< SolverLiteral const > SolverLiteralSpan
A span of solver literals.
Definition core.hh:401
std::span< WeightedLiteral const > WeightedLiteralSpan
A span of weighted literals.
Definition core.hh:415
clingo_id_t ProgramId
A program id used for various kinds of indices.
Definition core.hh:382
std::span< ProgramLiteral const > ProgramLiteralSpan
A span of program literals.
Definition core.hh:394
@ level
Set the level of an atom.
@ init
Modify the initial VSIDS score of an atom.
WeightConstraintType
Enumeration of weight constraint types.
Definition propagate.hh:30
ClauseFlags
Enumeration of clause flags.
Definition propagate.hh:37
PropagatorCheckMode
Enumeration of propagator check modes.
Definition propagate.hh:16
PropagatorUndoMode
Enumeration of propagator undo modes.
Definition propagate.hh:24
@ equivalence
The weight constraint is equivalent to the literal.
Definition propagate.hh:33
@ implication_left
The weight constraint implies the literal.
Definition propagate.hh:31
@ implication_right
The literal implies the weight constraint.
Definition propagate.hh:32
@ lock
Exempt the clause from deletion.
Definition propagate.hh:39
@ tag
Delete the clause at the end of the current solving step.
Definition propagate.hh:40
@ none
The empty set of flags.
Definition propagate.hh:38
@ fixpoint
Call check on propagation fixpoints.
@ both
Call check on propagation fixpoints and total assignments.
@ total
Call check on total assignments.
@ default_
Call undo for non-empty change lists.
@ always
Also call undo for empty change lists.
#define CLINGO_ENABLE_BITSET_ENUM(E,...)
Opt-in macro for enabling bit operations for a given enum type.
Definition enum.hh:18
An instance of this struct has to be registered with a solver to implement a custom propagator.
Definition propagate.h:557