Trait clingo::GroundProgramObserver
source · 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§
sourcefn init_program(&mut self, _incremental: bool) -> bool
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
sourcefn begin_step(&mut self) -> bool
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
sourcefn end_step(&mut self) -> bool
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
sourcefn rule(
&mut self,
_choice: bool,
_head: &[Atom],
_body: &[SolverLiteral]
) -> bool
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 disjunctionhead
- the head atomsbody
- the body literals
Returns whether the call was successful
sourcefn weight_rule(
&mut self,
_choice: bool,
_head: &[Atom],
_lower_bound: i32,
_body: &[WeightedLiteral]
) -> bool
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 disjunctionhead
- the head atomslower_bound
- the lower bound of the weight rulebody
- the weighted body literals
Returns whether the call was successful
sourcefn minimize(&mut self, _priority: i32, _literals: &[WeightedLiteral]) -> bool
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 constraintliterals
- the weighted literals whose sum to minimize
Returns whether the call was successful
sourcefn project(&mut self, _atoms: &[Atom]) -> bool
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
sourcefn output_atom(&mut self, _symbol: Symbol, _atom: Atom) -> bool
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 atomatom
- the aspif atom (0 for facts)
Returns whether the call was successful
sourcefn output_term(&mut self, _symbol: Symbol, _condition: &[SolverLiteral]) -> bool
fn output_term(&mut self, _symbol: Symbol, _condition: &[SolverLiteral]) -> bool
Observe shown terms passed to the solver.
Arguments
symbol
- the symbolic representation of the termcondition
- the literals of the condition
Returns whether the call was successful
sourcefn output_csp(
&mut self,
_symbol: Symbol,
_value: i32,
_condition: &[SolverLiteral]
) -> bool
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 variablevalue
- the value of the variablecondition
- the literals of the condition
Returns whether the call was successful
sourcefn external(&mut self, _atom: Atom, _type_: ExternalType) -> bool
fn external(&mut self, _atom: Atom, _type_: ExternalType) -> bool
Observe external statements passed to the solver.
Arguments
atom
- the external atometype
- the type of the external statement
Returns whether the call was successful
sourcefn assume(&mut self, _literals: &[SolverLiteral]) -> bool
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
sourcefn heuristic(
&mut self,
_atom: Atom,
_type_: HeuristicType,
_bias: i32,
_priority: u32,
_condition: &[SolverLiteral]
) -> bool
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 atomhtype
- the type of the heuristic modificationbias
- the heuristic biaspriority
- the heuristic prioritycondition
- the condition under which to apply the heuristic modification
Returns whether the call was successful
sourcefn acyc_edge(
&mut self,
_node_u: i32,
_node_v: i32,
_condition: &[SolverLiteral]
) -> bool
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 edgenode_v
- the end vertex of the edgecondition
- the condition under which the edge is part of the graph
Returns whether the call was successful
sourcefn theory_term_number(&mut self, _term_id: Id, _number: i32) -> bool
fn theory_term_number(&mut self, _term_id: Id, _number: i32) -> bool
Observe numeric theory terms.
Arguments
term_id
- the id of the termnumber
- the value of the term
Returns whether the call was successful
sourcefn theory_term_string(&mut self, _term_id: Id, _name: &str) -> bool
fn theory_term_string(&mut self, _term_id: Id, _name: &str) -> bool
Observe string theory terms.
Arguments
term_id
- the id of the termname
- the value of the term
Returns whether the call was successful
sourcefn theory_term_compound(
&mut self,
_term_id: Id,
_name_id_or_type: i32,
_arguments: &[Id]
) -> bool
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 termname_id_or_type
- the name or type of the termarguments
- the arguments of the term
Returns whether the call was successful
sourcefn theory_element(
&mut self,
_element_id: Id,
_terms: &[Id],
_condition: &[SolverLiteral]
) -> bool
fn theory_element( &mut self, _element_id: Id, _terms: &[Id], _condition: &[SolverLiteral] ) -> bool
Observe theory elements.
Arguments
element_id
- the id of the elementterms
- the term tuple of the elementcondition
- the condition of the element
Returns whether the call was successful
sourcefn theory_atom(
&mut self,
_atom_id_or_zero: Id,
_term_id: Id,
_elements: &[Id]
) -> bool
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 directivesterm_id
- the term associated with the atomelements
- the elements of the atom
Returns whether the call was successful
sourcefn 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
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 directivesterm_id
- the term associated with the atomelements
- the elements of the atomoperator_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