Class Network

  • All Implemented Interfaces:
    Cloneable

    public final class Network
    extends Object
    implements Cloneable
    Represents a Bayesian Network, or a Dynamic Bayesian Network. To perform inference with a network see the com.bayesserver.inference namespace. A Bayesian network consists of nodes which contain one or more variables. Each node can be connected with a directed link (A link in a Dynamic Bayesian Network can have an associated order which links nodes in different time slices).

    Each node in a Bayesian network must have a distribution specified over its own variables conditional on its parents variables. For example if a network contains nodes A and B each with a single variable of the same name, and A is a parent of B, then the distribution at A equals P(A), since A has no parents, and the distribution at B equals P(B|A).

    Once the nodes, links, and distributions in a Bayesian network have been specified, one or more inference engines can be created based on the network, to perform probabilistic inference. See Inference.

    See Also:
    Node, Link
    • Constructor Detail

      • Network

        public Network()
        Initializes a new instance of the Network class.
      • Network

        public Network​(String name)
        Initializes a new instance of the Network class with the specified [name].
        Parameters:
        name - The optional name of the network. Can be null.
    • Method Detail

      • validateTrialSession

        public static void validateTrialSession()
        Evaluation version only.
      • getCustomProperties

        public CustomPropertyCollection getCustomProperties()
        Gets custom properties associated with this instance. Custom properties allow storage of custom information, which will be saved with the network.
      • getNodeGroups

        public NetworkNodeGroupCollection getNodeGroups()
        Gets groups which nodes can belong to. Each node can belong to one or more groups.
      • getSyncNodeVariableName

        public static boolean getSyncNodeVariableName()
        When true synchronizes Variable names with their containing Node. The synchronization is one way from the Node to the Variable only.

        Synchronization only occurs when a node has a single variable, whose name matches its containing node.

      • setSyncNodeVariableName

        public static void setSyncNodeVariableName​(boolean value)
        When true synchronizes Variable names with their containing Node. The synchronization is one way from the Node to the Variable only.

        Synchronization only occurs when a node has a single variable, whose name matches its containing node.

      • copy

        public Network copy()
        Makes a copy of the network.
        Returns:
        The copy.
      • getIsInternal

        public boolean getIsInternal()
        For internal use only. May be removed in future versions.
      • setIsInternal

        public void setIsInternal​(boolean value)
        For internal use only. May be removed in future versions.
      • validate

        public void validate​(ValidationOptions options)
        Validates that the Bayesian network is correctly specified.
        Parameters:
        options - Specifies options to control the validation process.
        Throws:
        InvalidNetworkException - Raised when the network is not correctly specified, containing the error message.
      • isDag

        public boolean isDag()
        Determines whether this instance is a Directed Acyclic Graph (DAG) which is a requirement for Bayesian networks.
        Returns:
        true if this instance is a DAG; otherwise, false.
      • isTree

        public boolean isTree()
        Determines whether this instance is a tree (singly connected).
        Returns:
        true if this instance is a tree; otherwise, false.
      • addMonitor

        public void addMonitor​(NetworkMonitor monitor)
        For internal use only.
        Parameters:
        monitor -
        Throws:
        NullPointerException - Raised if [monitor] is null.
      • removeMonitor

        public void removeMonitor​(NetworkMonitor monitor)
        For internal use.
        Parameters:
        monitor -
        Throws:
        NullPointerException - Raised if [monitor] is null.
      • getLinks

        public NetworkLinkCollection getLinks()
        The collection of links in the Bayesian network. Note that if a Node is removed from the network, all of its links are automatically removed.
        See Also:
        Link
      • getName

        public String getName()
        An optional name for the Bayesian network.
      • setName

        public void setName​(String value)
        An optional name for the Bayesian network.
      • getDescription

        public String getDescription()
        An optional description for the Bayesian network.
      • setDescription

        public void setDescription​(String value)
        An optional description for the Bayesian network.
      • saveToString

        public String saveToString​(String charSetName)
                            throws XMLStreamException
        Saves the network to a string, with the specified encoding. For large networks consider saving to file or a stream.
        Parameters:
        charSetName - The encoding to use.
        Returns:
        The network persisted to a string.
        Throws:
        XMLStreamException
      • saveToString

        public String saveToString()
                            throws XMLStreamException
        Saves the network to a string, with UTF-8 encoding. For large networks consider saving to file or a stream.
        Returns:
        The network persisted to a string.
        Throws:
        XMLStreamException