Struct nice_smile::network::Network

source ·
pub struct Network { /* private fields */ }
Expand description

A Bayesian Network.

Implementations§

source§

impl Network

source

pub fn new_uninitialized() -> Self

Create a new uninitialized network.

source

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());
source

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());
source

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.

source

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.

source

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.

source

pub fn invalidate_all_beliefs(&mut self) -> Result<()>

Invalidates values in all nodes of the Network.

source

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.

source

pub fn set_update_immediate(&mut self, immediate: bool)

Returns the update immediate flag.

For more information, refer to the Self::is_update_immediate.

source

pub fn set_bayesian_network_algorithm( &mut self, algorithm: BayesianNetworkAlgorithm, )

Sets the algorithm used for inference in Bayesian networks.

source

pub fn set_influence_diagram_algorithm( &mut self, algorithm: InfluenceDiagramAlgorithm, )

Sets the algorithm used for inference in influence diagrams.

Trait Implementations§

source§

impl Clone for Network

source§

fn clone(&self) -> Self

Clone the network.

let network1 = Network::new_uninitialized();
// TODO: add nodes to the network
let network2 = network1.clone();
assert!(network1 == network2);
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl PartialEq for Network

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Network

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.