pub struct BackwardEngine { /* private fields */ }Expand description
Backward chaining engine for goal-driven reasoning
Implementations§
Source§impl BackwardEngine
impl BackwardEngine
Sourcepub fn new(kb: KnowledgeBase) -> Self
pub fn new(kb: KnowledgeBase) -> Self
Create a new backward chaining engine
Sourcepub fn with_config(kb: KnowledgeBase, config: BackwardConfig) -> Self
pub fn with_config(kb: KnowledgeBase, config: BackwardConfig) -> Self
Create with custom configuration
Sourcepub fn set_config(&mut self, config: BackwardConfig)
pub fn set_config(&mut self, config: BackwardConfig)
Update configuration
Sourcepub fn query_with_rete_engine(
&mut self,
query_str: &str,
facts: &mut Facts,
rete_engine: Option<Arc<Mutex<IncrementalEngine>>>,
) -> Result<QueryResult>
pub fn query_with_rete_engine( &mut self, query_str: &str, facts: &mut Facts, rete_engine: Option<Arc<Mutex<IncrementalEngine>>>, ) -> Result<QueryResult>
Query with optional RETE IncrementalEngine for TMS integration
Sourcepub fn explain_why(
&mut self,
query_str: &str,
facts: &mut Facts,
) -> Result<String>
pub fn explain_why( &mut self, query_str: &str, facts: &mut Facts, ) -> Result<String>
Explain why a goal was proven (or not)
Sourcepub fn config(&self) -> &BackwardConfig
pub fn config(&self) -> &BackwardConfig
Get the configuration
Sourcepub fn knowledge_base(&self) -> &KnowledgeBase
pub fn knowledge_base(&self) -> &KnowledgeBase
Get the knowledge base
Sourcepub fn index_stats(&self) -> IndexStats
pub fn index_stats(&self) -> IndexStats
Get conclusion index statistics
Sourcepub fn rebuild_index(&mut self)
pub fn rebuild_index(&mut self)
Rebuild the conclusion index (call after modifying knowledge base)
Sourcepub fn query_aggregate(
&mut self,
query: &str,
facts: &mut Facts,
) -> Result<Value>
pub fn query_aggregate( &mut self, query: &str, facts: &mut Facts, ) -> Result<Value>
Query with aggregation functions
Supports: count, sum, avg, min, max, first, last
§Example
ⓘ
// Count all employees
let count = engine.query_aggregate(
"count(?x) WHERE employee(?x)",
&mut facts
)?;
// Sum of salaries over 50000
let total = engine.query_aggregate(
"sum(?salary) WHERE salary(?name, ?salary) AND ?salary > 50000",
&mut facts
)?;
// Average price
let avg_price = engine.query_aggregate(
"avg(?price) WHERE product(?name, ?price)",
&mut facts
)?;Auto Trait Implementations§
impl Freeze for BackwardEngine
impl RefUnwindSafe for BackwardEngine
impl Send for BackwardEngine
impl Sync for BackwardEngine
impl Unpin for BackwardEngine
impl UnwindSafe for BackwardEngine
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
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>
Converts
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>
Converts
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 more