thinking about rules implementation...
This commit is contained in:
@@ -8,6 +8,22 @@
|
||||
//! by a key of type `K`.
|
||||
//! A constraint owns references to actual values assigned,
|
||||
//! used to perform checks.
|
||||
//!
|
||||
//!
|
||||
//! The problem is to clarify the way Constraints operate.
|
||||
//! Do they compute their status from some data on demand ?
|
||||
//! Do they keep their status updated by watching the Variables
|
||||
//! they act on ?
|
||||
//! Worse, do they have superpowers ?
|
||||
//! Could they filter on a variable domain, according to some other variable
|
||||
//! state ? This would mean that constraints won't judge a result, but guide
|
||||
//! the solving process to avoid erroring paths, like a constraint-driven
|
||||
//! solving. This would be powerfull but maybe far too complex...
|
||||
//!
|
||||
//! On the other hand, we can implement a simple Observer pattern, with strong
|
||||
//! coupling to [`Problem`](crate::solver::Problem).
|
||||
//! Because of this, we can safely play with private fields of Problem, and in
|
||||
//! return, provide a public api to build specific constraints.
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum Status {
|
||||
@@ -93,7 +109,7 @@ mod tests {
|
||||
use super::Constraint;
|
||||
|
||||
let domain = Domain::new(vec![1, 2, 3]);
|
||||
let mut problem = Problem::build()
|
||||
let problem = Problem::build()
|
||||
.add_variable("Left", domain.all(), None)
|
||||
.add_variable("Right", domain.all(), None)
|
||||
.add_constraint(Constraint::new(vec![&"Left", &"Right"]))
|
||||
|
||||
Reference in New Issue
Block a user