Struct nice_smile::network::Network
source · pub struct Network { /* private fields */ }Expand description
A Bayesian Network.
Implementations§
source§impl Network
impl Network
sourcepub fn new_uninitialized() -> Self
pub fn new_uninitialized() -> Self
Create a new uninitialized network.
sourcepub fn from_xdsl_string(xdsl_string: impl AsRef<str>) -> Result<Self>
pub fn from_xdsl_string(xdsl_string: impl AsRef<str>) -> Result<Self>
Create a new network from an XDSL string.
Example usage:
let network = Network::from_xdsl_string(&xdsl)?;
assert_ne!(xdsl, "".to_string());sourcepub fn to_xdsl_string(&mut self) -> Result<String>
pub fn to_xdsl_string(&mut self) -> Result<String>
Export the network to an XDSL string.
Example usage:
let mut network = Network::new_uninitialized();
let xdsl = network.to_xdsl_string()?;
assert_ne!(xdsl, "".to_string());sourcepub fn read_from_file(file_path: impl AsRef<Path>) -> Result<Network>
pub fn read_from_file(file_path: impl AsRef<Path>) -> Result<Network>
Read a network from a file.
The file type is determined automaticaly by the file_path extension. For the supported file types list, refer to the smile::ffi::DSL_network::ReadFile.
sourcepub fn write_to_file(&mut self, file_path: impl AsRef<Path>) -> Result<()>
pub fn write_to_file(&mut self, file_path: impl AsRef<Path>) -> Result<()>
Write the network to a file.
The file type is determined automaticaly by the file_path extension. For the supported file types list, refer to the smile::ffi::DSL_network::ReadFile.
sourcepub fn update_beliefs(&mut self) -> Result<()>
pub fn update_beliefs(&mut self) -> Result<()>
Executes inference algorithm to update node values. Returns DSL_OKAY on success, or a negative error code on failure.
sourcepub fn invalidate_all_beliefs(&mut self) -> Result<()>
pub fn invalidate_all_beliefs(&mut self) -> Result<()>
Invalidates values in all nodes of the Network.
sourcepub fn is_update_immediate(&self) -> bool
pub fn is_update_immediate(&self) -> bool
Sets the immediate update flag.
If the flag is set to true, Self::update_beliefs will be called after changes in the network structure, parameters or evidence.
sourcepub fn set_update_immediate(&mut self, immediate: bool)
pub fn set_update_immediate(&mut self, immediate: bool)
Returns the update immediate flag.
For more information, refer to the Self::is_update_immediate.
sourcepub fn set_bayesian_network_algorithm(
&mut self,
algorithm: BayesianNetworkAlgorithm,
)
pub fn set_bayesian_network_algorithm( &mut self, algorithm: BayesianNetworkAlgorithm, )
Sets the algorithm used for inference in Bayesian networks.
sourcepub fn set_influence_diagram_algorithm(
&mut self,
algorithm: InfluenceDiagramAlgorithm,
)
pub fn set_influence_diagram_algorithm( &mut self, algorithm: InfluenceDiagramAlgorithm, )
Sets the algorithm used for inference in influence diagrams.