pub struct PropagatorConstructorContext<'a> { /* private fields */ }Expand description
PropagatorConstructorContext is used when Propagators are initialised after creation.
It represents a communication point between the [Solver] and the Propagator.
Propagators use the PropagatorConstructorContext to register to domain changes
of variables and to retrieve the current bounds of variables.
Implementations§
Source§impl PropagatorConstructorContext<'_>
impl PropagatorConstructorContext<'_>
Sourcepub fn will_not_register_any_events(&mut self)
pub fn will_not_register_any_events(&mut self)
Indicate that the constructor is deliberately not registering the propagator to be enqueued at any time.
If this is called and later a registration happens, then the registration will still go through. Calling this function only prevents the crash if no registration happens.
Sourcepub fn register(
&mut self,
var: impl IntegerVariable,
domain_events: DomainEvents,
local_id: LocalId,
)
pub fn register( &mut self, var: impl IntegerVariable, domain_events: DomainEvents, local_id: LocalId, )
Subscribes the propagator to the given DomainEvents.
The domain events determine when Propagator::notify() will be called on the propagator.
The LocalId is internal information related to the propagator,
which is used when calling Propagator::notify() to identify the variable.
Each variable must have a unique LocalId. Most often this would be its index of the
variable in the internal array of variables.
Duplicate registrations are ignored.
Sourcepub fn register_predicate(&mut self, predicate: Predicate) -> PredicateId
pub fn register_predicate(&mut self, predicate: Predicate) -> PredicateId
Register the propagator to be enqueued when the given Predicate becomes true.
Returns the PredicateId used by the solver to track the predicate.
Sourcepub fn register_backtrack<Var>(
&mut self,
var: Var,
domain_events: DomainEvents,
local_id: LocalId,
)where
Var: IntegerVariable,
pub fn register_backtrack<Var>(
&mut self,
var: Var,
domain_events: DomainEvents,
local_id: LocalId,
)where
Var: IntegerVariable,
Subscribes the propagator to the given DomainEvents when they are undone during
backtracking. This method is complementary to PropagatorConstructorContext::register,
the LocalIds provided to both of these method should be the same for the same variable.
The domain events determine when Propagator::notify_backtrack() will be called on the
propagator. The LocalId is internal information related to the propagator,
which is used when calling Propagator::notify_backtrack() to identify the variable.
Each variable must have a unique LocalId. Most often this would be its index of the
variable in the internal array of variables.
Note that the LocalId is used to differentiate between [DomainId]s and
[AffineView]s.
Sourcepub fn reborrow(&mut self) -> PropagatorConstructorContext<'_>
pub fn reborrow(&mut self) -> PropagatorConstructorContext<'_>
Reborrow the current context to a new value with a shorter lifetime. Should be used when
passing Self to another function that takes ownership, but the value is still needed
afterwards.
Sourcepub fn add_inference_checker(
&mut self,
inference_code: InferenceCode,
checker: Box<dyn InferenceChecker<Predicate>>,
)
pub fn add_inference_checker( &mut self, inference_code: InferenceCode, checker: Box<dyn InferenceChecker<Predicate>>, )
Add an inference checker for inferences produced by the propagator.
If the check-propagations feature is not enabled, adding an InferenceChecker will not
do anything.
Trait Implementations§
Source§impl<'a> Debug for PropagatorConstructorContext<'a>
impl<'a> Debug for PropagatorConstructorContext<'a>
Auto Trait Implementations§
impl<'a> Freeze for PropagatorConstructorContext<'a>
impl<'a> !RefUnwindSafe for PropagatorConstructorContext<'a>
impl<'a> !Send for PropagatorConstructorContext<'a>
impl<'a> !Sync for PropagatorConstructorContext<'a>
impl<'a> Unpin for PropagatorConstructorContext<'a>
impl<'a> !UnwindSafe for PropagatorConstructorContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ProblemSolution for Twhere
T: HasAssignments,
impl<T> ProblemSolution for Twhere
T: HasAssignments,
Source§fn num_domains(&self) -> usize
fn num_domains(&self) -> usize
Returns the number of defined DomainIds.
fn get_integer_value<Var>(&self, var: Var) -> i32where
Var: IntegerVariable,
fn get_literal_value(&self, literal: Literal) -> bool
Source§impl<T> ReadDomains for Twhere
T: HasAssignments,
impl<T> ReadDomains for Twhere
T: HasAssignments,
Source§fn evaluate_predicate(&self, predicate: Predicate) -> Option<bool>
fn evaluate_predicate(&self, predicate: Predicate) -> Option<bool>
Predicate is assigned (either true or false) or is
currently unassigned.Source§fn evaluate_literal(&self, literal: Literal) -> Option<bool>
fn evaluate_literal(&self, literal: Literal) -> Option<bool>
Literal is assigned (either true or false) or is
currently unassigned.Source§fn get_holes_at_current_checkpoint<Var>(
&self,
var: &Var,
) -> impl Iterator<Item = i32>where
Var: IntegerVariable,
fn get_holes_at_current_checkpoint<Var>(
&self,
var: &Var,
) -> impl Iterator<Item = i32>where
Var: IntegerVariable,
Source§fn get_holes<Var>(&self, var: &Var) -> impl Iterator<Item = i32>where
Var: IntegerVariable,
fn get_holes<Var>(&self, var: &Var) -> impl Iterator<Item = i32>where
Var: IntegerVariable,
var (including ones which were
created at previous decision levels).Source§fn is_fixed<Var>(&self, var: &Var) -> boolwhere
Var: IntegerVariable,
fn is_fixed<Var>(&self, var: &Var) -> boolwhere
Var: IntegerVariable,
true if the domain of the given variable is singleton (i.e., the variable is
fixed).Source§fn lower_bound<Var>(&self, var: &Var) -> i32where
Var: IntegerVariable,
fn lower_bound<Var>(&self, var: &Var) -> i32where
Var: IntegerVariable,
var.Source§fn lower_bound_at_trail_position<Var>(
&self,
var: &Var,
trail_position: usize,
) -> i32where
Var: IntegerVariable,
fn lower_bound_at_trail_position<Var>(
&self,
var: &Var,
trail_position: usize,
) -> i32where
Var: IntegerVariable,
Source§fn upper_bound<Var>(&self, var: &Var) -> i32where
Var: IntegerVariable,
fn upper_bound<Var>(&self, var: &Var) -> i32where
Var: IntegerVariable,
var.Source§fn upper_bound_at_trail_position<Var>(
&self,
var: &Var,
trail_position: usize,
) -> i32where
Var: IntegerVariable,
fn upper_bound_at_trail_position<Var>(
&self,
var: &Var,
trail_position: usize,
) -> i32where
Var: IntegerVariable,
Source§fn contains<Var>(&self, var: &Var, value: i32) -> boolwhere
Var: IntegerVariable,
fn contains<Var>(&self, var: &Var, value: i32) -> boolwhere
Var: IntegerVariable,
value is in the domain of var.Source§fn contains_at_trail_position<Var>(
&self,
var: &Var,
value: i32,
trail_position: usize,
) -> boolwhere
Var: IntegerVariable,
fn contains_at_trail_position<Var>(
&self,
var: &Var,
value: i32,
trail_position: usize,
) -> boolwhere
Var: IntegerVariable,
Source§fn iterate_domain<Var>(&self, var: &Var) -> impl Iterator<Item = i32>where
Var: IntegerVariable,
fn iterate_domain<Var>(&self, var: &Var) -> impl Iterator<Item = i32>where
Var: IntegerVariable,
Iterator over the values in the domain of the provided var (including the
lower-bound and upper-bound values).Source§fn is_decision_predicate(&self, predicate: Predicate) -> bool
fn is_decision_predicate(&self, predicate: Predicate) -> bool
Source§fn is_initial_bound(&self, predicate: Predicate) -> bool
fn is_initial_bound(&self, predicate: Predicate) -> bool
Predicate is an initial bound of its domain.Source§fn read_trailed_integer(&self, trailed_integer: TrailedInteger) -> i64
fn read_trailed_integer(&self, trailed_integer: TrailedInteger) -> i64
TrailedInteger.Source§fn new_trailed_integer(&mut self, initial_value: i64) -> TrailedInteger
fn new_trailed_integer(&mut self, initial_value: i64) -> TrailedInteger
TrailedInteger assigned to the provided initial_value.Source§fn write_trailed_integer(&mut self, trailed_integer: TrailedInteger, value: i64)
fn write_trailed_integer(&mut self, trailed_integer: TrailedInteger, value: i64)
TrailedInteger to the provided value.Source§fn get_checkpoint(&self) -> usize
fn get_checkpoint(&self) -> usize
Source§fn initial_lower_bound(&self, var: DomainId) -> i32
fn initial_lower_bound(&self, var: DomainId) -> i32
var at the time of its creation.Source§fn initial_upper_bound(&self, var: DomainId) -> i32
fn initial_upper_bound(&self, var: DomainId) -> i32
var at the time of its creation.Source§fn initial_holes(&self, var: DomainId) -> Vec<i32>
fn initial_holes(&self, var: DomainId) -> Vec<i32>
var.