The constraints module implements a very basic system for checking and solving constraints.
Examples
use ai_kit::core::Bindings;
use ai_kit::constraints::{Constraint, Number, NumericalConstraint, SolveResult};
let constraints = vec![
Constraint::Numerical(NumericalConstraint::Set{
variable: "x".to_string(),
constant: 1.0,
}),
Constraint::Numerical(NumericalConstraint::Set{
variable: "sum".to_string(),
constant: 3.0,
}),
Constraint::Numerical(NumericalConstraint::Sum{
first: "x".to_string(),
second: "y".to_string(),
third: "sum".to_string()
}),
];
let result : SolveResult<Number> = Constraint::solve_many(
constraints.iter().collect(),
&Bindings::new(),
);
let expected_inferred_value = Number { value: 2.0 };
if let SolveResult::Success(bindings) = result {
assert_eq!(
bindings.get_binding(&"y".to_string()).unwrap(),
expected_inferred_value
);
}