Assignment

Struct Assignment 

Source
pub struct Assignment(/* private fields */);
Expand description

Represents a (partial) assignment of a particular solver.

An assignment assigns truth values to a set of literals. A literal is assigned to either true or false, or is unassigned (Assignment::truth_value()). Furthermore, each assigned literal is associated with a decision level (Assignment::level()). There is exactly one decision literal (Assignment::decision()) for each decision level greater than zero. Assignments to all other literals on the same level are consequences implied by the current and possibly previous decisions. Assignments on level zero are immediate consequences of the current program. Decision levels are consecutive numbers starting with zero up to and including the current decision level (Assignment::decision_level()).

Implementations§

Source§

impl Assignment

Source

pub fn decision_level(&self) -> u32

Get the current decision level.

Source

pub fn root_level(&self) -> u32

Get the current root level.

Decisions levels smaller or equal to the root level are not backtracked during solving.

Source

pub fn has_conflict(&self) -> bool

Check whether the given assignment is conflicting.

Source

pub fn has_literal(&self, literal: SolverLiteral) -> bool

Check whether the given literal is part of a (partial) assignment.

§Arguments
  • literal - the literal
Source

pub fn level(&self, literal: SolverLiteral) -> Result<u32, ClingoError>

Determine the decision level of a given literal.

§Arguments
  • literal - the literal

Returns the decision level of the given literal

Source

pub fn decision(&self, level: u32) -> Result<SolverLiteral, ClingoError>

Determine the decision literal given a decision level.

§Arguments
  • level - the level

Returns the decision literal for the given decision level

Source

pub fn is_fixed(&self, literal: SolverLiteral) -> Result<bool, ClingoError>

Check if a literal has a fixed truth value.

§Arguments
  • literal - the literal

Returns whether the literal is fixed

Source

pub fn is_true(&self, literal: SolverLiteral) -> Result<bool, ClingoError>

Check if a literal is true.

§Arguments
Source

pub fn is_false(&self, literal: SolverLiteral) -> Result<bool, ClingoError>

Check if a literal has a fixed truth value.

§Arguments
  • literal - the literal

Returns whether the literal is false (see Assignment::truth_value()

Source

pub fn truth_value( &self, literal: SolverLiteral, ) -> Result<TruthValue, ClingoError>

Determine the truth value of a given literal.

§Arguments
  • literal - the literal
  • value - the resulting truth value

Returns whether the call was successful

Source

pub fn size(&self) -> usize

The number of (positive) literals in the assignment.

Source

pub fn at(&self, offset: usize) -> Result<SolverLiteral, ClingoError>

The (positive) literal at the given offset in the assignment.

§Arguments
  • offset - the offset of the literal

Returns the literal

Source

pub fn is_total(&self) -> bool

Check if the assignmen is total, i.e. there are no free literal.

Source

pub fn trail_size(&self) -> Result<u32, ClingoError>

Returns the number of literals in the trail, i.e., the number of assigned literals.

Source

pub fn trail_begin(&self, level: u32) -> Result<u32, ClingoError>

Returns the offset of the decision literal with the given decision level in the trail.

**Note:**SolverLiterals in the trail are ordered by decision levels, where the first literal with a larger level than the previous literals is a decision; the following literals with same level are implied by this decision literal. Each decision level up to and including the current decision level has a valid offset in the trail.

§Arguments
  • level - the decision level

Returns the offset of the decision literal

Source

pub fn trail_end(&self, level: u32) -> Result<u32, ClingoError>

Returns the offset following the last literal with the given decision level.

Note: This function is the counter part to clingo_assignment_trail_begin().

§Arguments
  • level - the decision level

Returns the offset

Source

pub fn trail_at(&self, offset: u32) -> Result<SolverLiteral, ClingoError>

Returns the literal at the given position in the trail.

§Arguments
  • offset - the offset of the literal

Returns the literal

Trait Implementations§

Source§

impl Debug for Assignment

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.