diff --git a/rust/src/common/interface.rs b/rust/src/common/interface.rs index 961f316..877a15a 100644 --- a/rust/src/common/interface.rs +++ b/rust/src/common/interface.rs @@ -17,13 +17,15 @@ pub trait PropositionProbability { } pub trait LogicalModel { - fn initialize_weight(implication:&Implication) -> Result<(), Box>; + fn initialize_connection(&mut self, implication:&Implication) -> Result<(), Box>; fn train( + &mut self, storage: &mut Storage, proposition: &Proposition, ) -> Result>; fn predict( + &self, storage: &mut Storage, evidence: &dyn PropositionProbability, proposition: &Proposition, diff --git a/rust/src/common/run.rs b/rust/src/common/run.rs index b66dec0..f7cd072 100644 --- a/rust/src/common/run.rs +++ b/rust/src/common/run.rs @@ -4,15 +4,17 @@ use redis::Client; use crate::model::{storage::Storage, inference::marginalized_inference_probability}; use crate::model::choose::compute_backlinks; -use super::interface::ScenarioMaker; +use super::interface::{ScenarioMaker, LogicalModel}; - -pub fn do_training(storage: &mut Storage) -> Result<(), Box> { +fn create_model(model_name:&String) -> Result, Box> { + todo!() +} +pub fn do_training(model:Box, storage: &Storage) -> Result<(), Box> { trace!("do_training - Getting all implications"); let implications = storage.get_all_implications()?; for implication in implications { trace!("do_training - Processing implication: {:?}", implication); - initialize_weights(storage.get_redis_connection(), &implication)?; + model.initialize_connection( &implication)?; } trace!("do_training - Getting all propositions"); @@ -58,6 +60,8 @@ pub fn train_and_test(scenario_maker:&dyn ScenarioMaker) -> Result<(), Box