pumpkin_solver::variables

Trait IntegerVariable

source
pub trait IntegerVariable:
    Clone
    + PredicateConstructor<Value = i32>
    + TransformableVariable<Self::AffineView> {
    type AffineView: IntegerVariable;

    // Required methods
    fn lower_bound(&self, assignment: &AssignmentsInteger) -> i32;
    fn upper_bound(&self, assignment: &AssignmentsInteger) -> i32;
    fn contains(&self, assignment: &AssignmentsInteger, value: i32) -> bool;
    fn describe_domain(&self, assignment: &AssignmentsInteger) -> Vec<Predicate>;
    fn remove(
        &self,
        assignment: &mut AssignmentsInteger,
        value: i32,
        reason: Option<ReasonRef>,
    ) -> Result<(), EmptyDomain>;
    fn set_lower_bound(
        &self,
        assignment: &mut AssignmentsInteger,
        value: i32,
        reason: Option<ReasonRef>,
    ) -> Result<(), EmptyDomain>;
    fn set_upper_bound(
        &self,
        assignment: &mut AssignmentsInteger,
        value: i32,
        reason: Option<ReasonRef>,
    ) -> Result<(), EmptyDomain>;
    fn watch_all(
        &self,
        watchers: &mut Watchers<'_>,
        events: EnumSet<IntDomainEvent>,
    );
    fn watch_all_backtrack(
        &self,
        watchers: &mut Watchers<'_>,
        events: EnumSet<IntDomainEvent>,
    );
    fn unpack_event(&self, event: OpaqueDomainEvent) -> IntDomainEvent;
}
Expand description

A trait specifying the required behaviour of an integer variable such as retrieving a lower-bound (IntegerVariable::lower_bound) or adjusting the bounds (IntegerVariable::set_lower_bound).

Required Associated Types§

Required Methods§

source

fn lower_bound(&self, assignment: &AssignmentsInteger) -> i32

Get the lower bound of the variable.

source

fn upper_bound(&self, assignment: &AssignmentsInteger) -> i32

Get the upper bound of the variable.

source

fn contains(&self, assignment: &AssignmentsInteger, value: i32) -> bool

Determine whether the value is in the domain of this variable.

source

fn describe_domain(&self, assignment: &AssignmentsInteger) -> Vec<Predicate>

Get a predicate description (bounds + holes) of the domain of this variable. N.B. can be very expensive with large domains, and very large with holey domains

This should not be used to explicitly check for holes in the domain, but only to build explanations. If views change the observed domain, they will not change this description, because it should be a description of the domain in the solver.

source

fn remove( &self, assignment: &mut AssignmentsInteger, value: i32, reason: Option<ReasonRef>, ) -> Result<(), EmptyDomain>

Remove a value from the domain of this variable.

source

fn set_lower_bound( &self, assignment: &mut AssignmentsInteger, value: i32, reason: Option<ReasonRef>, ) -> Result<(), EmptyDomain>

Tighten the lower bound of the domain of this variable.

source

fn set_upper_bound( &self, assignment: &mut AssignmentsInteger, value: i32, reason: Option<ReasonRef>, ) -> Result<(), EmptyDomain>

Tighten the upper bound of the domain of this variable.

source

fn watch_all( &self, watchers: &mut Watchers<'_>, events: EnumSet<IntDomainEvent>, )

Register a watch for this variable on the given domain events.

source

fn watch_all_backtrack( &self, watchers: &mut Watchers<'_>, events: EnumSet<IntDomainEvent>, )

source

fn unpack_event(&self, event: OpaqueDomainEvent) -> IntDomainEvent

Decode a domain event for this variable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§