|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCOM.hugin.HAPI.NetworkModel
COM.hugin.HAPI.Domain
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. |
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 |
public static final Domain.Equilibrium H_EQUILIBRIUM_SUM
propagate(Equilibrium, EvidenceMode)
.
public static final Domain.Equilibrium H_EQUILIBRIUM_MAX
propagate(Equilibrium, EvidenceMode)
.
public static final Domain.EvidenceMode H_EVIDENCE_MODE_NORMAL
public static final Domain.EvidenceMode H_EVIDENCE_MODE_FAST_RETRACTION
public static final Domain.TriangulationMethod H_TM_CLIQUE_SIZE
public static final Domain.TriangulationMethod H_TM_CLIQUE_WEIGHT
public static final Domain.TriangulationMethod H_TM_FILL_IN_SIZE
public static final Domain.TriangulationMethod H_TM_FILL_IN_WEIGHT
public static final Domain.TriangulationMethod H_TM_TOTAL_WEIGHT
setMaxNumberOfSeparators(int)
.
Constructor Detail |
public Domain() throws ExceptionHugin
public Domain(java.lang.String hkbFileName) throws ExceptionHugin
hkbFileName
- the name of the HKB file (a String).public Domain(java.lang.String hkbFileName, java.lang.String password) throws ExceptionHugin
hkbFileName
- the name of the HKB file (a String).password
- a password needed to load the file.public Domain(java.lang.String netFileName, ParseListener parseListener) throws ExceptionHugin
netFileName
- a string containing the name of the NET file.parseListener
- the ParseListener used for handling
parse errors.Method Detail |
public void delete() throws ExceptionHugin
delete
in class NetworkModel
ExceptionHugin
public double approximate(double epsilon) throws ExceptionHugin
epsilon
- the threshold value. Maximal probability
mass to eradicate from each clique.
ExceptionHugin
public boolean cgEvidenceIsPropagated() throws ExceptionHugin
ExceptionHugin
public void compile() throws ExceptionHugin
triangulate
or triangulateWithOrder
. If the
domain already is triangulated, nothing is changed. The Domain
must contain at least one chance or decision node.
ExceptionHugin
public void compile(NodeList eliminationOrder) throws ExceptionHugin
eliminationOrder
- an ordered NodeList used as basis for
constructing the triangulated graph (and in turn the
JunctionTree).
ExceptionHugin
public void compile(Domain.TriangulationMethod method) throws ExceptionHugin
TriangulationMethod
. If the domain
already is triangulated, nothing is changed. The Domain must
contain at least one chance or decision node.
method
- the triangulation method used.
ExceptionHugin
public double compress() throws ExceptionHugin
ExceptionHugin
public boolean equilibriumIs(Domain.Equilibrium equilibrium) throws ExceptionHugin
equilibrium
- the type of Equilibrium to test for.
ExceptionHugin
public boolean evidenceIsPropagated() throws ExceptionHugin
ExceptionHugin
public boolean evidenceModeIs(Domain.EvidenceMode evidenceMode) throws ExceptionHugin
evidenceMode
- the type of EvidenceMode to test for.
ExceptionHugin
public boolean evidenceToPropagate() throws ExceptionHugin
ExceptionHugin
public double getApproximationConstant() throws ExceptionHugin
ExceptionHugin
public double getConflict() throws ExceptionHugin
ExceptionHugin
public NodeList getEliminationOrder() throws ExceptionHugin
ExceptionHugin
public JunctionTreeList getJunctionTrees() throws ExceptionObjectNotAlive
ExceptionObjectNotAlive
public Table getMarginal(NodeList nodes) throws ExceptionHugin
nodes
- a NodeList containing the Nodes over
which to compute the marginal.
ExceptionHugin
public double getNormalizationConstant() throws ExceptionHugin
ExceptionHugin
public void initialize() throws ExceptionHugin
ExceptionHugin
public boolean isCompiled() throws ExceptionHugin
ExceptionHugin
public boolean isCompressed() throws ExceptionHugin
ExceptionHugin
public boolean likelihoodIsPropagated() throws ExceptionHugin
ExceptionHugin
public void propagate(Domain.Equilibrium equilibrium, Domain.EvidenceMode evidenceMode) throws ExceptionHugin
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.
ExceptionHugin
public void resetInferenceEngine() throws ExceptionHugin
ExceptionHugin
public void retractFindings() throws ExceptionHugin
ExceptionHugin
public void save(java.lang.String fileName, NetworkModel.Endian format) throws ExceptionHugin
fileName
- the name of the file to which the HKB is saved.format
- byte-order in the saved file.
ExceptionHugin
public void saveAsKB(java.lang.String fileName, java.lang.String password) throws ExceptionHugin
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.
fileName
- the name of the file to which the HKB is saved.password
- which, if non-null, will be needed upon reloading the file.
ExceptionHugin
public void saveAsHKB(java.lang.String fileName, java.lang.String password) throws ExceptionHugin
ExceptionHugin
public void saveToMemory() throws ExceptionHugin
ExceptionHugin
public void writeNet(java.lang.String fileName) throws ExceptionHugin
ExceptionHugin
public void simulate() throws ExceptionHugin
ExceptionHugin
public void seedRandom(int seed) throws ExceptionHugin
seed
- the seed number.
ExceptionHugin
public void seedRandom(long seed) throws ExceptionHugin
ExceptionHugin
public boolean tablesToPropagate() throws ExceptionHugin
ExceptionHugin
public void triangulate(Domain.TriangulationMethod method) throws ExceptionHugin
method
- the TriangulationMethod used.
ExceptionHugin
public void triangulateWithOrder(NodeList order) throws ExceptionHugin
order
- a NodeList containing the Nodes of the network
in the order of elimination.
ExceptionHugin
public void unCompile() throws ExceptionHugin
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.
ExceptionHugin
public void setConcurrencyLevel(int level) throws ExceptionHugin
level
- the level of concurrency.
ExceptionHugin
public void setGrainSize(int size) throws ExceptionHugin
The initial value of the grain size parameter is 10000.
size
- the grain size.
ExceptionHugin
public int getConcurrencyLevel() throws ExceptionHugin
ExceptionHugin
setConcurrencyLevel
public int getGrainSize() throws ExceptionHugin
ExceptionHugin
public double getLogNormalizationConstant() throws ExceptionHugin
ExceptionHugin
public void setNumberOfCases(int size) throws ExceptionHugin
ExceptionHugin
public int newCase() throws ExceptionHugin
ExceptionHugin
public int getNumberOfCases() throws ExceptionHugin
ExceptionHugin
public void setCaseCount(int c, double count) throws ExceptionHugin
c
- the case for which to set the count.count
- the multiplicity of 'c'.
ExceptionHugin
public double getCaseCount(int c) throws ExceptionHugin
c
- the case for which to get the count.
ExceptionHugin
public void learnTables() throws ExceptionHugin
ExceptionHugin
public void learnClassTables() throws ExceptionHugin
ExceptionHugin
public double getLogLikelihood() throws ExceptionHugin
ExceptionHugin
public void setLogLikelihoodTolerance(double tolerance) throws ExceptionHugin
ExceptionHugin
public double getLogLikelihoodTolerance() throws ExceptionHugin
ExceptionHugin
public void setMaxNumberOfEMIterations(int m) throws ExceptionHugin
ExceptionHugin
public int getMaxNumberOfEMIterations() throws ExceptionHugin
ExceptionHugin
public void adapt() throws ExceptionHugin
ExceptionHugin
public void learnStructure() throws ExceptionHugin
ExceptionHugin
public void setSignificanceLevel(double alpha) throws ExceptionHugin
alpha
- the significance level.
ExceptionHugin
public double getSignificanceLevel() throws ExceptionHugin
ExceptionHugin
public void setMaxNumberOfSeparators(int m) throws ExceptionHugin
ExceptionHugin
public int getMaxNumberOfSeparators() throws ExceptionHugin
ExceptionHugin
public void parseCase(java.lang.String fileName, ParseListener parseListener) throws ExceptionHugin
fileName
and enters
the associated findings into this Domain. All existing
evidence in the Domain is retracted before entering the case
findings.
fileName
- the name of the file containing the case.parseListener
- the ParseListener used for handling
parse errors.
ExceptionHugin
public void saveCase(java.lang.String fileName) throws ExceptionHugin
fileName
(if the file exists, it is overwritten).
fileName
- the name of the file in which the case is going
to be saved.
ExceptionHugin
public void saveCases(java.lang.String fileName, NodeList nodes, int[] cases, boolean caseCounts, java.lang.String separator, java.lang.String missingData) throws ExceptionHugin
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 filecases
- 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 filemissingData
- The string used to represent missing data
ExceptionHugin
public void parseCases(java.lang.String fileName, ParseListener parseListener) throws ExceptionHugin
fileName
and enters
the cases into this Domain.
fileName
- the name of the file containing the cases.parseListener
- the ParseListener used for handling
parse errors.
ExceptionHugin
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |