Backend

Struct Backend 

Source
pub struct Backend<'a> { /* private fields */ }
Expand description

Handle to the backend to add directives in aspif format.

Implementations§

Source§

impl<'a> Backend<'a>

Source

pub fn rule( &mut self, choice: bool, head: &[Atom], body: &[SolverLiteral], ) -> Result<(), ClingoError>

Add a rule to the program.

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

pub fn weight_rule( &mut self, choice: bool, head: &[Atom], lower_bound: i32, body: &[WeightedLiteral], ) -> Result<(), ClingoError>

Add a weight rule to the program.

Attention: All weights and the lower bound must be positive.

§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
§Errors
Source

pub fn minimize( &mut self, priority: i32, literals: &[WeightedLiteral], ) -> Result<(), ClingoError>

Add a minimize constraint (or weak constraint) to the program.

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

pub fn project(&mut self, atoms: &[Atom]) -> Result<(), ClingoError>

Add a projection directive.

§Arguments
  • atoms - the atoms to project on
§Errors
Source

pub fn external( &mut self, atom: Atom, type_: ExternalType, ) -> Result<(), ClingoError>

Add an external statement.

§Arguments
  • atom - the external atom
  • type - the type of the external statement
§Errors
Source

pub fn assume(&mut self, literals: &[SolverLiteral]) -> Result<(), ClingoError>

Add an assumption directive.

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

pub fn heuristic( &mut self, atom: Atom, htype: HeuristicType, bias: i32, priority: u32, condition: &[SolverLiteral], ) -> Result<(), ClingoError>

Add an heuristic directive.

§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
§Errors
Source

pub fn acyc_edge( &mut self, node_u: i32, node_v: i32, condition: &[SolverLiteral], ) -> Result<(), ClingoError>

Add an edge directive.

§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
§Errors
Source

pub fn add_atom(&mut self, symbol: Option<Symbol>) -> Result<Atom, ClingoError>

Get a fresh atom to be used in aspif directives.

§Arguments
  • symbol - optional symbol to associate the atom with

Trait Implementations§

Source§

impl<'a> Debug for Backend<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Drop for Backend<'a>

Source§

fn drop(&mut self)

Finalize the backend after using it.

Auto Trait Implementations§

§

impl<'a> Freeze for Backend<'a>

§

impl<'a> RefUnwindSafe for Backend<'a>

§

impl<'a> Send for Backend<'a>

§

impl<'a> Sync for Backend<'a>

§

impl<'a> Unpin for Backend<'a>

§

impl<'a> !UnwindSafe for Backend<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.