public final class Network extends Object implements Cloneable
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
.
Constructor and Description |
---|
Network()
Initializes a new instance of the
Network class. |
Network(String name)
Initializes a new instance of the
Network class with the specified [name]. |
Modifier and Type | Method and Description |
---|---|
void |
addMonitor(NetworkMonitor monitor)
For internal use only.
|
Network |
copy()
Makes a copy of the network.
|
CustomPropertyCollection |
getCustomProperties()
Gets custom properties associated with this instance.
|
String |
getDescription()
An optional description for the Bayesian network.
|
boolean |
getIsInternal()
For internal use only.
|
NetworkLinkCollection |
getLinks()
The collection of links in the Bayesian network.
|
String |
getName()
An optional name for the Bayesian network.
|
NetworkNodeGroupCollection |
getNodeGroups()
Gets groups which nodes can belong to.
|
NetworkNodeCollection |
getNodes()
The collection of nodes in the Bayesian network.
|
static boolean |
getSyncNodeVariableName()
|
NetworkVariableCollection |
getVariables()
The collection of variables in the Bayesian network.
|
boolean |
isDag()
Determines whether this instance is a Directed Acyclic Graph (DAG) which is a requirement for Bayesian networks.
|
boolean |
isTree()
Determines whether this instance is a tree (singly connected).
|
void |
load(InputStream input)
Loads a
Network from the specified input InputStream . |
void |
load(String path)
Loads a
Network from the specified [path]. |
void |
loadFromString(String value)
Loads a network from a string using UTF-8 encoding.
|
void |
loadFromString(String value,
String charSetName)
Loads a network from a string using the specified encoding.
|
void |
removeMonitor(NetworkMonitor monitor)
For internal use.
|
void |
save(OutputStream output)
Saves this
Network to the specified output OutputStream . |
void |
save(String path)
Saves this
Network to the specified [path] overwriting the file if it already exists. |
String |
saveToString()
Saves the network to a string, with UTF-8 encoding.
|
String |
saveToString(String charSetName)
Saves the network to a string, with the specified encoding.
|
void |
setDescription(String value)
An optional description for the Bayesian network.
|
void |
setIsInternal(boolean value)
For internal use only.
|
void |
setName(String value)
An optional name for the Bayesian network.
|
static void |
setSyncNodeVariableName(boolean value)
|
void |
validate(ValidationOptions options)
Validates that the Bayesian network is correctly specified.
|
static void |
validateTrialSession()
Evaluation version only.
|
public Network()
Network
class.public static void validateTrialSession()
public CustomPropertyCollection getCustomProperties()
public NetworkNodeGroupCollection getNodeGroups()
public static boolean getSyncNodeVariableName()
public static void setSyncNodeVariableName(boolean value)
public Network copy()
public boolean getIsInternal()
public void setIsInternal(boolean value)
public void validate(ValidationOptions options)
options
- Specifies options to control the validation process.InvalidNetworkException
- Raised when the network is not correctly specified, containing the error message.public boolean isDag()
true
if this instance is a DAG; otherwise, false
.public boolean isTree()
true
if this instance is a tree; otherwise, false
.public void addMonitor(NetworkMonitor monitor)
monitor
- NullPointerException
- Raised if [monitor] is null.public void removeMonitor(NetworkMonitor monitor)
monitor
- NullPointerException
- Raised if [monitor] is null.public NetworkNodeCollection getNodes()
Node
public NetworkVariableCollection getVariables()
Variable
public NetworkLinkCollection getLinks()
Node
is removed from the network, all of its links are automatically removed.Link
public String getName()
public void setName(String value)
public String getDescription()
public void setDescription(String value)
public String saveToString(String charSetName) throws XMLStreamException
charSetName
- The encoding to use.XMLStreamException
public String saveToString() throws XMLStreamException
XMLStreamException
public void loadFromString(String value, String charSetName) throws UnsupportedEncodingException, XMLStreamException
value
- The persisted string value of the network.charSetName
- The encoding the network was originally saved in.UnsupportedEncodingException
XMLStreamException
public void loadFromString(String value) throws UnsupportedEncodingException, XMLStreamException
value
- The persisted string value of the network.UnsupportedEncodingException
XMLStreamException
public void save(OutputStream output) throws XMLStreamException
Network
to the specified output OutputStream
.
When saving to file, .bayes is the recommended file extension.output
- The OutputStream
to save to.XMLStreamException
public void save(String path) throws IOException, XMLStreamException
Network
to the specified [path] overwriting the file if it already exists.
The recommended file extension is .bayespath
- The path and name of the file to save to.IOException
XMLStreamException
public void load(String path) throws IOException, XMLStreamException
Network
from the specified [path].path
- The path and file name to load from.IOException
XMLStreamException
public void load(InputStream input) throws XMLStreamException
Network
from the specified input InputStream
.input
- The InputStream
to load from.XMLStreamException
Copyright © 2021. All rights reserved.