3#include <clingo/base.hh>
4#include <clingo/core.hh>
6#include <clingo/observe.h>
32 void init_program(
bool incremental) { do_init_program(incremental); }
54 do_weight_rule(head, lower, body, choice);
85 do_heuristic(atom, type, bias, priority, condition);
98 void observe(clingo_control_t *ctl,
bool preprocess) {
100 [](
bool incremental,
void *data) ->
bool {
106 [](
void *data) ->
bool {
119 void *data) ->
bool {
121 static_cast<Observer *
>(data)->
rule(std::span{head, head_size}, std::span{body, body_size},
choice);
129 std::span{body, body_size},
choice);
135 static_cast<Observer *
>(data)->
minimize(std::span{body, body_size}, priority);
161 std::span{condition, size});
165 [](
int node_u,
int node_v,
clingo_literal_t const *condition,
size_t size,
void *data) ->
bool {
167 static_cast<Observer *
>(data)->
edge(node_u, node_v, std::span{condition, size});
175 virtual void do_init_program([[maybe_unused]]
bool incremental) {}
176 virtual void do_begin_step() {}
177 virtual void do_end_step([[maybe_unused]] Base base) {}
179 [[maybe_unused]]
bool choice) {}
187 [[maybe_unused]]
int bias, [[maybe_unused]]
unsigned priority,
189 virtual void do_edge([[maybe_unused]]
int node_u, [[maybe_unused]]
int node_v,
A base that maps signatures to atom bases, and captures term and theory bases.
Definition base.hh:607
The main control class for grounding and solving logic programs.
Definition control.hh:228
Observer interface to inspect the current ground program.
Definition observe.hh:15
Observer(Observer &&other)=delete
Disable move and copy operations.
void end_step(Base base)
Callback for the end of a step.
Definition observe.hh:38
void init_program(bool incremental)
Callback for the beginning of the program.
Definition observe.hh:32
virtual ~Observer()=default
The default destructor.
void assume(ProgramLiteralSpan literals)
Callback for an assumption directive.
Definition observe.hh:77
void minimize(WeightedLiteralSpan literals, Weight priority)
Callback for a minimize constraint.
Definition observe.hh:61
void heuristic(ProgramAtom atom, HeuristicType type, int bias, unsigned priority, ProgramLiteralSpan condition)
Definition observe.hh:84
auto operator=(Observer &&other) -> Observer &=delete
Disable move and copy operations.
Observer()=default
The default constructor.
void edge(int node_u, int node_v, ProgramLiteralSpan condition)
Callback for an edge statement.
Definition observe.hh:93
void project(ProgramAtomSpan atoms)
Callback for a projection directive.
Definition observe.hh:66
void begin_step()
Callback for the beginning of a step.
Definition observe.hh:35
void external(ProgramAtom atom, ExternalType type)
Callback for an external statement.
Definition observe.hh:72
void weight_rule(ProgramAtomSpan head, Weight lower, WeightedLiteralSpan body, bool choice)
Callback for a weight rule.
Definition observe.hh:53
void rule(ProgramAtomSpan head, ProgramLiteralSpan body, bool choice)
Callback for a rule.
Definition observe.hh:45
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
uint32_t clingo_atom_t
Unsigned integer type used for aspif atoms.
Definition core.h:75
int32_t clingo_literal_t
Signed integer type used for aspif and solver literals.
Definition core.h:73
int32_t clingo_weight_t
Signed integer type for weights in sum aggregates and minimize constraints.
Definition core.h:79
CLINGO_VISIBILITY_DEFAULT bool clingo_control_observe(clingo_control_t *control, clingo_observer_t const *observer, void *data, bool preprocess)
Get an observer to inspect the ground program.
int clingo_external_type_t
Corresponding type to clingo_external_type_e.
Definition shared.h:32
int clingo_heuristic_type_t
Corresponding type to clingo_heuristic_type_e.
Definition shared.h:22
@ project
Discard project statements.
@ minimize
Discard minimize statements.
@ preprocess
Whether to preprocess the program before writing.
clingo_atom_t ProgramAtom
A program atom.
Definition core.hh:387
HeuristicType
Enumeration of heuristic types.
Definition core.hh:560
std::span< ProgramAtom const > ProgramAtomSpan
A span of program atoms.
Definition core.hh:389
clingo_weight_t Weight
A weight used in sum aggregates and minimize constraints.
Definition core.hh:408
std::span< WeightedLiteral const > WeightedLiteralSpan
A span of weighted literals.
Definition core.hh:415
std::span< ProgramLiteral const > ProgramLiteralSpan
A span of program literals.
Definition core.hh:394
ExternalType
Enumeration of control modes.
Definition core.hh:552
An instance of this struct has to be registered with a solver to observe ground directives as they ar...
Definition observe.h:42
A literal with an associated weight.
Definition core.h:81