pub trait GroundProgramObserver {
Show 20 methods // Provided methods fn init_program(&mut self, _incremental: bool) -> bool { ... } fn begin_step(&mut self) -> bool { ... } fn end_step(&mut self) -> bool { ... } fn rule( &mut self, _choice: bool, _head: &[Atom], _body: &[SolverLiteral] ) -> bool { ... } fn weight_rule( &mut self, _choice: bool, _head: &[Atom], _lower_bound: i32, _body: &[WeightedLiteral] ) -> bool { ... } fn minimize( &mut self, _priority: i32, _literals: &[WeightedLiteral] ) -> bool { ... } fn project(&mut self, _atoms: &[Atom]) -> bool { ... } fn output_atom(&mut self, _symbol: Symbol, _atom: Atom) -> bool { ... } fn output_term( &mut self, _symbol: Symbol, _condition: &[SolverLiteral] ) -> bool { ... } fn output_csp( &mut self, _symbol: Symbol, _value: i32, _condition: &[SolverLiteral] ) -> bool { ... } fn external(&mut self, _atom: Atom, _type_: ExternalType) -> bool { ... } fn assume(&mut self, _literals: &[SolverLiteral]) -> bool { ... } fn heuristic( &mut self, _atom: Atom, _type_: HeuristicType, _bias: i32, _priority: u32, _condition: &[SolverLiteral] ) -> bool { ... } fn acyc_edge( &mut self, _node_u: i32, _node_v: i32, _condition: &[SolverLiteral] ) -> bool { ... } fn theory_term_number(&mut self, _term_id: Id, _number: i32) -> bool { ... } fn theory_term_string(&mut self, _term_id: Id, _name: &str) -> bool { ... } fn theory_term_compound( &mut self, _term_id: Id, _name_id_or_type: i32, _arguments: &[Id] ) -> bool { ... } fn theory_element( &mut self, _element_id: Id, _terms: &[Id], _condition: &[SolverLiteral] ) -> bool { ... } fn theory_atom( &mut self, _atom_id_or_zero: Id, _term_id: Id, _elements: &[Id] ) -> bool { ... } fn theory_atom_with_guard( &mut self, _atom_id_or_zero: Id, _term_id: Id, _elements: &[Id], _operator_id: Id, _right_hand_side_id: Id ) -> bool { ... }
}
Expand description

An instance of this struct has to be registered with a solver to observe ground directives as they are passed to the solver.

Note: This interface is closely modeled after the aspif format. For more information please refer to the specification of the aspif format.

Not all callbacks have to be implemented and can be set to NULL if not needed. If one of the callbacks in the struct fails, grounding is stopped. If a non-recoverable clingo API call fails, a callback must return false. Otherwise ::clingo_error_unknown should be set and false returned.

Provided Methods§

source

fn init_program(&mut self, _incremental: bool) -> bool

Called once in the beginning.

If the incremental flag is true, there can be multiple calls to Control::solve().

Arguments
  • incremental - whether the program is incremental

Returns whether the call was successful

source

fn begin_step(&mut self) -> bool

Marks the beginning of a block of directives passed to the solver.

See: GroundProgramObserver::end_step()

Returns whether the call was successful

source

fn end_step(&mut self) -> bool

Marks the end of a block of directives passed to the solver.

This function is called before solving starts.

See: GroundProgramObserver::begin_step()

Returns whether the call was successful

source

fn rule( &mut self, _choice: bool, _head: &[Atom], _body: &[SolverLiteral] ) -> bool

Observe rules passed to the solver.

Arguments
  • choice - determines if the head is a choice or a disjunction
  • head - the head atoms
  • body - the body literals

Returns whether the call was successful

source

fn weight_rule( &mut self, _choice: bool, _head: &[Atom], _lower_bound: i32, _body: &[WeightedLiteral] ) -> bool

Observe weight rules passed to the solver.

Arguments
  • choice - determines if the head is a choice or a disjunction
  • head - the head atoms
  • lower_bound - the lower bound of the weight rule
  • body - the weighted body literals

Returns whether the call was successful

source

fn minimize(&mut self, _priority: i32, _literals: &[WeightedLiteral]) -> bool

Observe minimize constraints (or weak constraints) passed to the solver.

Arguments
  • priority - the priority of the constraint
  • literals - the weighted literals whose sum to minimize

Returns whether the call was successful

source

fn project(&mut self, _atoms: &[Atom]) -> bool

Observe projection directives passed to the solver.

Arguments
  • atoms - the atoms to project on

Returns whether the call was successful

source

fn output_atom(&mut self, _symbol: Symbol, _atom: Atom) -> bool

Observe shown atoms passed to the solver.

Note: Facts do not have an associated aspif atom. The value of the atom is set to zero.

Arguments
  • symbol - the symbolic representation of the atom
  • atom - the aspif atom (0 for facts)

Returns whether the call was successful

source

fn output_term(&mut self, _symbol: Symbol, _condition: &[SolverLiteral]) -> bool

Observe shown terms passed to the solver.

Arguments
  • symbol - the symbolic representation of the term
  • condition - the literals of the condition

Returns whether the call was successful

source

fn output_csp( &mut self, _symbol: Symbol, _value: i32, _condition: &[SolverLiteral] ) -> bool

Observe shown csp variables passed to the solver.

Arguments
  • symbol - the symbolic representation of the variable
  • value - the value of the variable
  • condition - the literals of the condition

Returns whether the call was successful

source

fn external(&mut self, _atom: Atom, _type_: ExternalType) -> bool

Observe external statements passed to the solver.

Arguments
  • atom - the external atom
  • etype - the type of the external statement

Returns whether the call was successful

source

fn assume(&mut self, _literals: &[SolverLiteral]) -> bool

Observe assumption directives passed to the solver.

Arguments
  • literals - the literals to assume (positive literals are true and negative literals false for the next solve call)

Returns whether the call was successful

source

fn heuristic( &mut self, _atom: Atom, _type_: HeuristicType, _bias: i32, _priority: u32, _condition: &[SolverLiteral] ) -> bool

Observe heuristic directives passed to the solver.

Arguments
  • atom - the target atom
  • htype - the type of the heuristic modification
  • bias - the heuristic bias
  • priority - the heuristic priority
  • condition - the condition under which to apply the heuristic modification

Returns whether the call was successful

source

fn acyc_edge( &mut self, _node_u: i32, _node_v: i32, _condition: &[SolverLiteral] ) -> bool

Observe edge directives passed to the solver.

Arguments
  • node_u - the start vertex of the edge
  • node_v - the end vertex of the edge
  • condition - the condition under which the edge is part of the graph

Returns whether the call was successful

source

fn theory_term_number(&mut self, _term_id: Id, _number: i32) -> bool

Observe numeric theory terms.

Arguments
  • term_id - the id of the term
  • number - the value of the term

Returns whether the call was successful

source

fn theory_term_string(&mut self, _term_id: Id, _name: &str) -> bool

Observe string theory terms.

Arguments
  • term_id - the id of the term
  • name - the value of the term

Returns whether the call was successful

source

fn theory_term_compound( &mut self, _term_id: Id, _name_id_or_type: i32, _arguments: &[Id] ) -> bool

Observe compound theory terms.

The name_id_or_type gives the type of the compound term:

  • if it is -1, then it is a tuple
  • if it is -2, then it is a set
  • if it is -3, then it is a list
  • otherwise, it is a function and name_id_or_type refers to the id of the name (in form of a string term)
Arguments
  • term_id - the id of the term
  • name_id_or_type - the name or type of the term
  • arguments - the arguments of the term

Returns whether the call was successful

source

fn theory_element( &mut self, _element_id: Id, _terms: &[Id], _condition: &[SolverLiteral] ) -> bool

Observe theory elements.

Arguments
  • element_id - the id of the element
  • terms - the term tuple of the element
  • condition - the condition of the element

Returns whether the call was successful

source

fn theory_atom( &mut self, _atom_id_or_zero: Id, _term_id: Id, _elements: &[Id] ) -> bool

Observe theory atoms without guard.

Arguments
  • atom_id_or_zero - the id of the atom or zero for directives
  • term_id - the term associated with the atom
  • elements - the elements of the atom

Returns whether the call was successful

source

fn theory_atom_with_guard( &mut self, _atom_id_or_zero: Id, _term_id: Id, _elements: &[Id], _operator_id: Id, _right_hand_side_id: Id ) -> bool

Observe theory atoms with guard.

Arguments
  • atom_id_or_zero - the id of the atom or zero for directives
  • term_id - the term associated with the atom
  • elements - the elements of the atom
  • operator_id - the id of the operator (a string term)
  • right_hand_side_id - the id of the term on the right hand side of the atom

Returns whether the call was successful

Implementors§