pub struct TreeReweightedBP {
pub max_iterations: usize,
pub tolerance: f64,
pub edge_weights: HashMap<(String, String), f64>,
}Expand description
Tree-reweighted belief propagation (TRW-BP).
Uses a convex combination of spanning trees to provide an upper bound on the log partition function. More robust than standard BP for loopy graphs.
Messages are reweighted by edge appearance probabilities ρ_e ∈ [0,1].
Fields§
§max_iterations: usizeMaximum iterations
tolerance: f64Convergence tolerance
edge_weights: HashMap<(String, String), f64>Edge appearance probabilities (default: uniform)
Implementations§
Source§impl TreeReweightedBP
impl TreeReweightedBP
Sourcepub fn set_edge_weight(&mut self, var: String, factor: String, weight: f64)
pub fn set_edge_weight(&mut self, var: String, factor: String, weight: f64)
Set edge appearance probability for a variable-factor edge.
Sourcepub fn initialize_uniform_weights(&mut self, graph: &FactorGraph)
pub fn initialize_uniform_weights(&mut self, graph: &FactorGraph)
Initialize uniform edge weights for all edges in graph.
Sourcepub fn run(
&mut self,
graph: &FactorGraph,
) -> Result<HashMap<String, ArrayD<f64>>>
pub fn run( &mut self, graph: &FactorGraph, ) -> Result<HashMap<String, ArrayD<f64>>>
Run tree-reweighted belief propagation.
Returns variable beliefs (marginals) and an upper bound on log Z.
Sourcepub fn compute_log_partition_upper_bound(
&self,
_graph: &FactorGraph,
_beliefs: &HashMap<String, ArrayD<f64>>,
) -> Result<f64>
pub fn compute_log_partition_upper_bound( &self, _graph: &FactorGraph, _beliefs: &HashMap<String, ArrayD<f64>>, ) -> Result<f64>
Compute upper bound on log partition function.
log Z ≤ log Z_TRW = Σ_i ρ_i log Z_i
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TreeReweightedBP
impl RefUnwindSafe for TreeReweightedBP
impl Send for TreeReweightedBP
impl Sync for TreeReweightedBP
impl Unpin for TreeReweightedBP
impl UnwindSafe for TreeReweightedBP
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.