-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78c5f7f
commit d98ffe8
Showing
3 changed files
with
32 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::{utils::function_pointer::FnType, model::Network, updates::observations::observation_update}; | ||
|
||
/// Single time slice belief propagation. | ||
/// | ||
/// # Arguments | ||
/// * `observations` - A vector of values, each value is one new observation associated | ||
/// with one node. | ||
pub fn belief_propagation(network: &mut Network, observations_set: Vec<f64>, predictions: & Vec<(usize, FnType)>, updates: & Vec<(usize, FnType)>) { | ||
|
||
// 1. prediction steps | ||
for (idx, step) in predictions.iter() { | ||
step(network, *idx); | ||
} | ||
|
||
// 2. observation steps | ||
for (i, observations) in observations_set.iter().enumerate() { | ||
let idx = network.inputs[i]; | ||
observation_update(network, idx, *observations); | ||
} | ||
|
||
// 3. update steps | ||
for (idx, step) in updates.iter() { | ||
step(network, *idx); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod set_sequence; | ||
pub mod function_pointer; | ||
pub mod function_pointer; | ||
pub mod beliefs_propagation; |