pub struct ConstraintBuilder<S: Score> {
pub factory: Rc<RefCell<ConstraintFactory<S>>>,
pub weights: Rc<RefCell<ConstraintWeights>>,
pub _phantom: PhantomData<S>,
}Expand description
High-level builder for constraint satisfaction problems.
Fields§
§factory: Rc<RefCell<ConstraintFactory<S>>>§weights: Rc<RefCell<ConstraintWeights>>§_phantom: PhantomData<S>Implementations§
Source§impl<S: Score + 'static> ConstraintBuilder<S>
impl<S: Score + 'static> ConstraintBuilder<S>
pub fn new() -> Self
pub fn with_limits(limits: ResourceLimits) -> Self
Sourcepub fn for_each<T: GreynetFact + 'static>(&self) -> Stream<Arity1, S>
pub fn for_each<T: GreynetFact + 'static>(&self) -> Stream<Arity1, S>
Starts a stream definition for any fact type, not tied to a specific constraint.
Sourcepub fn add_constraint(
&mut self,
id: &str,
weight: f64,
) -> ConstraintStreamBuilder<'_, S>
pub fn add_constraint( &mut self, id: &str, weight: f64, ) -> ConstraintStreamBuilder<'_, S>
Starts the definition of a new constraint with a fluent API. This is the recommended way to define constraints.
Sourcepub fn constraint(
self,
id: &str,
weight: f64,
recipe_fn: impl Fn(ConstraintId) -> ConstraintRecipe<S>,
) -> Self
pub fn constraint( self, id: &str, weight: f64, recipe_fn: impl Fn(ConstraintId) -> ConstraintRecipe<S>, ) -> Self
Defines a constraint using a closure. This method is kept for backward
compatibility but add_constraint is preferred.
The closure now receives the ConstraintId to pass to penalize().
Sourcepub fn bulk_constraints(
self,
constraints: Vec<(&str, f64, Box<dyn Fn(ConstraintId) -> ConstraintRecipe<S>>)>,
) -> Self
pub fn bulk_constraints( self, constraints: Vec<(&str, f64, Box<dyn Fn(ConstraintId) -> ConstraintRecipe<S>>)>, ) -> Self
Defines a batch of constraints using closures.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for ConstraintBuilder<S>
impl<S> !RefUnwindSafe for ConstraintBuilder<S>
impl<S> !Send for ConstraintBuilder<S>
impl<S> !Sync for ConstraintBuilder<S>
impl<S> Unpin for ConstraintBuilder<S>where
S: Unpin,
impl<S> !UnwindSafe for ConstraintBuilder<S>
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
Mutably borrows from an owned value. Read more