COM.hugin.HAPI
Class Domain

java.lang.Object
  extended byCOM.hugin.HAPI.NetworkModel
      extended byCOM.hugin.HAPI.Domain

public class Domain
extends NetworkModel

Instances of the Domain class represent Bayesian networks and influence diagrams in which you can propagate evidence and calculate updated beliefs and expected utilities.


Nested Class Summary
static class Domain.Equilibrium
          The Equilibrium class represents the equilibrium state of this Domain.
static class Domain.EvidenceMode
          The EvidenceMode class represents the mode used for propagating evidence in this Domain.
static class Domain.TriangulationMethod
          The TriangulationMethod class represents the triangulation method used for this Domain.
 
Nested classes inherited from class COM.hugin.HAPI.NetworkModel
NetworkModel.Category, NetworkModel.Constraint, NetworkModel.Endian, NetworkModel.Kind
 
Field Summary
static Domain.Equilibrium H_EQUILIBRIUM_MAX
          Represents max equilibrium.
static Domain.Equilibrium H_EQUILIBRIUM_SUM
          Represents sum equilibrium.
static Domain.EvidenceMode H_EVIDENCE_MODE_FAST_RETRACTION
          Represents the fast retraction evidence mode used for propagating evidence in this Domain.
static Domain.EvidenceMode H_EVIDENCE_MODE_NORMAL
          Represents the normal evidence mode used for propagating evidence in this Domain.
static Domain.TriangulationMethod H_TM_CLIQUE_SIZE
          Represents the clique-size triangulation heuristic.
static Domain.TriangulationMethod H_TM_CLIQUE_WEIGHT
          Represents the clique-weight triangulation heuristic.
static Domain.TriangulationMethod H_TM_FILL_IN_SIZE
          Represents the fill-in triangulation heuristic.
static Domain.TriangulationMethod H_TM_FILL_IN_WEIGHT
          Represents the fill-in-weight triangulation heuristic.
static Domain.TriangulationMethod H_TM_TOTAL_WEIGHT
          Represents the total clique-table size triangulation algorithm.
 
Fields inherited from class COM.hugin.HAPI.NetworkModel
H_CATEGORY_CHANCE, H_CATEGORY_DECISION, H_CATEGORY_ERROR, H_CATEGORY_INSTANCE, H_CATEGORY_UTILITY, H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN, H_CONSTRAINT_BACKWARD_EDGE_REQUIRED, H_CONSTRAINT_EDGE_FORBIDDEN, H_CONSTRAINT_EDGE_REQUIRED, H_CONSTRAINT_ERROR, H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN, H_CONSTRAINT_FORWARD_EDGE_REQUIRED, H_CONSTRAINT_NONE, H_ENDIAN_BIG, H_ENDIAN_HOST, H_ENDIAN_LITTLE, H_KIND_CONTINUOUS, H_KIND_DISCRETE, H_KIND_ERROR
 
Constructor Summary
Domain()
          Constructs a new, empty Domain.
Domain(java.lang.String hkbFileName)
          Constructs a domain by loading the corresponding Hugin Knowledge Base (HKB) from a file.
Domain(java.lang.String netFileName, ParseListener parseListener)
          Constructs a domain from a NET file.
Domain(java.lang.String hkbFileName, java.lang.String password)
          Constructs a domain by loading the corresponding Hugin Knowledge Base (HKB) from a file.
 
Method Summary
 void adapt()
          Adapts this Domain according to the evidence entered.
 double approximate(double epsilon)
          Removes "near-zero" probabilities from the clique probability tables.
 boolean cgEvidenceIsPropagated()
          Returns 'true' if the evidence on CG nodes has been propagated; otherwise, returns 'false'.
 void compile()
          Compiles this Domain.
 void compile(Domain.TriangulationMethod method)
          Compiles this Domain using a particular triangulation method TriangulationMethod.
 void compile(NodeList eliminationOrder)
          Compiles this Domain using an elimination order.
 double compress()
          Removes the zero entries from the clique and separator tables of the JunctionTrees in this Domain.
 void delete()
          Deletes this Domain, including all Node and JunctionTrees belonging to it.
 boolean equilibriumIs(Domain.Equilibrium equilibrium)
          Tests for Equilibrium type.
 boolean evidenceIsPropagated()
          Tests if evidence has been propagated for this Domain.
 boolean evidenceModeIs(Domain.EvidenceMode evidenceMode)
          Tests for evidence mode.
 boolean evidenceToPropagate()
          Tests if evidence has been entered since the last propagation.
 double getApproximationConstant()
          Returns the approximation constant.
 double getCaseCount(int c)
          Returns case count for a case.
 int getConcurrencyLevel()
          Gets the current level of concurrency.
 double getConflict()
          Returns the conflict value.
 NodeList getEliminationOrder()
          Returns the triangulation order.
 int getGrainSize()
          Returns the current value of the grain size parameter.
 JunctionTreeList getJunctionTrees()
          Returns the JunctionTrees of this Domain.
 double getLogLikelihood()
          Returns log-likelihood of this Domain.
 double getLogLikelihoodTolerance()
          Returns the log-likelihood tolerance for this Domain.
 double getLogNormalizationConstant()
          Returns the log of the normalization constant.
 Table getMarginal(NodeList nodes)
          Computes the marginal distribution for the Nodes provided as argument (which must all be chance nodes) with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTree(s) of this Domain.
 int getMaxNumberOfEMIterations()
          Returns the maximum number of iterations allowed for the EM algorithm.
 int getMaxNumberOfSeparators()
          Returns the maximum number of separators allowed when using the H_TM_TOTAL_WEIGHT TriangulationMethod.
 double getNormalizationConstant()
          Retrieves the normalization constant for the most recent propagation.
 int getNumberOfCases()
          Returns the number of data cases.
 double getSignificanceLevel()
          Returns the significance level of the dependency tests performed during structural learning using the PC-algorithm.
 void initialize()
          Establishes the initial values for all tables of this Domain (which must be compiled).
 boolean isCompiled()
          Tests whether this Domain is compiled.
 boolean isCompressed()
          Tests whether this Domain is compressed.Returns 'true' if it is; otherwise, returns 'false'.
 void learnClassTables()
          Learns the conditional probability tables of the class nodes, from which the domain is created, from data using the EM algorithm.
 void learnStructure()
          Learn the structure (graph) of the Bayesian network from data using the PC-algorithm.
 void learnTables()
          Learns the conditional probability tables from data using the EM algorithm.
 boolean likelihoodIsPropagated()
          Tests if likelihood evidence has been propagated for this Domain.
 int newCase()
          Creates a new case.
 void parseCase(java.lang.String fileName, ParseListener parseListener)
          Parses the case stored in file fileName and enters the associated findings into this Domain.
 void parseCases(java.lang.String fileName, ParseListener parseListener)
          Parses the cases stored in file fileName and enters the cases into this Domain.
 void propagate(Domain.Equilibrium equilibrium, Domain.EvidenceMode evidenceMode)
          Establishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all JunctionTrees of this Domain.
 void resetInferenceEngine()
          Establishes the initial state of the inference engine, which is sum-equilibrium with no evidence incorporated.
 void retractFindings()
          Retracts (all) evidence for all nodes in this Domain.
 void save(java.lang.String fileName, NetworkModel.Endian format)
          Saves this Domain as a Hugin Knowledge Base (HKB) to a file.
 void saveAsHKB(java.lang.String fileName, java.lang.String password)
          Deprecated. Replaced by saveAsKB(String,String).
 void saveAsKB(java.lang.String fileName, java.lang.String password)
          Saves this Domain as a Hugin Knowledge Base (HKB) to a file.
 void saveCase(java.lang.String fileName)
          Saves all evidence entered in this Domain in file fileName (if the file exists, it is overwritten).
 void saveCases(java.lang.String fileName, NodeList nodes, int[] cases, boolean caseCounts, java.lang.String separator, java.lang.String missingData)
          Saves all cases entered in this Domain in a file with the given fileName (if the file exists, it is overwritten).
 void saveToMemory()
          Creates a copy in memory of the belief and JunctionTree tables of this Domain (which must be compiled).
 void seedRandom(int seed)
          Seeds the pseudo-random number generator for this Domain.
 void seedRandom(long seed)
          Deprecated. Replaced by seedRandom(int).
 void setCaseCount(int c, double count)
          Sets case count for a case.
 void setConcurrencyLevel(int level)
          Sets the level of concurrency.
 void setGrainSize(int size)
          Sets the grain size parameter.
 void setLogLikelihoodTolerance(double tolerance)
          Sets the log-likelihood tolerance for this Domain.
 void setMaxNumberOfEMIterations(int m)
          Sets the maximum number of iterations allowed for the EM algorithm.
 void setMaxNumberOfSeparators(int m)
          Sets the maximum number of separators allowed when using the H_TM_TOTAL_WEIGHT TriangulationMethod.
 void setNumberOfCases(int size)
          Sets the number of cases.
 void setSignificanceLevel(double alpha)
          Sets the significance level of the dependency tests performed during structural learning using the PC-algorithm.
 void simulate()
          Generates a sample configuration from the joint distribution represented by the JunctionTree(s) of this Domain.
 boolean tablesToPropagate()
          Tests for new node tables.
 void triangulate(Domain.TriangulationMethod method)
          Transforms the graph of this Domain into a triangulated graph.
 void triangulateWithOrder(NodeList order)
          Transforms a network into a triangulated graph using a specified elimination order.
 void unCompile()
          Uncompiles this Domain.
 void writeNet(java.lang.String fileName)
          Deprecated. Replaced by saveAsNet().
 
Methods inherited from class COM.hugin.HAPI.NetworkModel
closeLogFile, generateTables, getAttribute, getAttributes, getFileName, getLogFile, getNodeByName, getNodes, getNodeSize, getUserData, INFINITY, openLogFile, openLogFile, parseNodes, saveAsNet, setAttribute, setNodeSize, setUserData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

H_EQUILIBRIUM_SUM

public static final Domain.Equilibrium H_EQUILIBRIUM_SUM
Represents sum equilibrium. Sum equilibrium is the state achieved by sum propagation in the JunctionTree of this Domain. See also propagate(Equilibrium, EvidenceMode).


H_EQUILIBRIUM_MAX

public static final Domain.Equilibrium H_EQUILIBRIUM_MAX
Represents max equilibrium. Max equilibrium is the state achieved by max propagation in the JunctionTree of this Domain. See also propagate(Equilibrium, EvidenceMode).


H_EVIDENCE_MODE_NORMAL

public static final Domain.EvidenceMode H_EVIDENCE_MODE_NORMAL
Represents the normal evidence mode used for propagating evidence in this Domain.


H_EVIDENCE_MODE_FAST_RETRACTION

public static final Domain.EvidenceMode H_EVIDENCE_MODE_FAST_RETRACTION
Represents the fast retraction evidence mode used for propagating evidence in this Domain.


H_TM_CLIQUE_SIZE

public static final Domain.TriangulationMethod H_TM_CLIQUE_SIZE
Represents the clique-size triangulation heuristic. Triangulation is the process of transforming the graph of this Domain to a triangulated graph, which forms the basis for constructing the JunctionTree of the Domain. As its score function, this heuristic uses the size of N(v), where N(v) is the set of neighbors of the target node v (i.e., the node to be eliminated next in the elimination order used for triangulating the graph).


H_TM_CLIQUE_WEIGHT

public static final Domain.TriangulationMethod H_TM_CLIQUE_WEIGHT
Represents the clique-weight triangulation heuristic. Triangulation is the process of transforming the graph of this Domain to a triangulated graph, which forms the basis for constructing the JunctionTree of the Domain. As its score function, this heuristic uses the product of the number of states of the discrete nodes in N(v) multiplied by a + bm(m + 3)/2, where m is the number of continuous nodes in N(v), a and b are the size of the types h_number_t and h_double_t, respectively, and N(v) is the set of neighbors of the target node v (i.e., the node to be eliminated next in the elimination order used for triangulating the graph).


H_TM_FILL_IN_SIZE

public static final Domain.TriangulationMethod H_TM_FILL_IN_SIZE
Represents the fill-in triangulation heuristic. Triangulation is the process of transforming the graph of this Domain to a triangulated graph, which forms the basis for constructing the JunctionTree of the Domain. As its score function, this heuristic uses the number of fill-in links required to complete the neighbors of a target node (i.e., the node to be eliminated next in the elimination order used for triangulating the graph).


H_TM_FILL_IN_WEIGHT

public static final Domain.TriangulationMethod H_TM_FILL_IN_WEIGHT
Represents the fill-in-weight triangulation heuristic. Triangulation is the process of transforming the graph of this Domain to a triangulated graph, which forms the basis for constructing the JunctionTree of the Domain. As its score function, this heuristic uses the sum of the weights of the fill-in links required to complete the neighbors of a target node (i.e., the node to be eliminated next in the elimination order used for triangulating the graph).


H_TM_TOTAL_WEIGHT

public static final Domain.TriangulationMethod H_TM_TOTAL_WEIGHT
Represents the total clique-table size triangulation algorithm. Triangulation is the process of transforming the graph of this Domain to a triangulated graph, which forms the basis for constructing the JunctionTree of the Domain. This algorithm is also sometimes referred to as the optimal triangulation algorithm. See also setMaxNumberOfSeparators(int).

Constructor Detail

Domain

public Domain()
       throws ExceptionHugin
Constructs a new, empty Domain.


Domain

public Domain(java.lang.String hkbFileName)
       throws ExceptionHugin
Constructs a domain by loading the corresponding Hugin Knowledge Base (HKB) from a file.

Parameters:
hkbFileName - the name of the HKB file (a String).

Domain

public Domain(java.lang.String hkbFileName,
              java.lang.String password)
       throws ExceptionHugin
Constructs a domain by loading the corresponding Hugin Knowledge Base (HKB) from a file.

Parameters:
hkbFileName - the name of the HKB file (a String).
password - a password needed to load the file.

Domain

public Domain(java.lang.String netFileName,
              ParseListener parseListener)
       throws ExceptionHugin
Constructs a domain from a NET file.

Parameters:
netFileName - a string containing the name of the NET file.
parseListener - the ParseListener used for handling parse errors.
Method Detail

delete

public void delete()
            throws ExceptionHugin
Deletes this Domain, including all Node and JunctionTrees belonging to it.

Specified by:
delete in class NetworkModel
Throws:
ExceptionHugin

approximate

public double approximate(double epsilon)
                   throws ExceptionHugin
Removes "near-zero" probabilities from the clique probability tables. For each Clique in this domain, a value delta is computed such that the sum of all elements less than delta in the (discrete part) of the clique table is less than epsilon. These elements (less than delta) are then set to 0.

Parameters:
epsilon - the threshold value. Maximal probability mass to eradicate from each clique.
Returns:
The probability mass remaining in the entire Domain, letting you know how much precision you have "lost". Note that this is not the same as 1 - e, as the e value is relative to each clique. Typically, the amount of probability mass removed will be somewhat larger than e.
Throws:
ExceptionHugin

cgEvidenceIsPropagated

public boolean cgEvidenceIsPropagated()
                               throws ExceptionHugin
Returns 'true' if the evidence on CG nodes has been propagated; otherwise, returns 'false'.

Returns:
A boolean.
Throws:
ExceptionHugin

compile

public void compile()
             throws ExceptionHugin
Compiles this Domain. Uses the default triangulation method, unless the Domain is already triangulated using triangulate or triangulateWithOrder. If the domain already is triangulated, nothing is changed. The Domain must contain at least one chance or decision node.

Throws:
ExceptionHugin

compile

public void compile(NodeList eliminationOrder)
             throws ExceptionHugin
Compiles this Domain using an elimination order. If the domain already is triangulated, nothing is changed. The Domain must contain at least one chance or decision node.

Parameters:
eliminationOrder - an ordered NodeList used as basis for constructing the triangulated graph (and in turn the JunctionTree).
Throws:
ExceptionHugin

compile

public void compile(Domain.TriangulationMethod method)
             throws ExceptionHugin
Compiles this Domain using a particular triangulation method TriangulationMethod. If the domain already is triangulated, nothing is changed. The Domain must contain at least one chance or decision node.

Parameters:
method - the triangulation method used.
Throws:
ExceptionHugin

compress

public double compress()
                throws ExceptionHugin
Removes the zero entries from the clique and separator tables of the JunctionTrees in this Domain. Compression can only be applied to (compiled) ordinary Bayesian networks. Continuous nodes are allowed, but compression only applies to configurations of states of the discrete nodes.

Returns:
A double value which indicates a measure of compression achieved. The measure should be less than 1, indicating that the compressed Domain requires less space than the uncompressed Domain. An output greater than 1 means that the "compressed" Domain requires more space than the uncompressed Domain.
Throws:
ExceptionHugin

equilibriumIs

public boolean equilibriumIs(Domain.Equilibrium equilibrium)
                      throws ExceptionHugin
Tests for Equilibrium type. Returns 'true' if the equilibrium state of all JunctionTrees of this Domain are identical to 'equilibrium'.

Parameters:
equilibrium - the type of Equilibrium to test for.
Returns:
A boolean.
Throws:
ExceptionHugin

evidenceIsPropagated

public boolean evidenceIsPropagated()
                             throws ExceptionHugin
Tests if evidence has been propagated for this Domain. Returns 'true' if it has; otherwise, returns 'false'.

Returns:
A boolean.
Throws:
ExceptionHugin

evidenceModeIs

public boolean evidenceModeIs(Domain.EvidenceMode evidenceMode)
                       throws ExceptionHugin
Tests for evidence mode. Returns 'true' if the equilibrium states of all JunctionTrees of this Domain could have been obtained through a propagation using 'evidenceMode' as the evidence incorporation mode. Otherwise, returns 'false'.

Parameters:
evidenceMode - the type of EvidenceMode to test for.
Returns:
A boolean.
Throws:
ExceptionHugin

evidenceToPropagate

public boolean evidenceToPropagate()
                            throws ExceptionHugin
Tests if evidence has been entered since the last propagation. Returns 'true' if it has; otherwise, returns 'false'.

Returns:
A boolean.
Throws:
ExceptionHugin

getApproximationConstant

public double getApproximationConstant()
                                throws ExceptionHugin
Returns the approximation constant. The number returned is based on the most recent (explicit or implicit) approximation operation. An implicit approximation takes place when you change some conditional probability tables of acompressed domain, and then perform a propagation operation. Since some (discrete) state configurations have been removed from a compressed domain, the probability mass of the remaining configurations will typically be less than 1. This probability mass is returned by getApproximationConstant().

Returns:
A double expressing the probability mass remaining in the approximated domain.
Throws:
ExceptionHugin

getConflict

public double getConflict()
                   throws ExceptionHugin
Returns the conflict value. The conflict value is valid for this Domain computed during the most recent propagation. If no propagation has been performed, 1 is returned.

Returns:
A double-precision real value expressing the conflict measure in the domain.
Throws:
ExceptionHugin

getEliminationOrder

public NodeList getEliminationOrder()
                             throws ExceptionHugin
Returns the triangulation order. A NodeList containing a list of nodes in the order used to triangulate the network of this Domain is returned.

Returns:
NodeList containing Nodes representing the elimination order used.
Throws:
ExceptionHugin

getJunctionTrees

public JunctionTreeList getJunctionTrees()
                                  throws ExceptionObjectNotAlive
Returns the JunctionTrees of this Domain.

Returns:
A JunctionTreeList.
Throws:
ExceptionObjectNotAlive

getMarginal

public Table getMarginal(NodeList nodes)
                  throws ExceptionHugin
Computes the marginal distribution for the Nodes provided as argument (which must all be chance nodes) with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTree(s) of this Domain. If 'nodes' contains continuous nodes, they must be last in the list. This operation is not allowed on compressed Domains.

Parameters:
nodes - a NodeList containing the Nodes over which to compute the marginal.
Returns:
A Table containing the marginal distribution over the Nodes in 'nodes'.
Throws:
ExceptionHugin

getNormalizationConstant

public double getNormalizationConstant()
                                throws ExceptionHugin
Retrieves the normalization constant for the most recent propagation. For sum-propagation, the normalization constant is equal to the probability of the evidence propagated. For max-propagation, the normalization constant is the probability of the most probable configuration with the evidence incorporated.

Returns:
A double-precision real number.
Throws:
ExceptionHugin

initialize

public void initialize()
                throws ExceptionHugin
Establishes the initial values for all tables of this Domain (which must be compiled). This method erases all evidence previously entered.

Throws:
ExceptionHugin

isCompiled

public boolean isCompiled()
                   throws ExceptionHugin
Tests whether this Domain is compiled. Returns 'true' if it is; otherwise, returns 'false'.

Returns:
A boolean.
Throws:
ExceptionHugin

isCompressed

public boolean isCompressed()
                     throws ExceptionHugin
Tests whether this Domain is compressed.Returns 'true' if it is; otherwise, returns 'false'.

Returns:
A Boolean.
Throws:
ExceptionHugin

likelihoodIsPropagated

public boolean likelihoodIsPropagated()
                               throws ExceptionHugin
Tests if likelihood evidence has been propagated for this Domain. Returns 'true' if it has; otherwise, returns 'false'.

Returns:
A boolean.
Throws:
ExceptionHugin

propagate

public void propagate(Domain.Equilibrium equilibrium,
                      Domain.EvidenceMode evidenceMode)
               throws ExceptionHugin
Establishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all JunctionTrees of this Domain. Also, revised beliefs will be computed for all nodes.

Parameters:
equilibrium - Equilibrium type. The normal Equilibrium type is Domain.H_EQUILIBRIUM_SUM.
evidenceMode - EvidenceMode type. The normal EvidenceMode type is Domain.H_EVIDENCE_MODE_NORMAL.
Throws:
ExceptionHugin

resetInferenceEngine

public void resetInferenceEngine()
                          throws ExceptionHugin
Establishes the initial state of the inference engine, which is sum-equilibrium with no evidence incorporated. Any propagated evidence will thus be removed from the JunctionTree potentials, but entered evidence will still be "registered" (i.e., they will be incorporated in the next propagation).

Throws:
ExceptionHugin

retractFindings

public void retractFindings()
                     throws ExceptionHugin
Retracts (all) evidence for all nodes in this Domain.

Throws:
ExceptionHugin

save

public void save(java.lang.String fileName,
                 NetworkModel.Endian format)
          throws ExceptionHugin
Saves this Domain as a Hugin Knowledge Base (HKB) to a file. The byte order of the HKB file is determined by the 'format' argument. If the Domain is compiled, it can only be saved if the current equilibrium equals Domain.H_EQUILIBRIUM_SUM, and the current evidence incorporation mode equals Domain.H_EVIDENCE_MODE_NORMAL.

Parameters:
fileName - the name of the file to which the HKB is saved.
format - byte-order in the saved file.
Throws:
ExceptionHugin

saveAsKB

public void saveAsKB(java.lang.String fileName,
                     java.lang.String password)
              throws ExceptionHugin
Saves this Domain as a Hugin Knowledge Base (HKB) to a file. If password is non-null, the file will be password protected. This password will have to be used whenever the file is to be reloaded. If the Domain is compiled, it can only be saved if the current equilibrium equals Domain.H_EQUILIBRIUM_SUM, and the current evidence incorporation mode equals Domain.H_EVIDENCE_MODE_NORMAL.

Parameters:
fileName - the name of the file to which the HKB is saved.
password - which, if non-null, will be needed upon reloading the file.
Throws:
ExceptionHugin

saveAsHKB

public void saveAsHKB(java.lang.String fileName,
                      java.lang.String password)
               throws ExceptionHugin
Deprecated. Replaced by saveAsKB(String,String).

Throws:
ExceptionHugin

saveToMemory

public void saveToMemory()
                  throws ExceptionHugin
Creates a copy in memory of the belief and JunctionTree tables of this Domain (which must be compiled). This operation can only be performed if the current equilibrium equals Domain.H_EQUILIBRIUM_SUM, the current evidence mode equals Domain.H_EVIDENCE_MODE_NORMAL, and no CG evidence has been incorporated.

Throws:
ExceptionHugin

writeNet

public void writeNet(java.lang.String fileName)
              throws ExceptionHugin
Deprecated. Replaced by saveAsNet().

Throws:
ExceptionHugin

simulate

public void simulate()
              throws ExceptionHugin
Generates a sample configuration from the joint distribution represented by the JunctionTree(s) of this Domain. Given evidence, we may be interested in generating (sampling) configurations (i.e., vectors of values over the set of variables in the network) with respect to the conditional distribution for the evidence. If the Domain is compiled, a configuration is sampled with respect to the current distribution represented by the JunctionTree(s). This distribution must be in sum-equilibrium with evidence incorporated in normal mode.

Throws:
ExceptionHugin

seedRandom

public void seedRandom(int seed)
                throws ExceptionHugin
Seeds the pseudo-random number generator for this Domain. The configurations generated by simulate are not really random. They are generated using a pseudo-random number generator producing a sequence of numbers that although it appears random is actually completely deterministic. To change the starting point for the generator, use this method.

Parameters:
seed - the seed number.
Throws:
ExceptionHugin

seedRandom

public void seedRandom(long seed)
                throws ExceptionHugin
Deprecated. Replaced by seedRandom(int).

Throws:
ExceptionHugin

tablesToPropagate

public boolean tablesToPropagate()
                          throws ExceptionHugin
Tests for new node tables. Returns 'true' if there are any nodes in this Domain having (a conditional probability or utility) table that has changed since the most recent compilation or propagation; otherwise, returns 'false'.

Returns:
A boolean.
Throws:
ExceptionHugin

triangulate

public void triangulate(Domain.TriangulationMethod method)
                 throws ExceptionHugin
Transforms the graph of this Domain into a triangulated graph. First, the network of the Domain is tranformed into its moral graph, and then this moral graph is triangulated using a triangulation method.

Parameters:
method - the TriangulationMethod used.
Throws:
ExceptionHugin

triangulateWithOrder

public void triangulateWithOrder(NodeList order)
                          throws ExceptionHugin
Transforms a network into a triangulated graph using a specified elimination order. First, the network of this Domain is transformed into its moral graph. Second, this moral graph is triangulated using the Nodes in the NodeList order as elimination sequence. order must contain each chance and decision node of this Domain exactly once and it must respect the restrictions for influence diagrams and networks containing continuous chance nodes.

Parameters:
order - a NodeList containing the Nodes of the network in the order of elimination.
Throws:
ExceptionHugin

unCompile

public void unCompile()
               throws ExceptionHugin
Uncompiles this Domain. Removes the data structures of the Domain that are produced by compile(), triangulate(TriangulationMethod), and triangulateWithOrder(NodeList). Note that any references to objects within the compiled structure (e.g., Cliques and JunctionTrees) are invalidated by a call to uncompile(). Also note that many of the editing functions automatically performs an uncompile() operation. When this happens, the domain must be compiled (using compile()) before it can be used for inference.

Throws:
ExceptionHugin

setConcurrencyLevel

public void setConcurrencyLevel(int level)
                         throws ExceptionHugin
Sets the level of concurrency. The level of concurrency specifies the maximum number of threads to create when performing a specific table operation. Setting the level of concurrency to 1 will cause all table operations to be performed sequentially. The initial parameter value is 1.

Parameters:
level - the level of concurrency.
Throws:
ExceptionHugin

setGrainSize

public void setGrainSize(int size)
                  throws ExceptionHugin
Sets the grain size parameter. The grain size parameter specifies a lower limit of the tasks to be performed by each thread. The size of a task is approximately equal to the number of floating-point operations needed to perform the task (e.g. the number of elements to sum when performing a marginalization task).

The initial value of the grain size parameter is 10000.

Parameters:
size - the grain size.
Throws:
ExceptionHugin

getConcurrencyLevel

public int getConcurrencyLevel()
                        throws ExceptionHugin
Gets the current level of concurrency.

Returns:
A positive integer.

Throws:
ExceptionHugin
See Also:
setConcurrencyLevel

getGrainSize

public int getGrainSize()
                 throws ExceptionHugin
Returns the current value of the grain size parameter.

Returns:
A positive integer.
Throws:
ExceptionHugin

getLogNormalizationConstant

public double getLogNormalizationConstant()
                                   throws ExceptionHugin
Returns the log of the normalization constant.

Throws:
ExceptionHugin

setNumberOfCases

public void setNumberOfCases(int size)
                      throws ExceptionHugin
Sets the number of cases.

Throws:
ExceptionHugin

newCase

public int newCase()
            throws ExceptionHugin
Creates a new case.

Throws:
ExceptionHugin

getNumberOfCases

public int getNumberOfCases()
                     throws ExceptionHugin
Returns the number of data cases.

Throws:
ExceptionHugin

setCaseCount

public void setCaseCount(int c,
                         double count)
                  throws ExceptionHugin
Sets case count for a case.

Parameters:
c - the case for which to set the count.
count - the multiplicity of 'c'.
Throws:
ExceptionHugin

getCaseCount

public double getCaseCount(int c)
                    throws ExceptionHugin
Returns case count for a case.

Parameters:
c - the case for which to get the count.
Returns:
The multiplicity of 'c'.
Throws:
ExceptionHugin

learnTables

public void learnTables()
                 throws ExceptionHugin
Learns the conditional probability tables from data using the EM algorithm.

Throws:
ExceptionHugin

learnClassTables

public void learnClassTables()
                      throws ExceptionHugin
Learns the conditional probability tables of the class nodes, from which the domain is created, from data using the EM algorithm.

Throws:
ExceptionHugin

getLogLikelihood

public double getLogLikelihood()
                        throws ExceptionHugin
Returns log-likelihood of this Domain.

Throws:
ExceptionHugin

setLogLikelihoodTolerance

public void setLogLikelihoodTolerance(double tolerance)
                               throws ExceptionHugin
Sets the log-likelihood tolerance for this Domain.

Throws:
ExceptionHugin

getLogLikelihoodTolerance

public double getLogLikelihoodTolerance()
                                 throws ExceptionHugin
Returns the log-likelihood tolerance for this Domain.

Throws:
ExceptionHugin

setMaxNumberOfEMIterations

public void setMaxNumberOfEMIterations(int m)
                                throws ExceptionHugin
Sets the maximum number of iterations allowed for the EM algorithm.

Throws:
ExceptionHugin

getMaxNumberOfEMIterations

public int getMaxNumberOfEMIterations()
                               throws ExceptionHugin
Returns the maximum number of iterations allowed for the EM algorithm.

Throws:
ExceptionHugin

adapt

public void adapt()
           throws ExceptionHugin
Adapts this Domain according to the evidence entered.

Throws:
ExceptionHugin

learnStructure

public void learnStructure()
                    throws ExceptionHugin
Learn the structure (graph) of the Bayesian network from data using the PC-algorithm.

Throws:
ExceptionHugin

setSignificanceLevel

public void setSignificanceLevel(double alpha)
                          throws ExceptionHugin
Sets the significance level of the dependency tests performed during structural learning using the PC-algorithm. The default value is 0.05.

Parameters:
alpha - the significance level.
Throws:
ExceptionHugin

getSignificanceLevel

public double getSignificanceLevel()
                            throws ExceptionHugin
Returns the significance level of the dependency tests performed during structural learning using the PC-algorithm. The default value is 0.05

Returns:
A positive double.
Throws:
ExceptionHugin

setMaxNumberOfSeparators

public void setMaxNumberOfSeparators(int m)
                              throws ExceptionHugin
Sets the maximum number of separators allowed when using the H_TM_TOTAL_WEIGHT TriangulationMethod.

Throws:
ExceptionHugin

getMaxNumberOfSeparators

public int getMaxNumberOfSeparators()
                             throws ExceptionHugin
Returns the maximum number of separators allowed when using the H_TM_TOTAL_WEIGHT TriangulationMethod.

Throws:
ExceptionHugin

parseCase

public void parseCase(java.lang.String fileName,
                      ParseListener parseListener)
               throws ExceptionHugin
Parses the case stored in file fileName and enters the associated findings into this Domain. All existing evidence in the Domain is retracted before entering the case findings.

Parameters:
fileName - the name of the file containing the case.
parseListener - the ParseListener used for handling parse errors.
Throws:
ExceptionHugin

saveCase

public void saveCase(java.lang.String fileName)
              throws ExceptionHugin
Saves all evidence entered in this Domain in file fileName (if the file exists, it is overwritten).

Parameters:
fileName - the name of the file in which the case is going to be saved.
Throws:
ExceptionHugin

saveCases

public void saveCases(java.lang.String fileName,
                      NodeList nodes,
                      int[] cases,
                      boolean caseCounts,
                      java.lang.String separator,
                      java.lang.String missingData)
               throws ExceptionHugin
Saves all cases entered in this Domain in a file with the given fileName (if the file exists, it is overwritten).

Parameters:
fileName - the name of the file in which the case is going to be saved.
nodes - A list of all nodes which are to be included in the file
cases - A boolean array specifying for each case whether the case is to be included in the file. Giving NULL will include all cases.
caseCounts - If true, include case counts in the data file. If false, only include case counts if they are present in the domain.
separator - The string used to seperate the items in the file
missingData - The string used to represent missing data
Throws:
ExceptionHugin

parseCases

public void parseCases(java.lang.String fileName,
                       ParseListener parseListener)
                throws ExceptionHugin
Parses the cases stored in file fileName and enters the cases into this Domain.

Parameters:
fileName - the name of the file containing the cases.
parseListener - the ParseListener used for handling parse errors.
Throws:
ExceptionHugin