pt.tumba.ngram.bayes
Class BayesNet

java.lang.Object
  extended by pt.tumba.ngram.bayes.BayesNet
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
QuasiBayesNet

public class BayesNet
extends java.lang.Object
implements java.io.Serializable

Author:
Bruno Martins
See Also:
Serialized Form

Field Summary
static int BIF
           
static int BUGS
           
static int INVALID_INDEX
           
protected  java.lang.String name
           
protected  ProbabilityFunction[] probability_functions
           
protected  ProbabilityVariable[] probability_variables
           
protected  java.util.Vector properties
           
protected  DiscreteFunction utility_function
           
static int XML
           
 
Constructor Summary
BayesNet()
          Default constructor for a BayesNet.
BayesNet(BayesNet bn)
          Simple constructor for a BayesNet; creates a copy of a given network.
BayesNet(java.io.InputStream istream)
          Construct a BayesNet from a textual description in a stream.
BayesNet(java.lang.String s)
          Construct a BayesNet from a textual description in a string.
BayesNet(java.lang.String n_n, int n_v, int n_f)
          Simple constructor for a BayesNet.
BayesNet(java.lang.String n_n, java.util.Vector p)
          Simple constructor for a BayesNet.
BayesNet(java.net.URL url)
          Construct a BayesNet from a textual description in an URL.
BayesNet(java.net.URL context, java.lang.String spec)
          Construct a BayesNet from a textual description in an URL.
 
Method Summary
 void add_property(java.lang.String prop)
          Add a property.
 java.lang.String[][] get_all_evidence()
          Get all the evidence contained in the network variables.
 ProbabilityFunction get_function(ProbabilityVariable p_v)
          Find the ProbabilityFunction that corresponds to a given ProbabilityVariable.
 java.lang.String get_name()
          Get the name of the network.
 ProbabilityFunction get_probability_function(int index)
          Get the probability function at a given index.
 ProbabilityFunction[] get_probability_functions()
          Get the probability functions.
 ProbabilityVariable get_probability_variable(int index)
          Get the probability variable at a given index.
 ProbabilityVariable[] get_probability_variables()
          Get the probability variables.
 java.util.Vector get_properties()
          Get the properties.
 DiscreteFunction get_utility_function()
          Get the utility function.
 int index_of_variable(java.lang.String n_vb)
          Determine the position of a variable given its name.
 int number_probability_functions()
          Get the number of distributions in the network.
 int number_variables()
          Get the number of variables in the network.
 void print()
          Print a BayesNet in the standard output.
 void print(java.io.PrintStream out)
          Print a BayesNet in a given stream.
protected  void process_probability_function_properties(int index)
           
protected  void process_probability_variable_properties(int index)
           
protected  void process_properties()
           
 void remove_property(int i)
          Remove a property.
 void remove_property(java.lang.String prop)
          Remove a property.
 void save_bif(java.io.PrintStream out)
          Save a BayesNet object in a stream, in the BIF InterchangeFormat.
 void save_bugs(java.io.PrintStream pstream)
          Save a BayesNet object into a stream, in the BUGS format.
 void save_embayes(java.io.PrintStream out)
          Save a BayesNet object in a stream for the EBayes engine.
 void save_xml_0_2(java.io.PrintStream pstream)
          Save a BayesNet object in a stream, in the XMLBIF format version 0.2.
 void save_xml(java.io.PrintStream pstream)
          Save a BayesNet object in a stream, in the XMLBIF format version 0.3 (most recent version).
 void set_name(java.lang.String n)
          Set the name of the network.
 void set_probability_function(int index, ProbabilityFunction p_f)
          Set a probability variable given its index.
 void set_probability_function(int index, ProbabilityVariable[] variables, double[] values, java.util.Vector vec)
          Set a probability function given its constituents.
 void set_probability_functions(ProbabilityFunction[] pfs)
          Set the vector of probability functions.
 void set_probability_variable(int index, ProbabilityVariable p_v)
          Set a probability variable given its index.
 void set_probability_variable(int index, java.lang.String name, java.lang.String[] v, java.util.Vector vec)
          Set a probability variable given its constituents.
 void set_probability_variables(ProbabilityVariable[] pvs)
          Set the vector of probability variables.
 void set_properties(java.util.Vector prop)
          Set the properties.
protected  void translate(InterchangeFormat ifo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

properties

protected java.util.Vector properties

probability_variables

protected ProbabilityVariable[] probability_variables

probability_functions

protected ProbabilityFunction[] probability_functions

utility_function

protected DiscreteFunction utility_function

INVALID_INDEX

public static final int INVALID_INDEX
See Also:
Constant Field Values

BIF

public static final int BIF
See Also:
Constant Field Values

XML

public static final int XML
See Also:
Constant Field Values

BUGS

public static final int BUGS
See Also:
Constant Field Values
Constructor Detail

BayesNet

public BayesNet()
Default constructor for a BayesNet.


BayesNet

public BayesNet(java.lang.String n_n,
                int n_v,
                int n_f)
Simple constructor for a BayesNet.

Parameters:
n_n - Name of the network.
n_v - Number of variables in the network.
n_f - Number of probability distributions in the network.

BayesNet

public BayesNet(java.lang.String n_n,
                java.util.Vector p)
Simple constructor for a BayesNet.

Parameters:
n_n - Name of network.
p - Properties of the network.

BayesNet

public BayesNet(BayesNet bn)
Simple constructor for a BayesNet; creates a copy of a given network.

Parameters:
bn - Network to be copied.

BayesNet

public BayesNet(java.lang.String s)
         throws IFException
Construct a BayesNet from a textual description in a string.

Throws:
IFException

BayesNet

public BayesNet(java.io.InputStream istream)
         throws IFException
Construct a BayesNet from a textual description in a stream.

Throws:
IFException

BayesNet

public BayesNet(java.net.URL context,
                java.lang.String spec)
         throws IFException,
                java.io.IOException
Construct a BayesNet from a textual description in an URL.

Parameters:
context - The URL context as defined in the Java libraries.
spec - The URL spec as defined in the Java libraries.
Throws:
IFException
java.io.IOException

BayesNet

public BayesNet(java.net.URL url)
         throws IFException,
                java.io.IOException
Construct a BayesNet from a textual description in an URL.

Throws:
IFException
java.io.IOException
Method Detail

translate

protected void translate(InterchangeFormat ifo)

process_properties

protected void process_properties()

process_probability_variable_properties

protected void process_probability_variable_properties(int index)

process_probability_function_properties

protected void process_probability_function_properties(int index)

get_function

public ProbabilityFunction get_function(ProbabilityVariable p_v)
Find the ProbabilityFunction that corresponds to a given ProbabilityVariable. Note: the index of a variable is used by the function, as it is the only reference to the variable that is guaranteed to identify the variable uniquely.


save_bif

public void save_bif(java.io.PrintStream out)
Save a BayesNet object in a stream, in the BIF InterchangeFormat.


save_embayes

public void save_embayes(java.io.PrintStream out)
Save a BayesNet object in a stream for the EBayes engine.


save_xml

public void save_xml(java.io.PrintStream pstream)
Save a BayesNet object in a stream, in the XMLBIF format version 0.3 (most recent version).


save_xml_0_2

public void save_xml_0_2(java.io.PrintStream pstream)
Save a BayesNet object in a stream, in the XMLBIF format version 0.2.


save_bugs

public void save_bugs(java.io.PrintStream pstream)
Save a BayesNet object into a stream, in the BUGS format.


get_all_evidence

public java.lang.String[][] get_all_evidence()
Get all the evidence contained in the network variables.


index_of_variable

public int index_of_variable(java.lang.String n_vb)
Determine the position of a variable given its name.


print

public void print()
Print a BayesNet in the standard output.


print

public void print(java.io.PrintStream out)
Print a BayesNet in a given stream.


get_name

public java.lang.String get_name()
Get the name of the network.


set_name

public void set_name(java.lang.String n)
Set the name of the network.


get_properties

public java.util.Vector get_properties()
Get the properties.


set_properties

public void set_properties(java.util.Vector prop)
Set the properties.


add_property

public void add_property(java.lang.String prop)
Add a property.


remove_property

public void remove_property(java.lang.String prop)
Remove a property.


remove_property

public void remove_property(int i)
Remove a property.


number_variables

public int number_variables()
Get the number of variables in the network.


number_probability_functions

public int number_probability_functions()
Get the number of distributions in the network.


get_probability_variable

public ProbabilityVariable get_probability_variable(int index)
Get the probability variable at a given index.


get_probability_function

public ProbabilityFunction get_probability_function(int index)
Get the probability function at a given index.


get_probability_variables

public ProbabilityVariable[] get_probability_variables()
Get the probability variables.


get_probability_functions

public ProbabilityFunction[] get_probability_functions()
Get the probability functions.


get_utility_function

public DiscreteFunction get_utility_function()
Get the utility function.


set_probability_variable

public void set_probability_variable(int index,
                                     java.lang.String name,
                                     java.lang.String[] v,
                                     java.util.Vector vec)
Set a probability variable given its constituents.


set_probability_function

public void set_probability_function(int index,
                                     ProbabilityVariable[] variables,
                                     double[] values,
                                     java.util.Vector vec)
Set a probability function given its constituents.


set_probability_variable

public void set_probability_variable(int index,
                                     ProbabilityVariable p_v)
Set a probability variable given its index.


set_probability_function

public void set_probability_function(int index,
                                     ProbabilityFunction p_f)
Set a probability variable given its index.


set_probability_variables

public void set_probability_variables(ProbabilityVariable[] pvs)
Set the vector of probability variables.


set_probability_functions

public void set_probability_functions(ProbabilityFunction[] pfs)
Set the vector of probability functions.