JavaScript for HUGIN Web Service API

Description

The JavaScript for HUGIN Web Service API provides a scripting interface to the HUGIN Web Service API for using HUGIN in a browser context.  The API is a wrapper for the functionality provided by the HUGIN Web Service API, and translates any function calls into proper HTTP requests for exercising the remote decision engine and throwing errors appropriately when a function call fails.

Cross-domain scripting limitation

Due to limitations imposed by the browser security model, cross-origin HTTP requests are not supported in full.  This means that the JavaScript for HUGIN Web Service API can only bind to the HUGIN Web Service API iff the webpage which the script is running on and the HUGIN Web Service API is served from the same host (hostname+port).  This means that a simple proxy must be set up such that the web server which serves the web page forwards any HUGIN requests to the correct host/port serving the HUGIN Web Service API.

Caching

As any function invocation results in a HTTP request, the result of any idempotent function call is cached.  The cache is wiped when invoking a function with side effects.  Note: If the state of any resource is updated outside of javascript code, it is imperative to wipe the cache in order to reflect updated state (see HAPI.refetch).

How to make a HUGIN proxy for Apache+PHP web server configuration

  • Create a directory on the web server called ‘webservice’
  • In the ‘webservice’ directory, create a file ‘hugin.php’ with the contents of following code snippet
  • This is the contents of the ‘hugin.php’ script, configure $WEBSERVICE_HOST and $WEBSERVICE_PORT appropriately to point at the RESTful HUGIN Web Service API:
<?php
//NOTE:
//Apache AcceptPathInfo directive must be set to 'on' in order for this script to work!
//php.ini must have allow_url_fopen = On

//Address of HUGIN Web Service which request should be forwarded to
$WEBSERVICE_HOST = "127.0.0.1";
$WEBSERVICE_PORT = 8080;

$url = substr($_SERVER['REQUEST_URI'], strlen($_SERVER["SCRIPT_NAME"]));
$request_method = $_SERVER['REQUEST_METHOD'];
if ($request_method == 'GET' || $request_method == 'POST') {
  @$fp = fsockopen($WEBSERVICE_HOST, $WEBSERVICE_PORT, $errno, $errstr, 30);
  if (!$fp) {
    header("HTTP/1.1 404 Bad Request");
    echo "$errstr ($errno)<br />\n";
  } else {
    $out = '';
    if ($request_method == 'GET')
      $out .= "GET " . $url . " HTTP/1.1\r\n";
    else
      $out .= "POST " . $url . " HTTP/1.1\r\n";
    $out .= "Host: " . $WEBSERVICE_HOST . "\r\n";
    foreach (getallheaders() as $name => $value) {
      if ($name != "Connection" && $name != "Host")
        $out .= "$name: $value\r\n";
    }
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    if ($request_method == 'POST')
      fwrite($fp, file_get_contents('php://input'));
    $emptylines = 0;
    while (!feof($fp)) {
      $hs = fgets($fp, 128);
      if ($hs != "\r\n") {
        header($hs, true);
      } else {
        $emptylines++;
        if ($emptylines==1)
        break;
      }
    }
    $contents = '';
    while (!feof($fp))
      $contents .= fread($fp, 8192);
    fclose($fp);
    echo $contents;
  }
}
?>

Including the JavaScript library

To use the JavaScript for HUGIN Web Service API the .js library must be included.  Add the following to the <HEAD></HEAD> part of the HTML page (“/webservice/hugin.php” is the path to the HUGIN proxy script introduced above):

<head>
..
<script src="/webservice/hugin.php/hugin.js" type="text/javascript"></script>
..
</head>

Example scripting

The HUGIN library can then be exercised within any <script></script> tag:

<body>
..
<script type="text/javascript">
try {
  //create a new HAPI instance
  hapi = new HAPI("/webservice/hugin.php");

  //create a new Domain instance
  domain = hapi.getNewDomain();

  //create a node in the domain
  A = domain.getNewNode(HAPI.H_CATEGORY_CHANCE, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_NUMBER);
  A.setName("A");
  A.setNumberOfStates(3);
  A.setStateValue(0, 10);
  A.setStateValue(1, 20);
  A.setStateValue(2, 30);
  ..
} catch (e) {
  alert("An error occurred: " + e.name + "\n" + e.message);
}
</script>
..
</body>

For information on using HUGIN Widgets in conjunction with the JavaScript for HUGIN Web Service API on a web page see HUGIN Widgets Library.

Error Handling

When a HUGIN function invocation fails an error object is thrown.  Errors may be thrown due to a number of reasons such as pre-conditions for invoking the function was not met, wrong parameters, the HUGIN object may have already been deleted/garbage collected etc.  Catching and dealing with error objects is a natural part of exercising the JavaScript for HUGIN Web Service API.

Invocation of HUGIN functions should be appropriately wrapped in error handling code using the try/catch JavaScript construct.  Any error object can be inspected by looking at the error.name and error.message members.

Example

try {
  //code that invoke HUGIN function
} catch (e) {
  //deal with this error condition
}
Summary
JavaScript for HUGIN Web Service APIThe JavaScript for HUGIN Web Service API provides a scripting interface to the HUGIN Web Service API for using HUGIN in a browser context.
HAPIThe HAPI class is a container for all functionality in the JavaScript for HUGIN Web Service API.
Functions
HAPIInitializes a new instance of the HAPI class and binds it internally to the RESTful HUGIN Web Service API.
getNewClassCollectionConstruct an empty classcollection.
loadClassCollectionConstruct a classcollection from a HUGIN Knowledge Base retrieved over HTTP.
loadDomainInstantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.
loadCompileDomainInstantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.
getNewDomainConstructs a new empty Domain.
loadDataSetInstantiate a DataSet from a CSV file retrieved over HTTP.
getNewDataSetConstruct an empty DataSet.
refetchRefetch cached responses from remote decision engine.
getNewBatchConstructs a new Batch object.
BatchA Batch can be used to group together a sequence of batchable function calls and then carry out the function calls using a single HTTP request - effectively saving the round-trip-time delay of having to perform individual HTTP requests for each function.
Functions
getHAPIGet the HAPI object that owns this Batch
resetReset the Batch.
addAdd a function call to the Batch queue.
executeExecute the queued up function calls in a synchronously blocking fashion.
dispatchDispatch execution of queued up function calls in an asynchronously non-blocking fashion.
ClassCollectionClasses are grouped into ClassCollections.
Functions
getHAPIGet the HAPI object that owns this ClassCollection
deleteObjectDeletes this ClassCollection object, including all nested HUGIN objects belonging to it (e.g.
getClassByNameReturns a Class by name.
getMembersGet all Classes of this ClassCollection.
saveSubmits this ClassCollection in the form of a HKB file to the service located at a target URL.
downloadGenerate an URL for downloading this ClassCollection as a HKB file
getNewClassCreates a new Class.
NetworkModelNetworkModel interface is implemented by Class and Domain.
Functions
getHAPIGet the HAPI object that owns this NetworkModel
getNodeByNameReturns a Node by name.
getNewNodeCreates a new Node.
getNodesGet all Nodes in this NetworkModel.
generateTablesGenerates the conditional probability tables for all nodes of this NetworkModel.
getAttributeReturns an attribute value.
parseNodesParses the file retrieved from an URL and returns a list of Nodes.
setAttributeInserts the key/value pair in the attribute list for this NetworkModel.
ClassInstances of Class represent object-oriented Bayesian networks and LIMIDs.
Functions
deleteObjectDeletes this Class, including all Node objects belonging to it.
createDBNDomainCreates a DBN runtime Domain from this Class.
createDomainCreates a flat runtime Domain from this Class.
getNewInstanceNodeCreates a new instance Node.
getClassCollectionGet the ClassCollection to which this Class belongs.
getInputsGet all input Nodes defined for this Class.
getInstancesGet all instance Nodes that are instances of this Class.
getOutputsGet all output Nodes defined for this Class.
getNameReturns the name of this Class.
setNameSets the name of this Class.
DomainInstances of the Domain class represent Bayesian networks and LIMIDs in which you can propagate evidence and calculate updated beliefs and expected utilities.
Functions
deleteObjectDeletes this Domain, including all Node and JunctionTree objects belonging to it.
parseCaseParses a case retrieved from an URL and enters the associated findings into this Domain.
saveCaseSubmits all evidence entered in this Domain to the service located at a target URL.
saveSubmits this Domain in the form of a HKB file to the service located at a target URL.
downloadGenerate an URL for downloading this Domain as a HKB file
parseCasesParses the cases retrieved form an URL and enters the cases into this Domain.
saveCasesSubmits all cases in this Domain to the service located at a target URL.
propagateEstablishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all JunctionTrees of this Domain.
compileCompiles this Domain.
adaptAdapts this Domain according to the evidence entered.
adaptClassTablesUsingFractionalUpdateFor each discrete node of this Domain (which must be a runtime domain) such that both the node and its source node have experience tables, the conditional probability and experience tables of both nodes are learned/updated, and the tables of the domain node will be identical to those of its source node.
adaptClassTablesUsingOnlineEMThis function updates (adapts), for all discrete chance nodes of this Domain, the experience count (retrieval of experience) and the conditional probability distribution (dissemination of experience) for all parent configurations having a valid experience count.
approximateRemoves “near-zero” probabilities from the clique probability tables.
cgEvidenceIsPropagatedCheck if evidence on CG nodes has been propagated.
evidenceIsPropagatedTests if evidence has been propagated for this Domain.
evidenceToPropagateTests if evidence has been entered since the last propagation.
retractFindingsRetracts (all) evidence for all nodes in this Domain.
getNewModelConstructs a Model over a Node given a list of Nodes.
getExpectedUtilityGets the total expected utility associated with this Domain.
isCompiledTests whether this Domain is compiled.
isTriangulatedTests whether this Domain is triangulated.
isTriangulatedForBKTests whether this Domain has been triangulated for Boyen-Koller approximate inference.
initializeEstablishes the initial values for all tables of this Domain (which must be compiled).
getJunctionTreesGets all JunctionTrees of this Domain.
compressRemoves the zero entries from the clique and separator tables of the junction trees in this Domain.
computeSensitivityDataComputes the constants of the sensitivity functions for the specified output probabilities and all CPT parameters in the network.
getLogLikelihoodComputes the log-likelihood of the case data.
getLogLikelihoodToleranceReturns the log-likelihood tolerance for this Domain.
getLogNormalizationConstantReturns the log of the normalization constant.
getMAPConfigurationReturns a MAP configuration.
getMarginalComputes the marginal distribution for the Nodes provided as argument with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTrees of this Domain.
getMaxNumberOfEMIterationsReturns the maximum number of iterations allowed for the EM algorithm.
getMaxNumberOfSeparatorsReturns the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.
getNormalDeviateUse the pseudo-random number generator for this Domain to sample a real number from a normal (aka Gaussian) distribution.
getNormalizationConstantRetrieves the normalization constant for the most recent propagation.
getNumberOfCasesReturns the number of data cases.
getNumberOfMAPConfigurationsReturns the number of MAP configurations.
getProbabilityOfMAPConfigurationReturns the probability of a MAP configuration.
getSensitivitySetReturns the sensitivity set computed by the most recent call to Domain.computeSensitivityData.
getSignificanceLevelReturns the significance level of the dependency tests performed during structure learning using the PC-algorithm.
getUniformDeviateUse the pseudo-random number generator for this Domain to sample a real number from the uniform distribution over the interval [0,1).
enterCaseEnters a case as evidence.
equilibriumIsTests the Equilibrium type.
isCompressedTests whether this Domain is compressed.
evidenceModeIsTests for evidence mode.
learnStructureLearn the structure (graph) of the Bayesian network from data using the PC-algorithm.
learnTablesLearns the conditional probability tables from data using the EM algorithm.
likelihoodIsPropagatedTests if likelihood has been propagated for this Domain
newCaseCreates a new case.
findMAPConfigurationsFinds all configurations of nodes with probability at least minprobability.
getAICComputes the AIC score (Akaike’s Information Criterion) of the case data.
getApproximationConstantReturns the approximation constant.
getBICComputes the BIC score (Bayesian Information Criterion) of the case data.
getCaseCountReturns case count for a case.
getConflictReturns the conflict value.
getDConnectedNodesPerforms a d-separation test and returns a list of d-connected nodes.
getDSeparatedNodesPerforms a d-separation test and returns a list of d-separated nodes.
getEliminationOrderReturns the triangulation order.
resetInferenceEngineEstablishes the initial state of the inference engine, which is sum-equilibrium with no evidence incorporated.
saveToMemoryCreates a copy in memory of the belief and junction tree tables of this Domain.
seedRandomSeeds the pseudo-random number generator for this Domain.
setCaseCountSets case count for a case.
setLogLikelihoodToleranceSets the log-likelihood tolerance for this Domain.
setMaxNumberOfEMIterationsSets the maximum number of iterations allowed for the EM algorithm.
setMaxNumberOfSeparatorsSets the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.
setNumberOfCasesSets the number of cases.
setSignificanceLevelSets the significance level of the dependency tests performed during structure learning using the PC-algorithm.
simulateGenerates a sample configuration from the joint distribution represented by this Domain.
batchSimulateGenerates a number of sample configurations by invoking Domain.simulate a number of times and for each iteration recording the results of Node.getSampledValue, Node.getSampledState or Node.getSampledUtility for specified Nodes.
tablesToPropagateTests for new node tables.
triangulateTriangulates the graph of this Domain using the default triangulation method.
uncompileUncompiles this Domain.
updatePoliciesUpdates the policy tables of the domain.
getExplanationReturns the evidence subset associated with the explanation of rank index computed by the most recent call to Node.computeExplanationData.
getExplanationScoreReturns the score of the specified explanation.
getNumberOfExplanationsReturns the number of explanations.
addCasesAdds the specified range of rows of the data set to this Domain as cases.
triangulateTriangulates the graph of this Domain using the specified triangulation method.
computeDBNPredictionsComputes predictions for {numberOfTimePoints} time slices beyond the current time window.
getDBNWindowOffsetReturns the total number of time steps that the time window of this DBN runtime domain has been moved.
initializeDBNWindowMoves the time window of this DBN back to its initial position, and removes all evidence.
moveDBNWindowSlides the time window of this DBN delta steps into the future.
triangulateDBNTriangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.
triangulateDBNForBKTriangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.
NodeNodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs.
Functions
getHAPIGet the HAPI object that owns this Node
deleteObjectDeletes this Node.
getModelGets the Model for this Node.
getNameReturns the name of this Node.
setNameSets the name of this Node.
setPositionSets the position of this Node.
getPositionXReturns the position of this Node on the X-axis.
getPositionYReturns the position of this Node on the Y-axis.
setNumberOfStatesSets the number of states of this node.
getNumberOfStatesGet the number of states of this discrete node.
setStateLabelSets the label of the specified state.
getStateLabelGets the label of the specified state.
getTableGets the Table associated with this Node.
getBeliefGets the belief for the specified state of this Node.
getParentsGet an array of parent Nodes for this Node.
getChildrenGet an array of child Nodes for this Node.
addParentAdds a Node as a new parent of this Node.
selectStateSelects the specified state of this Node.
getSelectedStateGets (the index of) the selected state of this node.
retractFindingsRetracts all findings for this Node.
getExpectedUtilityGets the expected utility associated with this utility node or specified action of this discrete node.
getSampledUtilityReturns the sampled utility associated with this utility node.
getValueGets the value of this FunctionNode.
setValueSets the function associated with this function node to a number value.
evidenceIsEnteredTest if the evidence potential, currently registered with this Node, is non-vacuous.
getStateIndexGet the index of the state matching the specified value.
getStateValueGets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.
setStateValueSets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.
enterValueEnters evidence (observation of the value) for this continuous chance node.
getEnteredValueGets the evidence (value) entered for this continuous chance node.
evidenceIsPropagatedReturns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is non-vacuous; otherwise, returns false.
evidenceToPropagateReturns true if the entered and the propagated evidence differ; otherwise, returns false.
getAttributeReturns an attribute value.
getCategoryReturns the category of this Node.
getEdgeConstraintReturns the constraint between this and Node.
getHomeDomainReturns the Domain containing this Node.
getJunctionTreeReturns the JunctionTree to which this Node belongs.
getKindReturns the kind of this Node.
getSubtypeReturns the subtype of this Node.
getLabelReturns the label of this Node.
likelihoodIsPropagatedReturns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is a likelihood; otherwise, returns false.
likelihoodIsEnteredReturns true if the evidence potential, currently registered with this Node, is a likelihood; otherwise, returns false.
removeParentRemoves the directed link between a parent and this Node.
reverseEdgeReverses the edge between this Node and the specified neighbor.
setAttributeSets a value for a particular attribute in the attribute list for this Node.
setEdgeConstraintSets a constraint between this Node and another Node.
setLabelSets the label of this Node.
switchParentReplace the given parent node with the new node.
caseIsSetReturns true if a value has been set for this continuous chance or discete node in case caseindex; otherwise, returns false.
getAlphaReturns the alpha component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.
getBetaReturns the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.
getCaseValueReturns the value set for this continuous chance node in case caseindex.
getDistributionReturns the distribution for this continuous node.
getExperienceTableReturns the experience table of this continuous or discrete chance node.
getGammaReturns the gamma component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.
getMeanReturns the mean of the marginal distribution of this continuous chance node.
getPropagatedValueRetrieves the value that has been propagated for this continuous chance Node.
getSampledValueReturns the value of this function or continuous chance Node for the configuration generated by the most recent call to Domain.simulate.
getVarianceReturns the variance of the marginal distribution of this continuous chance Node.
hasExperienceTableReturns true if this continuous or discrete chance Node has an experience table; returns false otherwise.
setAlphaSets the alpha component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.
setBetaSets the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.
setCaseValueSets the value of this continuous chance node to value in case c.
setGammaSets the gamma component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.
unsetCaseSpecifies that the value of this continuous chance or discrete node is “unknown” for case caseindex.
computeSensitivityDataComputes the constants of the sensitivity functions for the specified output probability and all CPT/policy parameters in the network.
getFadingTableReturns the fading table of this discrete chance node.
hasFadingTableReturns true if this discrete chance Node has a fading table; returns false otherwise.
getRequisiteAncestorsGet an array of Nodes containing the requisite ancestors of this decision Node.
getRequisiteParentsGet an array of Nodes containing the requisite parents of this decision Node.
enterFindingSpecifies a finding value for a given state with all other states unaffected.
generateTableGenerates the table of this discrete Node from its Model (a missing Model will trigger an error).
getCaseStateReturns the state of this discrete node for case c.
getEnteredFindingReturns the entered finding for the specified state of this node.
getEntropyComputes the entropy of this node.
getMutualInformationComputes the mutual information between this discrete Node and the specified discrete Node.
getPropagatedFindingReturns the propagated finding.
getSampledStateReturns the state index of this discrete node for the configuration generated by the most recent call to Domain.simulate.
getSensitivityConstantsReturns the four constants of the specified sensitivity function.
getSensitivityConstantsByOutputReturns the four constants of the specified sensitivity function.
setCaseStateSets the state of this discrete node to state in case c.
getStateIndexFromLabelReturns the index of the state matching the specified label.
computeExplanationDataComputes Bayes factor data for all (nonempty) subsets of evidence nodes up to the specified maximum size.
computeExplanationData2Computes “normalized likelihoods” for the specified hypothesis and all (nonempty) subsets of evidence nodes up to the specified maximum size.
addToInputsMakes this Node become an input node of its Class.
addToOutputsMakes this Node become an output node of its Class.
createTemporalCloneConstructs a temporal clone of this Node.
getHomeReturns the NetworkModel containing this Node.
getHomeClassReturns the Class containing this Node.
getInstanceReturns the instance Node containing this (cloned) output node.
getMasterReturns the “master” of this (cloned) output Node of an instance node (i.e., the node cloned to get this output node).
getSourceGet an array of Nodes of Class nodes that identifies this Domain node.
getTemporalCloneGet the “temporal clone” of this Node.
getTemporalMasterGet the “temporal master” of this Node.
removeFromInputsRemoves this Node from the set of input nodes of its class.
removeFromOutputsRemoves this Node from the set of output nodes of its class.
getPredictedBeliefReturns the predicted belief for the specified state of this discrete Node at the specified time point.
getPredictedValueGets the predicted value of this FunctionNode at the specified time point.
getPredictedMeanReturns the predicted mean of the marginal distribution of this continuous chance node at the specified time point.
getPredictedVarianceReturns the predicted variance of the marginal distribution of this continuous chance node at the specified time point.
TableHugin uses Tables for representing the conditional probability and utility potentials of individual Nodes, the probability and utility potentials on separators and Cliques of JunctionTrees, evidence potentials, etc.
Functions
getHAPIGet the HAPI object that owns this Table
deleteObjectDeletes this Table.
getSizeGet the size of this Table.
getNodesGet all Nodes associated with this Table.
getDataItemGet the data item at position index of the discrete data of this Table.
setDataItemSets a specific data item of the discrete data of this Table.
setDataSets a region of the discrete data of this Table.
getDataGets a region of the discrete data of this Table.
getMeanGet the mean of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.
getVarianceGet the variance of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.
getCovarianceGet the covariance of a pair of continuous chance Nodes given a configuration of the discrete chance Nodes of this Table.
computeProbabilityOfIntervalCompute the probability of a given interval for the mixture distribution represented by this Table.
reorderNodesReorders the list of Nodes of this Table.
getCGSizeReturns the CG size of this Table.
setAllDataItemsSets all data items of the discrete data of this Table.
ModelA Model is a compact description of a table.
Functions
getHAPIGet the HAPI object that owns this Model
deleteObjectDeletes this Model.
setExpressionAssociates an expression (specified as a string) with a specific configuration of the Nodes of this Model.
getExpressionReturns the expression (as a string) associated with a specific configuration of the NodeResources of this ModelResource.
setNumberOfSamplesPerIntervalSets the number of values taken within each bounded interval of an interval parent when generating the conditional probability table for a node with interval parents.
getNumberOfSamplesPerIntervalGets the number of values per interval used when generating the conditional probability table for a node with interval parents.
getSizeReturns the number of configurations of the Node of this Model.
getNodesGet all Nodes in this Model.
CliqueCliques represents the cliques in the junction tree.
Functions
getHAPIGet the HAPI object that owns this Clique
getJunctionTreeGet the JunctionTree to which this Clique belongs.
getMembersGet the list of Nodes that are members of this Clique.
getNeighborsGet a list of Cliques that are neighbors of this Clique.
JunctionTreeJunctionTrees represents the junction trees in the compiled Domain.
Functions
getHAPIGet the HAPI object that owns this JunctionTree
cgEvidenceIsPropagatedCheck if CG evidence has been propagated in this JunctionTree.
equilibriumIsTests the Equilibrium type.
evidenceIsPropagatedTests if evidence has been propagated for this JunctionTree.
evidenceModeIsTests the EvidenceMode.
evidenceToPropagateTests if evidence has been entered since the last propagation.
getCliquesGet the list of Cliques in this JunctionTree.
getConflictGet the conflict measure of the data inserted in this JunctionTree.
getRootGet the root Clique of this JunctionTree.
getTotalCGSizeGet the total number of CG table entries for this JunctionTree.
getTotalSizeGet the total number of discrete table configurations for this JunctionTree.
likelihoodIsPropagatedTests if likelihoods have been propagated in this JunctionTree.
tablesToPropagateTests if this JunctionTree contains updated tables that have not been propagated.
propagatePropagates evidence in this JunctionTree.
DataSetInstances of the DataSet represents a data set as a “matrix” with cases as rows and variables as columns.
Functions
getHAPIGet the HAPI object that owns this DataSet
deleteObjectDeletes this DataSet.
deleteColumnDeletes the specified column from this DataSet.
deleteRowDeletes the specified row from this DataSet.
getColumnNameReturns the name of the specified column of this DataSet.
getDataItemReturns the data item at the specified location of this DataSet.
getNumberOfColumnsReturns the number of columns in this DataSet.
getNumberOfRowsReturns the number of rows in this DataSet.
moveColumnMoves the specified column to a new position.
moveRowMoves the specified row to a new position.
newColumnCreates a new column in this DataSet.
newRowCreates a new row in this DataSet.
setColumnNameSets the name of the specified column of this DataSet.
setDataItemSets (or deletes) the data item at the specified location of this DataSet.
saveSubmits this DataSet in the form of a CSV file to the service located at a target URL.
downloadGenerate an URL for downloading this DataSet as a CSV file
Globals
Constants
HAPI.H_CONSTRAINT_BACKWARD_EDGE_FORBIDDENRepresents the domain knowledge that a directed edge is forbidden from the second to the first Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_BACKWARD_EDGE_REQUIREDRepresents the domain knowledge that a directed edge is required from the second to the first Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_EDGE_FORBIDDENRepresents the domain knowledge that an edge is forbidden between a particular pair of Nodes.
HAPI.H_CONSTRAINT_EDGE_REQUIREDRepresents the domain knowledge that an edge is required for a particular pair of Nodes.
HAPI.H_CONSTRAINT_FORWARD_EDGE_FORBIDDENRepresents the domain knowledge that a directed edge is forbidden from the first to the second Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_FORWARD_EDGE_REQUIREDRepresents the domain knowledge that a directed edge is required from the first to the second Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_NONERepresents that no domain knowledge is available for a particular pair of Nodes.
HAPI.H_TM_BEST_GREEDYRepresents the best-greedy triangulation heuristic.
HAPI.H_TM_CLIQUE_SIZERepresents the clique-size triangulation heuristic.
HAPI.H_TM_CLIQUE_WEIGHTRepresents the clique-weight triangulation heuristic.
HAPI.H_TM_FILL_IN_SIZERepresents the fill-in-size triangulation heuristic.
HAPI.H_TM_FILL_IN_WEIGHTRepresents the fill-in-weight triangulation heuristic.
HAPI.H_TM_TOTAL_WEIGHTRepresents the total clique-table size triangulation algorithm.
HAPI.H_EVIDENCE_MODE_NORMALRepresents the normal evidence mode used for propagating evidence in this Domain.
HAPI.H_EVIDENCE_MODE_FAST_RETRACTIONRepresents the fast retraction evidence mode used for propagating evidence in this Domain.
HAPI.H_EQUILIBRIUM_MAXRepresents max equilibrium.
HAPI.H_EQUILIBRIUM_SUMRepresents sum equilibrium.
HAPI.H_CATEGORY_DECISIONRepresents the Category tag attached to DecisionNodes.
HAPI.H_CATEGORY_FUNCTIONRepresents the Category tag attached to FunctionNodes.
HAPI.H_CATEGORY_UTILITYRepresents the Category tag attached to UtilityNodes.
HAPI.H_CATEGORY_CHANCERepresents the Category tag attached to ChanceNodes.
HAPI.H_CATEGORY_INSTANCERepresents the Category tag attached to InstanceNodes.
HAPI.H_KIND_CONTINUOUSRepresents the Kind tag attached to continuous nodes.
HAPI.H_KIND_DISCRETERepresents the Kind tag attached to discrete nodes.
HAPI.H_KIND_OTHERRepresents the Kind tag attached to utility, function, and instance nodes.
HAPI.H_SUBTYPE_NUMBERRepresents the discrete node subtype for numbered nodes
HAPI.H_SUBTYPE_INTERVALRepresents the discrete node subtype for interval nodes
HAPI.H_SUBTYPE_BOOLEANRepresents the discrete node subtype for boolean nodes
HAPI.H_SUBTYPE_LABELRepresents the discrete node subtype for labelled nodes
HAPI.H_SUBTYPE_OTHERSubtype placeholder for specifying node other than discrete.

HAPI

The HAPI class is a container for all functionality in the JavaScript for HUGIN Web Service API.

Summary
Functions
HAPIInitializes a new instance of the HAPI class and binds it internally to the RESTful HUGIN Web Service API.
getNewClassCollectionConstruct an empty classcollection.
loadClassCollectionConstruct a classcollection from a HUGIN Knowledge Base retrieved over HTTP.
loadDomainInstantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.
loadCompileDomainInstantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.
getNewDomainConstructs a new empty Domain.
loadDataSetInstantiate a DataSet from a CSV file retrieved over HTTP.
getNewDataSetConstruct an empty DataSet.
refetchRefetch cached responses from remote decision engine.
getNewBatchConstructs a new Batch object.

Functions

HAPI

function HAPI(webServiceHome)

Initializes a new instance of the HAPI class and binds it internally to the RESTful HUGIN Web Service API.

Parameters

webServiceHomethe base uri for reaching the RESTful HUGIN Web Service API (e.g.  “/webservice/hugin.php”).

Returns

a HAPI instance that internally is bound to the HTTP interface provided by the HUGIN Web Service API.

Examples

  • Constructing a HAPI instance bound to a HUGIN Web Service API at /webservice/hugin.php which is served by the same host which the web page was loaded from:
h = new HAPI("/webservice/hugin.php");
  • Or we can supply the complete url for reaching the HUGIN Web Service API
h = new HAPI("http://myhost/webservice/hugin.php");

Important Note: Currently the JavaScript for HUGIN Web Service API require the RESTful HUGIN Web Service API and the web page executing scripts be served from the same host (hostname+port).  This is due to limitations regarding cross-origin requests imposed by the browser security model

getNewClassCollection

this.getNewClassCollection = function getNewClassCollection()

Construct an empty classcollection.

Returns

a ClassCollection object

Example

cc = h.getNetClassCollection();

loadClassCollection

this.loadClassCollection = function loadClassCollection(url)

Construct a classcollection from a HUGIN Knowledge Base retrieved over HTTP.

Parameters

urlThe URL where the HUGIN Knowledge Base (HKB) file is to be read from

Returns

a ClassCollection object

Example

cc = h.loadClassCollection("http://somehost/files/cc.hkb");

loadDomain

this.loadDomain = function loadDomain(url)

Instantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.

Parameters

urlThe URL where the HUGIN Knowledge Base (HKB) file is to be read from

Returns

a Domain object

Example

  • Creating Domain objects from HKB files located at different URLs:
domain1 = h.loadDomain("http://somehost/files/asia.hkb");
domain2 = h.loadDomain("http://anotherhost/cars.hkb");

loadCompileDomain

this.loadCompileDomain = function loadCompileDomain(url)

Instantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.  If the HKB file is a Domain stored in a compressed state, a sum,normal-propagation is performed, otherwise compile is invoked.

Parameters

urlThe URL where the HUGIN Knowledge Base (HKB) file is to be read from

Returns

a Domain object

Example

  • Creating Domain objects from HKB files located at different URLs:
domain1 = h.loadCompileDomain("http://somehost/files/asia.hkb");
domain2 = h.loadCompileDomain("http://anotherhost/cars.hkb");

getNewDomain

this.getNewDomain = function getNewDomain()

Constructs a new empty Domain.

Returns

a Domain object

Example

dom = h.getNewDomain();

loadDataSet

this.loadDataSet = function loadDataSet(url,
delimiter)

Instantiate a DataSet from a CSV file retrieved over HTTP.

Parameters

urlThe URL where the CSV file is to be read from
delimiterthe delimiter symbol used in the CSV file

Returns

a DataSet object

Example

  • Creating DataSet objects from CSV files located at different URLs:
data1 = h.loadDataSet("http://somehost/files/file1.csv", ",");
data2 = h.loadDataSet("http://somehost/files/file2.csv", ",");

getNewDataSet

this.getNewDataSet = function getNewDataSet()

Construct an empty DataSet.

Returns

a DataSet object

Example

data = h.getNewDataSet();

refetch

this.refetch = function refetch(huginObject)

Refetch cached responses from remote decision engine.  This is necessary if state has been updated outside of javascript code (e.g. by an external server script).

Parameters

huginObjectthe root hugin object whose state is not up to date, a ClassCollection or Domain

Returns

void

Example

  • Refetch cached state of Domain ‘dom, ‘h’ is a HAPI instance.
h.refetch(dom);

getNewBatch

this.getNewBatch = function getNewBatch()

Constructs a new Batch object.

Returns

a Batch object

Example

  • Create an new Batch object:
b = h.getNewBatch();

Batch

A Batch can be used to group together a sequence of batchable function calls and then carry out the function calls using a single HTTP request - effectively saving the round-trip-time delay of having to perform individual HTTP requests for each function.  Clever use of this function could significantly speed up the web application.

In the current implementation a batchable function is a function with side-effects that returns void.  As a consequence when batching multiple function calls together, if a function call produces an error we loose the ability to track exactly which specific function that failed.

When asynchronously dispatching a Batch it is the responsibility of the programmer to properly synchronize access to depending HUGIN resources until the call has returned.  Exercising functions on these HUGIN resources while the batch is executing is undefined.

To acquire a Batch use the HAPI.getNewBatch function.

Example usage

  • Enter evidence on multiple nodes, induce as few HTTP requests as possible
//procedure performed using the normal function calls
//d is domain A and B and C are nodes
A.selectState(0);                                                 //performs 1 HTTP post request
B.selectState(2);                                                 //performs 1 HTTP post request
C.selectState(2);                                                 //performs 1 HTTP post request
d.propagate(HAPI.H_EQUILIBRIUM_SUM, HAPI.H_EVIDENCE_MODE_NORMAL); //performs 1 HTTP post request
//total number of HTTP requests = 4

//procedure performed using batch functionality
batch = hapi.getNewBatch();                                                   //performs 0 HTTP post request
batch.add(A.selectState, 0);                                                 //performs 0 HTTP post request
batch.add(B.selectState, 2);                                                 //performs 0 HTTP post request
batch.add(C.selectState, 2);                                                 //performs 0 HTTP post request
batch.add(d.propagate, HAPI.H_EQUILIBRIUM_SUM, HAPI.H_EVIDENCE_MODE_NORMAL); //performs 0 HTTP post request
batch.execute();                                                             //performs 1 HTTP post request
//total number of HTTP requests = 1
Summary
Functions
getHAPIGet the HAPI object that owns this Batch
resetReset the Batch.
addAdd a function call to the Batch queue.
executeExecute the queued up function calls in a synchronously blocking fashion.
dispatchDispatch execution of queued up function calls in an asynchronously non-blocking fashion.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this Batch

Returns

the owning HAPI instancs.

reset

this.reset = function reset()

Reset the Batch.  Discard any queued up function calls.  Or turn a ‘used’ Batch instance into vanilla Batch object again for re-using.

Returns

void

Example

b.reset();

add

this.add = function add(command //,
 arg1,
 arg2,
 arg3,
 ...,
 argN)

Add a function call to the Batch queue.  This is done by passing a reference to the function on a specific HUGIN object instance and supplying any arguments that the function would need when invoked normally.

Parameters

commandfunction reference on specific HUGIN object instance.
arg1, arg2, arg3, ..., argNthe list of arguments for command.

Returns

void

Example

  • add a function call to Batch, select state function on node instance A
//normal function call
A.selectState(0);

//append similar function call to batch
b.add(A.selectState, 0);

execute

this.execute = function execute()

Execute the queued up function calls in a synchronously blocking fashion.

If any of the batched function calls fails then Batch.execute() throws an error and further execution the batch is cancelled.

Returns

void

Example

  • execute functions queued up in Batch b:
b.execute();

dispatch

this.dispatch = function dispatch(onSuccess,
onError)

Dispatch execution of queued up function calls in an asynchronously non-blocking fashion.  This means that invocation of Batch.dispatch() may return immediately.  When the batch has finished execution user code is notified through user supplied callback functions.

Parameters

onSuccessa callback function(), invoked if the batch is carried out with no errors.
onErrora callback function(error), invoked if one of the batched function calls fails.

Returns

void

Example

  • Batch a number of functions and propagate domain, when batch completes retrieve beliefs.
//onSuccess and onError are the user callback functions
function onSuccess() {
  //actions to perform when batch completes: retrieve beliefs from domain, update user interface or other stuff.
  //...
}

function onError(error) {
  //one of the function calls produced an error
  alert("An error occurred: " + e.name + "\n" + e.message);
}

//queueing up function calls and dispatching batch
batch = dom.getNewBatch();
batch.add(...); //queue up a number of batchable calls
batch.add(d.propagate, HAPI.H_EQUILIBRIUM_SUM, HAPI.H_EVIDENCE_MODE_NORMAL); //last function is propagate
batch.dispatch(onSuccess, onError);

ClassCollection

Classes are grouped into ClassCollections.  Each class must belong to exactly one ClassCollection.  A ClassCollection can be considered a closed world of interdependent Classes (i.e., Bayesian networks and LIMIDs).  That is, each Class may contain instances of other Classes of the ClassCollection, but not of Classes of other ClassCollections.

Several operations are supported for ClassCollection

  • Create and delete
  • Saving to a HKB file URL
  • Retrieval of the list of Class objects
  • Retrieval of a Class object by its name

A ClassCollection is instantiated using one of the HAPI classcollection functions HAPI.getNewClassCollection or HAPI.loadClassCollection.

Summary
Functions
getHAPIGet the HAPI object that owns this ClassCollection
deleteObjectDeletes this ClassCollection object, including all nested HUGIN objects belonging to it (e.g.
getClassByNameReturns a Class by name.
getMembersGet all Classes of this ClassCollection.
saveSubmits this ClassCollection in the form of a HKB file to the service located at a target URL.
downloadGenerate an URL for downloading this ClassCollection as a HKB file
getNewClassCreates a new Class.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this ClassCollection

Returns

the owning HAPI instancs.

deleteObject

this.deleteObject = function deleteObject()

Deletes this ClassCollection object, including all nested HUGIN objects belonging to it (e.g.  Classes, Nodes, Tables etc.).

Returns

void

Example

cc.deleteObject();

getClassByName

this.getClassByName = function getClassByName(name)

Returns a Class by name.

Parameters

namename of the class to get.

Returns

Class

Example

  • Get Class by name ‘class1’:
class1 = cc.getClassByName("class1");

getMembers

this.getMembers = function getMembers()

Get all Classes of this ClassCollection.

Returns

An array of Classes in this ClassCollection.

Example

memberList = cc.getMembers();

save

this.save = function save(url,
method)

Submits this ClassCollection in the form of a HKB file to the service located at a target URL.

Parameters

urlthe URL to submit HKB file
methodthe HTTP method to use: POST | PUT

Returns

void

Example

cc.save("http://somehost/someservice", "POST");

download

this.download = function download(filename)

Generate an URL for downloading this ClassCollection as a HKB file

Parameters

filenameused for setting the Content-Disposition filename header of response.

Returns

the URL as a string

Example

  • generate an URL for downloading ClassCollection object ‘cc’ as a HKB file:
url = cc.download("classes.hkb");

getNewClass

this.getNewClass = function getNewClass(name)

Creates a new Class.

Parameters

namethe name of the new class.

Returns

Class

Example

  • Create a new Class named ‘myClass’:
cls = cc.getNewClass("myClass");

NetworkModel

NetworkModel interface is implemented by Class and Domain.  A NetworkModel cannot be instantiated explicitly; use Domain and Class.

Summary
Functions
getHAPIGet the HAPI object that owns this NetworkModel
getNodeByNameReturns a Node by name.
getNewNodeCreates a new Node.
getNodesGet all Nodes in this NetworkModel.
generateTablesGenerates the conditional probability tables for all nodes of this NetworkModel.
getAttributeReturns an attribute value.
parseNodesParses the file retrieved from an URL and returns a list of Nodes.
setAttributeInserts the key/value pair in the attribute list for this NetworkModel.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this NetworkModel

Returns

the owning HAPI instancs.

Example

ownerHapi = dom.getHAPI();

getNodeByName

this.getNodeByName = function getNodeByName(name)

Returns a Node by name.  If no node by the given name exists, an exception is thrown.

Parameters

namename of the node to get.

Returns

Node

Example

  • Get Node by name ‘C1’:
c1 = net.getNodeByName("C1");

getNewNode

this.getNewNode = function getNewNode(category,
kind,
subtype)

Creates a new Node.  The specifics of the node created depends on the category, kind and subtype specified.

Parameters

categorythe node category, see HAPI.H_CATEGORY_CHANCE, HAPI.H_CATEGORY_DECISION, HAPI.H_CATEGORY_UTILITY, HAPI.H_CATEGORY_FUNCTION.
kindthe node kind, see HAPI.H_KIND_DISCRETE, HAPI.H_KIND_CONTINUOUS, HAPI.H_KIND_OTHER.
subtypethe node subtype, see HAPI.H_SUBTYPE_LABEL, HAPI.H_SUBTYPE_BOOLEAN, HAPI.H_SUBTYPE_NUMBER, HAPI.H_SUBTYPE_INTERVAL, HAPI.H_SUBTYPE_OTHER.

Returns

Node

Example

  • Create a new labelled discrete chance node:
n = net.getNewNode(HAPI.H_CATEGORY_CHANCE, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_LABEL);
  • Create a new boolean discrete chance node:
n = net.getNewNode(HAPI.H_CATEGORY_CHANCE, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_BOOLEAN);
  • Create a new numbered discrete chance node:
n = net.getNewNode(HAPI.H_CATEGORY_CHANCE, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_NUMBER);
  • Create a new interval discrete chance node:
n = net.getNewNode(HAPI.H_CATEGORY_CHANCE, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_INTERVAL);
  • Create a new labelled decision node:
n = net.getNewNode(HAPI.H_CATEGORY_DECISION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_LABEL);
  • Create a new boolean decision node:
n = net.getNewNode(HAPI.H_CATEGORY_DECISION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_BOOLEAN);
  • Create a new numbered decision node:
n = net.getNewNode(HAPI.H_CATEGORY_DECISION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_NUMBER);
  • Create a new interval decision node:
n = net.getNewNode(HAPI.H_CATEGORY_DECISION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_INTERVAL);
  • Create a new labelled function node:
n = net.getNewNode(HAPI.H_CATEGORY_FUNCTION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_LABEL);
  • Create a new boolean function node:
n = net.getNewNode(HAPI.H_CATEGORY_FUNCTION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_BOOLEAN);
  • Create a new numbered function node:
n = net.getNewNode(HAPI.H_CATEGORY_FUNCTION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_NUMBER);
  • Create a new interval function node:
n = net.getNewNode(HAPI.H_CATEGORY_FUNCTION, HAPI.H_KIND_DISCRETE, HAPI.H_SUBTYPE_INTERVAL);
  • Create a new continuous chance node:
n = net.getNewNode(HAPI.H_CATEGORY_CHANCE, HAPI.H_KIND_CONTINUOUS, HAPI.H_SUBTYPE_OTHER);
  • Create a new utility node:
n = net.getNewNode(HAPI.H_CATEGORY_UTILITY, HAPI.H_KIND_OTHER, HAPI.H_SUBTYPE_OTHER);
  • Create a new function node:
n = net.getNewNode(HAPI.H_CATEGORY_FUNCTION, HAPI.H_KIND_OTHER, HAPI.H_SUBTYPE_OTHER);

getNodes

this.getNodes = function getNodes()

Get all Nodes in this NetworkModel.

Returns

An array of Nodes in NetworkModel.

Example

  • get an array of all Nodes in networkmodel ‘net’:
nodes = net.getNodes();

generateTables

this.generateTables = function generateTables()

Generates the conditional probability tables for all nodes of this NetworkModel.  This is done by calling Node.generateTable for all nodes having a model, so the descriptions of the Node.generateTable function (for discrete and utility nodes) also apply here.

Returns

void

Example

net.generateTables();

getAttribute

this.getAttribute = function getAttribute(key)

Returns an attribute value.  That is, the value associated with a key in the attribute list for this NetworkModel.

Parameters

keythe key for which the attribute value is returned

Returns

a string

Example

  • get the attribute value associated with key ‘myattribute’ in NetworkModel ‘net’:
val = net.getAttribute("myattribute");

parseNodes

this.parseNodes = function parseNodes(url)

Parses the file retrieved from an URL and returns a list of Nodes.  This is used for reading an elimination order from an external URL.

Parameters

urlURL to the file with node names

Returns

An array of Nodes

Example

  • Parse the list of node names retrieved from an URL:
net.parseNodes("http://somehost/files/eliminationorder.txt");

setAttribute

this.setAttribute = function setAttribute(key,
value)

Inserts the key/value pair in the attribute list for this NetworkModel.  If the key is already defined, the value is updated.  If no value is provided, the attribute is removed.

Parameters

keyThe key identifying the attribute to be updated.
valueThe value of the attribute.

Returns

void

Example

  • Set the value ‘abc’ for key ‘A’ in NetworkModel ‘net’:
net.setAttribute("A", "abc");

Class

Instances of Class represent object-oriented Bayesian networks and LIMIDs.  Such an instance can contain nodes representing instances of other network classes and so on.  To use an instance (i.e., propagate evidence and calculate updated beliefs and expected utilities), it must first be unfolded to a plain Bayesian network or LIMID.  The Class.createDomain function handles this.

A Class is instantiated using ClassCollection.getNewClass.

Summary
Functions
deleteObjectDeletes this Class, including all Node objects belonging to it.
createDBNDomainCreates a DBN runtime Domain from this Class.
createDomainCreates a flat runtime Domain from this Class.
getNewInstanceNodeCreates a new instance Node.
getClassCollectionGet the ClassCollection to which this Class belongs.
getInputsGet all input Nodes defined for this Class.
getInstancesGet all instance Nodes that are instances of this Class.
getOutputsGet all output Nodes defined for this Class.
getNameReturns the name of this Class.
setNameSets the name of this Class.

Functions

deleteObject

this.deleteObject = function deleteObject()

Deletes this Class, including all Node objects belonging to it.

Returns

void

Example

  • Delete the Class object ‘cls’:
cls.deleteObject();

createDBNDomain

this.createDBNDomain = function createDBNDomain(numberOfSlices)

Creates a DBN runtime Domain from this Class.  The domain is formed by linking (through temporal clones) the specified number of instances (called time slices) of the class.

Parameters

numberOfSlicesthe number of time slices; an integer.

Returns

a Domain

Example

  • unfold Class ‘cls’ to a DBN domain with 5 time slices:
dom = cls.createDBNDomain(5);

createDomain

this.createDomain = function createDomain()

Creates a flat runtime Domain from this Class.  The domain can be compiled and used for inference, etc.

Returns

a Domain

Example

  • unfold Class ‘cls’ to a flat runtime domain:
dom = cls.createDomain();

getNewInstanceNode

this.getNewInstanceNode = function getNewInstanceNode(instanceOf)

Creates a new instance Node.

Parameters

instanceOfthe Class from which to instantiate the new instance node.

Returns

a Node

Example

inode = cls.getNewInstanceNode(ofCls);

getClassCollection

this.getClassCollection = function getClassCollection()

Get the ClassCollection to which this Class belongs.

Returns

the containing ClassCollection

Example

cc = cls.getClassCollection();

getInputs

this.getInputs = function getInputs()

Get all input Nodes defined for this Class.

Returns

An array of Nodes.

Example

nodes = cls.getInputs();

getInstances

this.getInstances = function getInstances()

Get all instance Nodes that are instances of this Class.

Returns

An array of Nodes.

Example

  • get all instance Nodes that are instances of Class ‘cls’:
nodes = cls.getInstances();

getOutputs

this.getOutputs = function getOutputs()

Get all output Nodes defined for this Class.

Returns

An array of Nodes.

Example

nodes = cls.getOutputs();

getName

this.getName = function getName()

Returns the name of this Class.

Returns

string containing the name of this Class.

Example

clsName = cls.getName();

setName

this.setName = function setName(name)

Sets the name of this Class.  The name must be valid, i.e., it must follow the rules that govern the validity of C identifiers, and no other Class in the ClassCollection must have the same name.

Parameters

namea string containing the new name of the Class

Returns

void

Example

cls.setName("myClass");

Domain

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

A Domain is instantiated using one of the HAPI domain functions HAPI.loadDomain or HAPI.getNewDomain.

Summary
Functions
deleteObjectDeletes this Domain, including all Node and JunctionTree objects belonging to it.
parseCaseParses a case retrieved from an URL and enters the associated findings into this Domain.
saveCaseSubmits all evidence entered in this Domain to the service located at a target URL.
saveSubmits this Domain in the form of a HKB file to the service located at a target URL.
downloadGenerate an URL for downloading this Domain as a HKB file
parseCasesParses the cases retrieved form an URL and enters the cases into this Domain.
saveCasesSubmits all cases in this Domain to the service located at a target URL.
propagateEstablishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all JunctionTrees of this Domain.
compileCompiles this Domain.
adaptAdapts this Domain according to the evidence entered.
adaptClassTablesUsingFractionalUpdateFor each discrete node of this Domain (which must be a runtime domain) such that both the node and its source node have experience tables, the conditional probability and experience tables of both nodes are learned/updated, and the tables of the domain node will be identical to those of its source node.
adaptClassTablesUsingOnlineEMThis function updates (adapts), for all discrete chance nodes of this Domain, the experience count (retrieval of experience) and the conditional probability distribution (dissemination of experience) for all parent configurations having a valid experience count.
approximateRemoves “near-zero” probabilities from the clique probability tables.
cgEvidenceIsPropagatedCheck if evidence on CG nodes has been propagated.
evidenceIsPropagatedTests if evidence has been propagated for this Domain.
evidenceToPropagateTests if evidence has been entered since the last propagation.
retractFindingsRetracts (all) evidence for all nodes in this Domain.
getNewModelConstructs a Model over a Node given a list of Nodes.
getExpectedUtilityGets the total expected utility associated with this Domain.
isCompiledTests whether this Domain is compiled.
isTriangulatedTests whether this Domain is triangulated.
isTriangulatedForBKTests whether this Domain has been triangulated for Boyen-Koller approximate inference.
initializeEstablishes the initial values for all tables of this Domain (which must be compiled).
getJunctionTreesGets all JunctionTrees of this Domain.
compressRemoves the zero entries from the clique and separator tables of the junction trees in this Domain.
computeSensitivityDataComputes the constants of the sensitivity functions for the specified output probabilities and all CPT parameters in the network.
getLogLikelihoodComputes the log-likelihood of the case data.
getLogLikelihoodToleranceReturns the log-likelihood tolerance for this Domain.
getLogNormalizationConstantReturns the log of the normalization constant.
getMAPConfigurationReturns a MAP configuration.
getMarginalComputes the marginal distribution for the Nodes provided as argument with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTrees of this Domain.
getMaxNumberOfEMIterationsReturns the maximum number of iterations allowed for the EM algorithm.
getMaxNumberOfSeparatorsReturns the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.
getNormalDeviateUse the pseudo-random number generator for this Domain to sample a real number from a normal (aka Gaussian) distribution.
getNormalizationConstantRetrieves the normalization constant for the most recent propagation.
getNumberOfCasesReturns the number of data cases.
getNumberOfMAPConfigurationsReturns the number of MAP configurations.
getProbabilityOfMAPConfigurationReturns the probability of a MAP configuration.
getSensitivitySetReturns the sensitivity set computed by the most recent call to Domain.computeSensitivityData.
getSignificanceLevelReturns the significance level of the dependency tests performed during structure learning using the PC-algorithm.
getUniformDeviateUse the pseudo-random number generator for this Domain to sample a real number from the uniform distribution over the interval [0,1).
enterCaseEnters a case as evidence.
equilibriumIsTests the Equilibrium type.
isCompressedTests whether this Domain is compressed.
evidenceModeIsTests for evidence mode.
learnStructureLearn the structure (graph) of the Bayesian network from data using the PC-algorithm.
learnTablesLearns the conditional probability tables from data using the EM algorithm.
likelihoodIsPropagatedTests if likelihood has been propagated for this Domain
newCaseCreates a new case.
findMAPConfigurationsFinds all configurations of nodes with probability at least minprobability.
getAICComputes the AIC score (Akaike’s Information Criterion) of the case data.
getApproximationConstantReturns the approximation constant.
getBICComputes the BIC score (Bayesian Information Criterion) of the case data.
getCaseCountReturns case count for a case.
getConflictReturns the conflict value.
getDConnectedNodesPerforms a d-separation test and returns a list of d-connected nodes.
getDSeparatedNodesPerforms a d-separation test and returns a list of d-separated nodes.
getEliminationOrderReturns the triangulation order.
resetInferenceEngineEstablishes the initial state of the inference engine, which is sum-equilibrium with no evidence incorporated.
saveToMemoryCreates a copy in memory of the belief and junction tree tables of this Domain.
seedRandomSeeds the pseudo-random number generator for this Domain.
setCaseCountSets case count for a case.
setLogLikelihoodToleranceSets the log-likelihood tolerance for this Domain.
setMaxNumberOfEMIterationsSets the maximum number of iterations allowed for the EM algorithm.
setMaxNumberOfSeparatorsSets the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.
setNumberOfCasesSets the number of cases.
setSignificanceLevelSets the significance level of the dependency tests performed during structure learning using the PC-algorithm.
simulateGenerates a sample configuration from the joint distribution represented by this Domain.
batchSimulateGenerates a number of sample configurations by invoking Domain.simulate a number of times and for each iteration recording the results of Node.getSampledValue, Node.getSampledState or Node.getSampledUtility for specified Nodes.
tablesToPropagateTests for new node tables.
triangulateTriangulates the graph of this Domain using the default triangulation method.
uncompileUncompiles this Domain.
updatePoliciesUpdates the policy tables of the domain.
getExplanationReturns the evidence subset associated with the explanation of rank index computed by the most recent call to Node.computeExplanationData.
getExplanationScoreReturns the score of the specified explanation.
getNumberOfExplanationsReturns the number of explanations.
addCasesAdds the specified range of rows of the data set to this Domain as cases.
triangulateTriangulates the graph of this Domain using the specified triangulation method.
computeDBNPredictionsComputes predictions for {numberOfTimePoints} time slices beyond the current time window.
getDBNWindowOffsetReturns the total number of time steps that the time window of this DBN runtime domain has been moved.
initializeDBNWindowMoves the time window of this DBN back to its initial position, and removes all evidence.
moveDBNWindowSlides the time window of this DBN delta steps into the future.
triangulateDBNTriangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.
triangulateDBNForBKTriangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.

Functions

deleteObject

this.deleteObject = function deleteObject()

Deletes this Domain, including all Node and JunctionTree objects belonging to it.

Returns

void

Example

  • Delete the Domain object ‘dom’:
dom.deleteObject();

parseCase

this.parseCase = function parseCase(url)

Parses a case retrieved from an URL and enters the associated findings into this Domain.  All existing evidence in the Domain is retracted before entering the case findings.  Contents of the retrieved ressource must conform to the HUGIN case file grammar as defined in the HUGIN API manual (api-manual.pdf).

Parameters

urlThe URL where the HUGIN case file is to be read from

Returns

void

Example

  • Parse a case retrieved from an URL:
dom.parseCase("http://somehost/files/casefile.hcf");

saveCase

this.saveCase = function saveCase(url,
method)

Submits all evidence entered in this Domain to the service located at a target URL.  Submittet contents conforms to the HUGIN case file grammar as defined in the HUGIN API manual (api-manual.pdf).

Parameters

urlthe URL to submit case file
methodthe HTTP method to use: POST | PUT

Returns

void

Example

dom.saveCase("http://somehost/someservice", "POST");

save

this.save = function save(url,
method)

Submits this Domain in the form of a HKB file to the service located at a target URL.

Parameters

urlthe URL to submit HKB file
methodthe HTTP method to use: POST | PUT

Returns

void

Example

dom.save("http://somehost/someservice", "POST");

download

this.download = function download(filename)

Generate an URL for downloading this Domain as a HKB file

Parameters

filenameused for setting the Content-Disposition filename header of response.

Returns

the URL as a string

Example

  • generate an URL for downloading Domain object ‘dom’ as a HKB file:
url = dom.download("network.hkb");

parseCases

this.parseCases = function parseCases(url)

Parses the cases retrieved form an URL and enters the cases into this Domain.  Contents of the retrieved ressource must conform to the HUGIN data file grammar as defined in the HUGIN API manual (api-manual.pdf).

Parameters

urlThe URL where the HUGIN data file is to be read from

Returns

void

Example

  • Parse a data file retrieved from an URL:
dom.parseCases("http://somehost/files/cases.dat");

saveCases

this.saveCases = function saveCases(url,
method,
nodes,
cases,
caseCounts,
separator,
missingData)

Submits all cases in this Domain to the service located at a target URL.  Submittet contents uses specified separator between data items and missingData for missing data; and otherwise conforms to the HUGIN data file grammar as defined in the HUGIN API manual (api-manual.pdf)

Parameters

urlthe URL to submit case file
methodthe HTTP method to use: POST | PUT
nodesa list of all nodes which are to be included in the file; an array of Nodes.
casesan array of integers specifying the case indexes of cases to be included in the file.  Note: passing null or an empty array for this parameter will include all cases.
caseCountsboolean value.  If true, include case counts in the data file.  If false, only include case counts if they are present in the Domain.
separatorthe string used to seperate the items in the file
missingDatathe string used to represent missing data

Returns

void

Example

nodes = dom.getNodes();
dom.saveCase("http://somehost/someservice", "POST", nodes, null, false, ",", "");

propagate

this.propagate = function propagate(equilibrium,
evidenceMode)

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

equilibriumEquilibrium type.  The normal Equilibrium type is HAPI.H_EQUILIBRIUM_SUM.
evidenceModeEvidenceMode type.  The normal EvidenceMode type is HAPI.H_EVIDENCE_MODE_NORMAL.

Returns

void

Example

  • Propagate evidence in domain ‘dom’:
dom.propagate(HAPI.H_EQUILIBRIUM_SUM, HAPI.H_EVIDENCE_MODE_NORMAL);

compile

this.compile = function compile()

Compiles this Domain.  The domain must not be compiled.  The default triangulation method is used (unless the domain is already triangulated, in which case the existing triangulation is used).

Returns

void

Example

  • Compile domain ‘dom’:
dom.compile();

adapt

this.adapt = function adapt()

Adapts this Domain according to the evidence entered.

Returns

void

Example

  • Adapt using evidence entered in domain ‘dom’:
dom.adapt();

adaptClassTablesUsingFractionalUpdate

this.adaptClassTablesUsingFractionalUpdate = function adaptClassTablesUsingFractionalUpdate()

For each discrete node of this Domain (which must be a runtime domain) such that both the node and its source node have experience tables, the conditional probability and experience tables of both nodes are learned/updated, and the tables of the domain node will be identical to those of its source node.

Nodes (in this domain or in the object-oriented model) without experience tables will not be modified.

This function updates (adapts), for all discrete nodes.

Returns

void

Example

  • Adapt class tables using fractional update in domain ‘dom’:
dom.adaptClassTablesUsingFractionalUpdate();

adaptClassTablesUsingOnlineEM

this.adaptClassTablesUsingOnlineEM = function adaptClassTablesUsingOnlineEM()

This function updates (adapts), for all discrete chance nodes of this Domain, the experience count (retrieval of experience) and the conditional probability distribution (dissemination of experience) for all parent configurations having a valid experience count.  (Fading factors are ignored.)

The alpha argument and the total experience determine the learning rate of the update step.

Parameters

alphathe parameter to be used for online EM (a real number).

Returns

void

Example

  • Adapt class tables using online EM in domain ‘dom’:
dom.adaptClassTablesUsingOnlineEM(0.5);

approximate

this.approximate = function approximate(epsilon)

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

epsilonthe 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 - epsilon, as the epsilon value is relative to each clique.  Typically, the amount of probability mass removed will be somewhat larger than epsilon.

Example

  • Approximate domain ‘dom’ with a threshold of 0.01:
remainProbMass = dom.approximate(0.01);

cgEvidenceIsPropagated

this.cgEvidenceIsPropagated = function cgEvidenceIsPropagated()

Check if evidence on CG nodes has been propagated.

Returns

Returns true if evidence on CG nodes has been propagated; otherwise, returns false.

Example

  • Check if evidence on CG nodes in domain ‘dom’ has been propagated:
cgIsPropagated = dom.cgEvidenceIsPropagated();

evidenceIsPropagated

this.evidenceIsPropagated = function evidenceIsPropagated()

Tests if evidence has been propagated for this Domain.

Returns

Returns true if evidence has been propagated; otherwise, returns false.

Example

  • Check if evidence in domain ‘dom’ has been propagated:
evidenceIsPropagated = dom.evidenceIsPropagated();

evidenceToPropagate

this.evidenceToPropagate = function evidenceToPropagate()

Tests if evidence has been entered since the last propagation.

Returns

Returns true if evidence has been entered since the last propagation; otherwise, returns false.

Example

  • Check if domain ‘dom’ has evidence to propagate:
result = dom.evidenceToPropagate();

retractFindings

this.retractFindings = function retractFindings()

Retracts (all) evidence for all nodes in this Domain.

Notice: Only possible for discrete and continuous nodes.

Returns

void

Example

  • retract findings in domain ‘dom’:
dom.retractFindings();

getNewModel

this.getNewModel = function getNewModel(belongsTo,
modelNodes)

Constructs a Model over a Node given a list of Nodes.

Parameters

belongsTothe Node that the new Model belongs to.
modelNodesa list of any model nodes for the new Model; an array of Nodes.

Returns

Model

Example

  • create a new Model for boolean node ‘b’ with model nodes ‘c’ and ‘d’:
modelNodes = [c, d];
model = dom.getNewModel(b, modelNodes);

getExpectedUtility

this.getExpectedUtility = function getExpectedUtility()

Gets the total expected utility associated with this Domain.

Notice: Only possible for utility and discrete nodes.

Returns

A real number representing the expected utility.

Example

  • get expected utility associated with domain ‘dom’:
util = dom.getExpectedUtility();

isCompiled

this.isCompiled = function isCompiled()

Tests whether this Domain is compiled.  A domain is “compiled” if it is triangulated and junction tree tables are created.

Returns

Returns true if Domain is compiled; otherwise, returns false.

Example

  • Test if domain ‘dom’ is compiled:
compiled = dom.isCompiled();

isTriangulated

this.isTriangulated = function isTriangulated()

Tests whether this Domain is triangulated.  Being “triangulated” means that the junction forest has been created, but not the associated tables.

Returns

Returns true if Domain is triangulated; otherwise, returns false.

Example

  • Test if domain ‘dom’ is triangulated:
triangulated = dom.isTriangulated();

isTriangulatedForBK

this.isTriangulatedForBK = function isTriangulatedForBK()

Tests whether this Domain has been triangulated for Boyen-Koller approximate inference.  That is, has this Domain been triangulated using Domain.triangulateDBNForBK.

Returns

Returns true if Domain is triangulated for Boyen-Koller; otherwise, returns false.

Example

  • Test if domain ‘dom’ is triangulated for Boyen-Koller:
triangulated = dom.isTriangulatedForBK();

initialize

this.initialize = function initialize()

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

Returns

void

Example

  • initialize domain ‘dom’:
dom.initialize();

getJunctionTrees

this.getJunctionTrees = function getJunctionTrees()

Gets all JunctionTrees of this Domain.

Returns

An array of JunctionTrees in this Domain.

Example

trees = dom.getJunctionTrees();

compress

this.compress = function compress()

Removes the zero entries from the clique and separator tables of the junction trees 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

void

Example

  • compress domain ‘dom’:
dom.compress();

computeSensitivityData

this.computeSensitivityData = function computeSensitivityData(nodes,
states)

Computes the constants of the sensitivity functions for the specified output probabilities and all CPT parameters in the network.  The output probabilities are specified using a list of nodes and a list of corresponding states.

Parameters

nodesthe list of (output) nodes; an array of Nodes.
statesa list of states of the nodes in the nodes list; an array of state indices (integers).

Returns

void

Example

  • Compute sensitivity data in domain ‘dom’ for output probabilities of node ‘A’ in state 0 and ‘B’ in state 2:
nodes = [A, B];
states = [0, 2];
dom.computeSensitivityData(nodes, states);

getLogLikelihood

this.getLogLikelihood = function getLogLikelihood()

Computes the log-likelihood of the case data.

Returns

A real number representing the log-likelihood of the case data.

Example

  • get log-likelihood of the case data in domain ‘dom’:
ll = dom.getLogLikelihood();

getLogLikelihoodTolerance

this.getLogLikelihoodTolerance = function getLogLikelihoodTolerance()

Returns the log-likelihood tolerance for this Domain.

Returns

A real number representing the log-likelihood tolerance.

Example

  • get log-likelihood tolerance for domain ‘dom’:
llt = dom.getLogLikelihoodTolerance();

getLogNormalizationConstant

this.getLogNormalizationConstant = function getLogNormalizationConstant()

Returns the log of the normalization constant.

Returns

A real number representing the log of the normalization constant.

Example

  • get log of normalization constant for domain ‘dom’:
lnc = dom.getLogNormalizationConstant();

getMAPConfiguration

this.getMAPConfiguration = function getMAPConfiguration(index)

Returns a MAP configuration.  This method returns the configuration identified by index among the configurations with probability at least minProbability - as specified in the most recent successful call to Domain.findMAPConfigurations.

The index argument must be a nonnegative integer less than Domain.getNumberOfMAPConfigurations: 0 requests the most probable configuration, 1 the second-most probable configuration, etc.

Parameters

indexidentifies the configuration; an integer.

Returns

an array of state indexes forming the configuration of the Nodes passed to Domain.findMAPConfigurations.

Example

  • get most probable MAP configuration:
configuration = dom.getMAPConfiguration(0);

getMarginal

this.getMarginal = function getMarginal(nodes)

Computes the marginal distribution for the Nodes provided as argument with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTrees of this Domain.  If nodes contains continuous nodes, they must be last in the list.  This operation is not allowed on compressed domains.

Parameters

nodeslist of Nodes over which to compute the marginal; an array of Nodes.

Returns

A Table containing the marginal distribution over the Nodes in nodes.

Example

  • get the marginal for Nodes ‘A’ , ‘B’ and ‘C’:
nodes = [A, B, C];
tbl = domain.getMarginal(nodes);

getMaxNumberOfEMIterations

this.getMaxNumberOfEMIterations = function getMaxNumberOfEMIterations()

Returns the maximum number of iterations allowed for the EM algorithm.

Returns

the maximum number of iterations allowed for the EM algorithm; an integer.

Example

  • get maximum number of EM iterations for domain ‘dom’:
maxiter = dom.getMaxNumberOfEMIterations();

getMaxNumberOfSeparators

this.getMaxNumberOfSeparators = function getMaxNumberOfSeparators()

Returns the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.

Returns

the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method; an integer.

Example

  • get maximum number of separators for domain ‘dom’:
maxsep = dom.getMaxNumberOfSeparators();

getNormalDeviate

this.getNormalDeviate = function getNormalDeviate(mean,
variance)

Use the pseudo-random number generator for this Domain to sample a real number from a normal (aka Gaussian) distribution.

Parameters

meanthe mean of the distribution; a real number.
variancethe variance of the distribution ; a real number.

Returns

real number

Example

  • get the normal deviate using mean=1 and variance=2:
nd = domain.getNormalDeviate(1, 2);

getNormalizationConstant

this.getNormalizationConstant = function getNormalizationConstant()

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

real number

Example

  • get the normalization constant for the most recent propagation in Domain ‘dom’:
nc = dom.getNormalizationConstant();

getNumberOfCases

this.getNumberOfCases = function getNumberOfCases()

Returns the number of data cases.

Returns

an integer; the number of data cases.

Example

  • get the number of cases in Domain ‘dom’:
numcases = dom.getNumberOfCases();

getNumberOfMAPConfigurations

this.getNumberOfMAPConfigurations = function getNumberOfMAPConfigurations()

Returns the number of MAP configurations.  This method returns the number of configurations found by the most recent successful call to Domain.findMAPConfigurations.

Returns

an integer.

Example

  • get the number of MAP configurations in Domain ‘dom’:
numconf = dom.getNumberOfMAPConfigurations();

getProbabilityOfMAPConfiguration

this.getProbabilityOfMAPConfiguration = function getProbabilityOfMAPConfiguration(
   index
)

Returns the probability of a MAP configuration.  This method returns the probability of the configuration returned by Domain.getMAPConfiguration

Parameters

indexidentifies the configuration; an integer.

Returns

a real number.

Example

  • get probability of MAP configuration 1:
prob = dom.getProbabilityOfMAPConfiguration(1);

getSensitivitySet

this.getSensitivitySet = function getSensitivitySet()

Returns the sensitivity set computed by the most recent call to Domain.computeSensitivityData.  If the results produced by that call have been invalidated, an error is thrown.

Returns

An array of Nodes.

Example

  • get sensitivity set:
nodes = dom.getSensitivitySet();

getSignificanceLevel

this.getSignificanceLevel = function getSignificanceLevel()

Returns the significance level of the dependency tests performed during structure learning using the PC-algorithm.  The default value is 0.05.

Returns

a real number.

Example

  • get significance level of dependency tests performed during structure learning using PC-algorithm:
siglevel = dom.getSignificanceLevel();

getUniformDeviate

this.getUniformDeviate = function getUniformDeviate()

Use the pseudo-random number generator for this Domain to sample a real number from the uniform distribution over the interval [0,1).

Returns

a real number.

Example

  • get uniform deviate:
unidev = dom.getUniformDeviate();

enterCase

this.enterCase = function enterCase(index)

Enters a case as evidence.

Parameters

indexcase index; an integer.

Returns

void

Example

  • enter case 10 in Domain ‘dom’:
dom.enterCase(10);

equilibriumIs

this.equilibriumIs = function equilibriumIs(equilibrium)

Tests the Equilibrium type.  Returns true if the equilibrium states of all JunctionTrees of this Domain are identical to equilibrium; otherwise, returns false.

Parameters

equilibriumthe type of Equilibrium to test for.  The normal Equilibrium type is HAPI.H_EQUILIBRIUM_SUM.

Returns

a boolean.  Returns true if the equilibrium states of all JunctionTrees of this Domain are identical to equilibrium; otherwise, returns false.

Example

result = dom.equilibriumIs(HAPI.H_EQUILIBRIUM_SUM);

isCompressed

this.isCompressed = function isCompressed()

Tests whether this Domain is compressed.

Returns

Returns true if Domain is compressed; otherwise, returns false.

Example

  • Test if domain ‘dom’ is compressed:
compiled = dom.isCompressed();

evidenceModeIs

this.evidenceModeIs = function evidenceModeIs(mode)

Tests for evidence mode.  Returns true if the equilibrium states of all JunctionTrees of this Domain could have been obtained through a propagation using mode as the evidence incorporation mode.  Otherwise, returns false.

Parameters

modethe type of EvidenceMode to test for.  The normal EvidenceMode type is HAPI.H_EVIDENCE_MODE_NORMAL.

Returns

a boolean.  Returns true if the equilibrium states of all JunctionTrees of this Domain could have been obtained through a propagation using mode as the evidence incorporation mode.  Otherwise, returns false.

Example

result = dom.evidenceModeIs(HAPI.H_EVIDENCE_MODE_NORMAL);

learnStructure

this.learnStructure = function learnStructure()

Learn the structure (graph) of the Bayesian network from data using the PC-algorithm.

Returns

void

Example

  • perform structure learning from cases in Domain ‘dom’ using PC-algorithm:
dom.learnStructure();

learnTables

this.learnTables = function learnTables()

Learns the conditional probability tables from data using the EM algorithm.

Returns

void

Example

  • perform EM on tables in Domain ‘dom’:
dom.learnTables();

likelihoodIsPropagated

this.likelihoodIsPropagated = function likelihoodIsPropagated()

Tests if likelihood has been propagated for this Domain

Returns

a boolean.  Returns true if likelihood has been propagated for this Domain; otherwise, returns false.

Example

  • Check if likelihood has been propagated for Domain ‘dom’:
likelihoodIsPropagated = dom.likelihoodIsPropagated();

newCase

this.newCase = function newCase()

Creates a new case.

Returns

an integer; the case index for the newly created case.

Example

  • create a new case in Domain ‘dom’:
caseindex = dom.newCase();

findMAPConfigurations

this.findMAPConfigurations = function findMAPConfigurations(nodes,
minprobability)

Finds all configurations of nodes with probability at least minprobability.  This method uses a Monte Carlo algorithm to solve a generalized form of the maximum a posteriori (MAP) configuration problem: The MAP configuration problem is the problem of finding the most probable configuration of a set of nodes given evidence on some of the remaining nodes.

The results of this method are provided by Domain.getNumberOfMAPConfigurations, Domain.getMAPConfiguration and Domain.getProbabilityOfMAPConfiguration.

Parameters

nodeslist of discrete Nodes for which to find configurations; an array of Nodes.
minprobabilityconfigurations with a lower probability than minprobability are ignored; a real number.

Returns

void

Example

  • find all configurations of discrete Nodes ‘A’ , ‘B’ and ‘C’ with a probablility of at least 0.5:
nodes = [A, B, C];
domain.findMAPConfigurations(nodes, 0.5);

getAIC

this.getAIC = function getAIC()

Computes the AIC score (Akaike’s Information Criterion) of the case data.

Returns

a real number.

Example

  • get AIC for case data in Domain ‘dom’:
score = dom.getAIC();

getApproximationConstant

this.getApproximationConstant = function getApproximationConstant()

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 Domain.getApproximationConstant.

Returns

a real number.

Example

  • get approximation constant in Domain ‘dom’:
approx = dom.getApproximationConstant();

getBIC

this.getBIC = function getBIC()

Computes the BIC score (Bayesian Information Criterion) of the case data.

Returns

a real number.

Example

  • get BIC for case data in Domain ‘dom’:
score = dom.getBIC();

getCaseCount

this.getCaseCount = function getCaseCount(caseindex)

Returns case count for a case.

Parameters

caseindexthe case for which to get the count.

Returns

a real number.  The multiplicity of case caseindex.

Example

  • get the case count for case 10 in Domain ‘dom’:
count = dom.getCaseCount(10);

getConflict

this.getConflict = function getConflict()

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 real number.

Example

  • get the conflict value computed during most recent propagation in Domain ‘dom’:
conf = dom.getConflict();

getDConnectedNodes

this.getDConnectedNodes = function getDConnectedNodes(source,
hard,
soft)

Performs a d-separation test and returns a list of d-connected nodes.  Assuming evidence on the specified evidence nodes, this method returns the list of nodes that are d-connected to the specified list of source nodes.

Parameters

sourcelist of source nodes; an array of Nodes.
hardlist of nodes assumed to be instantiated; an array of Nodes.
softlist of nodes assumed to have multi-state or likelihood evidence; an array of Nodes.

Returns

An array of Nodes.

Example

  • get d-connected nodes in Domain dom based on list of nodes in arrays source, hard and soft:
source = [ ... ];
hard = [ ... ];
soft = [ ... ];
nodes = dom.getDConnectedNodes(source, hard, soft);

getDSeparatedNodes

this.getDSeparatedNodes = function getDSeparatedNodes(source,
hard,
soft)

Performs a d-separation test and returns a list of d-separated nodes.  Assuming evidence on the specified evidence nodes, this method returns the list of nodes that are d-separated to the specified list of source nodes.

Parameters

sourcelist of source nodes; an array of Nodes.
hardlist of nodes assumed to be instantiated; an array of Nodes.
softlist of nodes assumed to have multi-state or likelihood evidence; an array of Nodes.

Returns

An array of Nodes.

Example

  • get d-seperated nodes in Domain dom based on list of nodes in arrays source, hard and soft:
source = [ ... ];
hard = [ ... ];
soft = [ ... ];
nodes = dom.getDSeparatedNodes(source, hard, soft);

getEliminationOrder

this.getEliminationOrder = function getEliminationOrder()

Returns the triangulation order.  A list of Nodes in the order used to triangulate the network of this Domain is returned.

Returns

An array of Nodes.

Example

  • get the elimination order used for triangulation of domain ‘dom’:
elim = dom.getEliminationOrder();

resetInferenceEngine

this.resetInferenceEngine = function resetInferenceEngine()

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 junction tree potentials, but entered evidence will still be “registered” (i.e., they will be incorporated in the next propagation).

Returns

void

Example

  • reset inference engine for Domain ‘dom’:
dom.resetInferenceEngine();

saveToMemory

this.saveToMemory = function saveToMemory()

Creates a copy in memory of the belief and junction tree tables of this Domain.  This operation can only be performed if the domain is compiled, the current equilibrium equals HAPI.H_EQUILIBRIUM_SUM, and no evidence has been incorporated.

Returns

void

Example

  • invoke saveToMemory on Domain ‘dom’:
dom.saveToMemory();

seedRandom

this.seedRandom = function seedRandom(seed)

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

seedthe seed; an integer.

Returns

void

Example

  • seed random generator for Domain ‘dom’ with the value ‘1000’:
dom.seedRandom(1000);

setCaseCount

this.setCaseCount = function setCaseCount(caseindex,
count)

Sets case count for a case.

Parameters

caseindexcase index; an integer.
countthe count; a real number.

Returns

void

Example

  • set case count to 2.5 for case 10 in Domain ‘dom’:
dom.setCaseCount(10, 2.5);

setLogLikelihoodTolerance

this.setLogLikelihoodTolerance = function setLogLikelihoodTolerance(tolerance)

Sets the log-likelihood tolerance for this Domain.

Parameters

tolerancea real number.

Returns

void

Example

  • set log-likelihood tolerance to 0.5 in Domain ‘dom’:
dom.setLogLikelihoodTolerance(0.5);

setMaxNumberOfEMIterations

this.setMaxNumberOfEMIterations = function setMaxNumberOfEMIterations(maxnumber)

Sets the maximum number of iterations allowed for the EM algorithm.  A value of 0 specifies an unbounded number of iterations.

Parameters

maxnumberan integer.

Returns

void

Example

  • set the maximum number of EM iterations to 10 in Domain ‘dom’:
dom.setMaxNumberOfEMIterations(10);

setMaxNumberOfSeparators

this.setMaxNumberOfSeparators = function setMaxNumberOfSeparators(maxnumber)

Sets the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.  A value of 0 specifies an unbounded number of separators.

Parameters

maxnumberan integer.

Returns

void

Example

  • set an infinite maximum number of separators in Domain ‘dom’:
dom.setMaxNumberOfSeparators(0);

setNumberOfCases

this.setNumberOfCases = function setNumberOfCases(size)

Sets the number of cases.

Parameters

sizean integer.

Returns

void

Example

  • set the number of cases to 100 in Domain ‘dom’:
dom.setNumberOfCases(100);

setSignificanceLevel

this.setSignificanceLevel = function setSignificanceLevel(alpha)

Sets the significance level of the dependency tests performed during structure learning using the PC-algorithm.  The default value is 0.05.

Parameters

alphaan integer.

Returns

void

Example

  • set the significance level of dependency tests performed during PC in Domain ‘dom’ to 0.1:
dom.setSignificanceLevel(0.1);

simulate

this.simulate = function simulate()

Generates a sample configuration from the joint distribution represented by 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 junction tree(s).  This distribution must be in sum-equilibrium with evidence incorporated in normal mode.

Returns

void

Example

  • sample a configuration in Domain ‘dom’:
dom.simulate();

batchSimulate

this.batchSimulate = function batchSimulate(iterations,
nodes)

Generates a number of sample configurations by invoking Domain.simulate a number of times and for each iteration recording the results of Node.getSampledValue, Node.getSampledState or Node.getSampledUtility for specified Nodes.

Parameters

iterationsthe number of times to invoke Domain.simulate and record results.
nodeslist of nodes to record the result of Node.getSampledValue, Node.getSampledState or Node.getSampledUtility for each Domain.simulate iteration.

Returns

{ node: [....], ...  }an associative array of nodes and simulated values.  Results are indexed on a [NODE][iteration] basis.

Example

  • sample ten configurations in Domain ‘dom’ and record results for nodes A and B:
A = dom.getNodeByName("A");
B = dom.getNodeByName("B");
result = dom.batchSimulate(10, [A, B]);

//display the Node.getSampledValue(), Node.getSampledState() or Node.getSampledUtility() result
//for node A from the fifth simulation iteration
alert(result[A][4]);

tablesToPropagate

this.tablesToPropagate = function tablesToPropagate()

Tests for new node tables.  Returns true if there is a node in this Domain having a (conditional probability, policy, or utility) table that has changed since the most recent compilation or propagation; otherwise, returns false.

Returns

a boolean

Example

  • check if Domain ‘dom’ contains any tables that have changed since most recent compilation or propagation:
result = dom.tablesToPropagate();

triangulate

this.triangulate = function triangulate()

Triangulates the graph of this Domain using the default triangulation method.

Returns

void

Example

dom.triangulate();

uncompile

this.uncompile = function uncompile()

Uncompiles this Domain.  Removes the data structures of the domain produced by a triangulation or a compilation.  Note that any references to objects within the compiled structure (e.g., Cliques and JunctionTrees) are invalidated (that is, any attempt to access the objects produce an error).  Also note that many of the editing functions automatically performs an uncompile operation.  When this happens, the domain must be compiled again before it can be used for inference.

Returns

void

Example

dom.uncompile();

updatePolicies

this.updatePolicies = function updatePolicies()

Updates the policy tables of the domain.  The policies of all unmade decisions are updated.  The new policies maximize the overall expected utility.

Returns

void

Example

  • update policies in Domain ‘dom’:
dom.updatePolicies();

getExplanation

this.getExplanation = function getExplanation(index)

Returns the evidence subset associated with the explanation of rank index computed by the most recent call to Node.computeExplanationData.

Parameters

indexspecifies that the indexth best explanation should be retrieved (the best explanation has index 0, the second best has index 1, etc.)

Returns

An array of Nodes.

getExplanationScore

this.getExplanationScore = function getExplanationScore(index)

Returns the score of the specified explanation.  This function returns the score associated with the explanation subset returned by Domain.getExplanation.

Parameters

indexidentifies the explanation.

Returns

A real number.

getNumberOfExplanations

this.getNumberOfExplanations = function getNumberOfExplanations()

Returns the number of explanations.  This function returns the number of subsets found by the most recent successful call to Node.computeExplanationData.

Returns

Number of explanations.

addCases

this.addCases = function addCases(data,
start,
count)

Adds the specified range of rows of the data set to this Domain as cases.

Parameters

dataa DataSet.
startthe index of the first row to transfer.
countthe number of rows to transfer.

Returns

void

Example

dom.addCases(data, 0, 10);

triangulate

this.triangulateWithMethod = function triangulateWithMethod()

Triangulates the graph of this Domain using the specified triangulation method.

Parameters

tmthe triangulation method to use.

Returns

void

Example

dom.triangulateWithMethod(HAPI.H_TM_BEST_GREEDY);

computeDBNPredictions

this.computeDBNPredictions = function computeDBNPredictions()

Computes predictions for {numberOfTimePoints} time slices beyond the current time window.  This Domain must have been produced by Class.createDBNDomain, and it must have been triangulated using Domain.triangulateDBN.  The predictions are accessed using Node.getPredictedBelief.

Parameters

numberOfTimePointsthe number of time slices to compute predictions for (this must be a positive number); an integer.

Returns

void

getDBNWindowOffset

this.getDBNWindowOffset = function getDBNWindowOffset()

Returns the total number of time steps that the time window of this DBN runtime domain has been moved.

Returns

integer

initializeDBNWindow

this.initializeDBNWindow = function initializeDBNWindow()

Moves the time window of this DBN back to its initial position, and removes all evidence.  This Domain must have been produced by Class.createDBNDomain, and it must have been triangulated using Domain.triangulateDBN.

Returns

void

moveDBNWindow

this.moveDBNWindow = function moveDBNWindow()

Slides the time window of this DBN delta steps into the future.  This Domain must have been produced by Class.createDBNDomain, and it must have been triangulated using Domain.triangulateDBN.

Parameters

deltathe number of time steps to slide the time window (this must be a positive number); an integer.

Returns

void

triangulateDBN

this.triangulateDBN = function triangulateDBN(tm)

Triangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.

Parameters

tmthe triangulation method to use.

Returns

void

triangulateDBNForBK

this.triangulateDBNForBK = function triangulateDBNForBK(tm)

Triangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.  Boyen-Koller approximations between time slices within the window are applied.

Parameters

tmthe triangulation method to use.

Returns

void

Node

Nodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs.  All nodes need a Domain; that is, the network must exist before its nodes can be created.

A Node can be created using the Domain node function <Domain.getNewNode>.

Summary
Functions
getHAPIGet the HAPI object that owns this Node
deleteObjectDeletes this Node.
getModelGets the Model for this Node.
getNameReturns the name of this Node.
setNameSets the name of this Node.
setPositionSets the position of this Node.
getPositionXReturns the position of this Node on the X-axis.
getPositionYReturns the position of this Node on the Y-axis.
setNumberOfStatesSets the number of states of this node.
getNumberOfStatesGet the number of states of this discrete node.
setStateLabelSets the label of the specified state.
getStateLabelGets the label of the specified state.
getTableGets the Table associated with this Node.
getBeliefGets the belief for the specified state of this Node.
getParentsGet an array of parent Nodes for this Node.
getChildrenGet an array of child Nodes for this Node.
addParentAdds a Node as a new parent of this Node.
selectStateSelects the specified state of this Node.
getSelectedStateGets (the index of) the selected state of this node.
retractFindingsRetracts all findings for this Node.
getExpectedUtilityGets the expected utility associated with this utility node or specified action of this discrete node.
getSampledUtilityReturns the sampled utility associated with this utility node.
getValueGets the value of this FunctionNode.
setValueSets the function associated with this function node to a number value.
evidenceIsEnteredTest if the evidence potential, currently registered with this Node, is non-vacuous.
getStateIndexGet the index of the state matching the specified value.
getStateValueGets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.
setStateValueSets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.
enterValueEnters evidence (observation of the value) for this continuous chance node.
getEnteredValueGets the evidence (value) entered for this continuous chance node.
evidenceIsPropagatedReturns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is non-vacuous; otherwise, returns false.
evidenceToPropagateReturns true if the entered and the propagated evidence differ; otherwise, returns false.
getAttributeReturns an attribute value.
getCategoryReturns the category of this Node.
getEdgeConstraintReturns the constraint between this and Node.
getHomeDomainReturns the Domain containing this Node.
getJunctionTreeReturns the JunctionTree to which this Node belongs.
getKindReturns the kind of this Node.
getSubtypeReturns the subtype of this Node.
getLabelReturns the label of this Node.
likelihoodIsPropagatedReturns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is a likelihood; otherwise, returns false.
likelihoodIsEnteredReturns true if the evidence potential, currently registered with this Node, is a likelihood; otherwise, returns false.
removeParentRemoves the directed link between a parent and this Node.
reverseEdgeReverses the edge between this Node and the specified neighbor.
setAttributeSets a value for a particular attribute in the attribute list for this Node.
setEdgeConstraintSets a constraint between this Node and another Node.
setLabelSets the label of this Node.
switchParentReplace the given parent node with the new node.
caseIsSetReturns true if a value has been set for this continuous chance or discete node in case caseindex; otherwise, returns false.
getAlphaReturns the alpha component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.
getBetaReturns the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.
getCaseValueReturns the value set for this continuous chance node in case caseindex.
getDistributionReturns the distribution for this continuous node.
getExperienceTableReturns the experience table of this continuous or discrete chance node.
getGammaReturns the gamma component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.
getMeanReturns the mean of the marginal distribution of this continuous chance node.
getPropagatedValueRetrieves the value that has been propagated for this continuous chance Node.
getSampledValueReturns the value of this function or continuous chance Node for the configuration generated by the most recent call to Domain.simulate.
getVarianceReturns the variance of the marginal distribution of this continuous chance Node.
hasExperienceTableReturns true if this continuous or discrete chance Node has an experience table; returns false otherwise.
setAlphaSets the alpha component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.
setBetaSets the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.
setCaseValueSets the value of this continuous chance node to value in case c.
setGammaSets the gamma component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.
unsetCaseSpecifies that the value of this continuous chance or discrete node is “unknown” for case caseindex.
computeSensitivityDataComputes the constants of the sensitivity functions for the specified output probability and all CPT/policy parameters in the network.
getFadingTableReturns the fading table of this discrete chance node.
hasFadingTableReturns true if this discrete chance Node has a fading table; returns false otherwise.
getRequisiteAncestorsGet an array of Nodes containing the requisite ancestors of this decision Node.
getRequisiteParentsGet an array of Nodes containing the requisite parents of this decision Node.
enterFindingSpecifies a finding value for a given state with all other states unaffected.
generateTableGenerates the table of this discrete Node from its Model (a missing Model will trigger an error).
getCaseStateReturns the state of this discrete node for case c.
getEnteredFindingReturns the entered finding for the specified state of this node.
getEntropyComputes the entropy of this node.
getMutualInformationComputes the mutual information between this discrete Node and the specified discrete Node.
getPropagatedFindingReturns the propagated finding.
getSampledStateReturns the state index of this discrete node for the configuration generated by the most recent call to Domain.simulate.
getSensitivityConstantsReturns the four constants of the specified sensitivity function.
getSensitivityConstantsByOutputReturns the four constants of the specified sensitivity function.
setCaseStateSets the state of this discrete node to state in case c.
getStateIndexFromLabelReturns the index of the state matching the specified label.
computeExplanationDataComputes Bayes factor data for all (nonempty) subsets of evidence nodes up to the specified maximum size.
computeExplanationData2Computes “normalized likelihoods” for the specified hypothesis and all (nonempty) subsets of evidence nodes up to the specified maximum size.
addToInputsMakes this Node become an input node of its Class.
addToOutputsMakes this Node become an output node of its Class.
createTemporalCloneConstructs a temporal clone of this Node.
getHomeReturns the NetworkModel containing this Node.
getHomeClassReturns the Class containing this Node.
getInstanceReturns the instance Node containing this (cloned) output node.
getMasterReturns the “master” of this (cloned) output Node of an instance node (i.e., the node cloned to get this output node).
getSourceGet an array of Nodes of Class nodes that identifies this Domain node.
getTemporalCloneGet the “temporal clone” of this Node.
getTemporalMasterGet the “temporal master” of this Node.
removeFromInputsRemoves this Node from the set of input nodes of its class.
removeFromOutputsRemoves this Node from the set of output nodes of its class.
getPredictedBeliefReturns the predicted belief for the specified state of this discrete Node at the specified time point.
getPredictedValueGets the predicted value of this FunctionNode at the specified time point.
getPredictedMeanReturns the predicted mean of the marginal distribution of this continuous chance node at the specified time point.
getPredictedVarianceReturns the predicted variance of the marginal distribution of this continuous chance node at the specified time point.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this Node

Returns

the owning HAPI instancs.

deleteObject

this.deleteObject = function deleteObject()

Deletes this Node.

Returns

void

Example

  • delete a node:
n.deleteObject();

getModel

this.getModel = function getModel()

Gets the Model for this Node.  If the Node has no model then null is returned.

Returns

Model (or null if Node has no model).

Example

  • get model for node n:
model = n.getModel();

getName

this.getName = function getName()

Returns the name of this Node.  If this node has not previously been assigned a name, a valid name will automatically be assigned.

Returns

string containing the name of this Node.

Example

  • get name of node:
nodeName = n.getName();

setName

this.setName = function setName(name)

Sets the name of this Node.  The name must be valid, i.e., it must follow the rules that govern the validity of C identifiers, and no other Node in the Domain to which this Node belongs must have the same name.

Parameters

namea string containing the new name of the Node

Returns

void

Example

  • set name of node:
n.setName("myNode");

setPosition

this.setPosition = function setPosition(X,
Y)

Sets the position of this Node.

Parameters

Xthe position on the X-axis (an integer)
Ythe position on the Y-axis (an integer)

Returns

void

Example

  • set position of node:
n.setPosition(10,20);

getPositionX

this.getPositionX = function getPositionX()

Returns the position of this Node on the X-axis.

Returns

an integer; position of this Node on the X-axis.

Example

  • get X position for node:
posX = n.getPositionX();

getPositionY

this.getPositionY = function getPositionY()

Returns the position of this Node on the Y-axis.

Returns

an integer; position of this Node on the Y-axis.

Example

  • get Y position for node:
posY = n.getPositionY();

setNumberOfStates

this.setNumberOfStates = function setNumberOfStates(stateCount)

Sets the number of states of this node.  Notice: Only possible for discrete nodes.

Parameters

stateCountthe number of states.

Returns

void

Example

  • set number of states for a discrete node to five:
n.setNumberOfStates(5);

getNumberOfStates

this.getNumberOfStates = function getNumberOfStates()

Get the number of states of this discrete node.  The states are numbered from 0 to N-1, where N is the number of states of the node.  Notice: Only possible for discrete nodes.

Returns

number of states of this discrete node.

Example

  • get number of states for a discrete node:
stateCount = n.getNumberOfStates();

setStateLabel

this.setStateLabel = function setStateLabel(state,
newLabel)

Sets the label of the specified state.  Notice: Only possible for discrete nodes.

Parameters

statethe index (a nonnegative integer) of the state; must be less than the number of states of the node.
newLabelthe desired state label.

Returns

void

Example

  • set state labels for state 0 and 1 for a discrete node:
n.setStateLabel(0, "State 0");
n.setStateLabel(1, "State 1");

getStateLabel

this.getStateLabel = function getStateLabel(state)

Gets the label of the specified state.  Notice: Only possible for discrete nodes.

Parameters

statethe index (a nonnegative integer) of the state; must be less than the number of states of the node.

Returns

Returns a string containing the label of the specified state.

Example

  • get state labels for state 0 and 1 for a discrete node:
label0 = n.getStateLabel(0);
label1 = n.getStateLabel(1);

getTable

this.getTable = function getTable()

Gets the Table associated with this Node.  If the node is a discrete chance node, the table is the conditional probability table for the node given its parents.  If the node is a utility node, the table represents a utility function of the parents of the node.

Returns

Returns the Table associated with this Node.

Example

  • get the table for a node:
tbl = n.getTable();

getBelief

this.getBelief = function getBelief(state)

Gets the belief for the specified state of this Node.  Note that if findings have been entered since the most recent propagation, the beliefs returned may not be up-to-date.  Notice: Only possible for discrete nodes.

Parameters

statean integer value representing which state to examine.

Returns

A real number representing the belief.

Example

  • get the belief for states 0 and 1 for a discrete node:
beliefState0 = n.getBelief(0);
beliefState1 = n.getBelief(1);

getParents

this.getParents = function getParents()

Get an array of parent Nodes for this Node.

Returns

an array of parent Nodes.

Example

  • get the list parents for node ‘n’:
parents = n.getParents();

getChildren

this.getChildren = function getChildren()

Get an array of child Nodes for this Node.

Returns

an array of child Nodes.

Example

  • get the list children for node ‘n’:
children = n.getChildren();

addParent

this.addParent = function addParent(parentNode)

Adds a Node as a new parent of this Node.  That is, it adds a directed link from the new parent to this node.

Returns

void

Example

  • add node ‘a’ as parent to node ‘b’:
b.addParent(a);

selectState

this.selectState = function selectState(state)

Selects the specified state of this Node.  This is equivalent to specifying the finding value 1 for the specified state and 0 for all other states.  Notice: Only possible for discrete nodes.

Parameters

statean integer value representing which state to select.

Returns

void

Example

  • select state 2 of node ‘n’:
n.selectState(2);

getSelectedState

this.getSelectedState = function getSelectedState()

Gets (the index of) the selected state of this node.  If no state is selected, a negative index is returned.  Notice: Only possible for discrete nodes.

Returns

the index of the selected state of this node.  If no state is selected, a negative index is returned.

Example

  • get index of selected state for node ‘n’:
selectedState = n.getSelectedState();

retractFindings

this.retractFindings = function retractFindings()

Retracts all findings for this Node.  For discrete nodes this is equivalent to setting the finding value to 1 for all states of this node.

Returns

void

Example

  • retract findings for node ‘n’:
n.retractFindings();

getExpectedUtility

this.getExpectedUtility = function getExpectedUtility(state)

Gets the expected utility associated with this utility node or specified action of this discrete node.  This is the utility value computed by the most recent inference operation.  Notice: Only possible for utility and discrete nodes.

Parameters

statean integer value designating which state of the discrete node to examine.  Notice: for utility nodes leave out the parameter or specify a value of -1.

Returns

A real number; the utility for the requested state of this discrete node, or the utility associated with this utility node.

Example

  • get expected utility for utility node u and state 0 of discrete node n:
utilU = u.getExpectedUtility();
utilN = n.getExpectedUtility(0);

getSampledUtility

this.getSampledUtility = function getSampledUtility()

Returns the sampled utility associated with this utility node.  This is the utility value sampled by the most recent call to DomainResource -> /simulateNotice: Only possible for utility nodes.

Returns

A real number; the sampled utility.

Example

  • get sampled utility for utility node u:
utilU = u.getSampledUtility();

getValue

this.getValue = function getValue()

Gets the value of this FunctionNode.  The value is computed using the function associated with the node.  If the function refers to other nodes, then the values of those nodes are derived from the results of the most recent inference operation.  Notice: Only possible for function nodes.

Returns

A real number.

Example

  • get value for function node n:
val = n.getValue();

setValue

this.setValue = function setValue(value)

Sets the function associated with this function node to a number value.  This is equivalent to retrieving the model and modifying the expression manually.  Notice: Only possible for function nodes that have no model nodes.  Furthermore the domain MUST be in a compiled state and an equilibrium, and tables MUST be up to date.

Parameters

valuea real number representing a fixed value function to use as the new function for this function node.

Returns

void

Example

  • set a value of 1.5 to use as the fixed value function for function node n:
n.setValue(1.5);

evidenceIsEntered

this.evidenceIsEntered = function evidenceIsEntered()

Test if the evidence potential, currently registered with this Node, is non-vacuous.

Returns

Returns true if the evidence potential, currently registered with this Node, is non-vacuous; otherwise, returns false.

Example

  • test if evidence has been entered for node n:
hasEvidence = n.evidenceIsEntered();

getStateIndex

this.getStateIndex = function getStateIndex(value)

Get the index of the state matching the specified value.  If there is no (unique) state with the specified state value, -1 is returned.  Notice: Only possible for numbered and interval discrete nodes.

Parameters

valuea state containing this value will be searched for.

Returns

The index of the state with the specified state value.

Example

  • get state index for value 2.5 for interval discrete node n:
state = n.getStateIndex(2.5);

getStateValue

this.getStateValue = function getStateValue(state)

Gets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.  For interval nodes, to indicate the right endpoint of the rightmost interval, specify state equal to the number of states of this interval node.  Notice: Only possible for numbered and interval discrete nodes.

Parameters

stateindex of the state.

Returns

The value associated with a particular state of this numbered node or the low value of the interval

Example

  • get state value for state 1 in numbered discrete node n:
val = n.getStateValue(1);

setStateValue

this.setStateValue = function setStateValue(state,
value)

Sets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.  For interval nodes, to indicate the right endpoint of the rightmost interval, specify state equal to the number of states of this interval node.  Notice: Only possible for numbered and interval discrete nodes.

Parameters

stateindex of the state.
valuethe value to set (a real number).

Returns

void

Example

  • set state value to 10 for state 1 in numbered discrete node n:
n.setStateValue(1, 10);

enterValue

this.enterValue = function enterValue(value)

Enters evidence (observation of the value) for this continuous chance node.  Notice: Only possible for continuous nodes.

Parameters

valuea real number representing the observation.

Returns

void

Example

  • enter a value of 1.5 for continuous node n:
n.enterValue(1.5);

getEnteredValue

this.getEnteredValue = function getEnteredValue()

Gets the evidence (value) entered for this continuous chance node.  If no value has been entered, an error is thrown.  Notice: Only possible for continuous nodes.

Returns

A real number expressing the value entered.

Example

  • get entered value for continuous node n:
val = n.getEnteredValue();

evidenceIsPropagated

this.evidenceIsPropagated = function evidenceIsPropagated()

Returns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is non-vacuous; otherwise, returns false.

Returns

Returns true if evidence has been propagated for this Node; otherwise, returns false.

Example

  • Check if evidence on Node ‘N’ has been propagated:
evidenceIsPropagated = N.evidenceIsPropagated();

evidenceToPropagate

this.evidenceToPropagate = function evidenceToPropagate()

Returns true if the entered and the propagated evidence differ; otherwise, returns false.

Returns

Returns true if evidence has been entered since the last propagation; otherwise, returns false.

Example

  • Check if Node ‘N’ has evidence to propagate:
result = N.evidenceToPropagate();

getAttribute

this.getAttribute = function getAttribute(key)

Returns an attribute value.  That is, the value associated with a key in the attribute list for this Node.

Parameters

keythe key for which the attribute value is returned Returns: a string

Example

  • get the attribute value associated with key ‘myattribute’ in Node ‘N’:
val = N.getAttribute("myattribute");

getCategory

this.getCategory = function getCategory()

Returns the category of this Node.

Returns

the node category, the string equals either HAPI.H_CATEGORY_CHANCE, HAPI.H_CATEGORY_DECISION, HAPI.H_CATEGORY_UTILITY, HAPI.H_CATEGORY_FUNCTION or HAPI.H_CATEGORY_INSTANCE.

Example

  • get the node category for Node ‘N’:
category = N.getCategory();

getEdgeConstraint

this.getEdgeConstraint = function getEdgeConstraint(node)

Returns the constraint between this and Node.

Parameters

nodea Node.

Returns

The constraint between this and Node, the string equals either HAPI.H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN, HAPI.H_CONSTRAINT_BACKWARD_EDGE_REQUIRED, HAPI.H_CONSTRAINT_EDGE_FORBIDDEN, HAPI.H_CONSTRAINT_EDGE_REQUIRED, HAPI.H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN, HAPI.H_CONSTRAINT_FORWARD_EDGE_REQUIRED or HAPI.H_CONSTRAINT_NONE

Example

  • get the constraint between Nodes ‘A’ and ‘B’:
constraint = A.getEdgeConstraint(B);

getHomeDomain

this.getHomeDomain = function getHomeDomain()

Returns the Domain containing this Node.

Returns

a Domain object

Example

  • get the home domain for Node ‘N’:
dom = N.getHomeDomain();

getJunctionTree

this.getJunctionTree = function getJunctionTree()

Returns the JunctionTree to which this Node belongs.

Returns

a JunctionTree.

Example

jt = N.getJunctionTree();

getKind

this.getKind = function getKind()

Returns the kind of this Node.

Returns

the node kind, the string equals either HAPI.H_KIND_CONTINUOUS, HAPI.H_KIND_DISCRETE or HAPI.H_KIND_OTHER.

Example

  • get the kind of Node ‘N’:
kind = N.getKind();

getSubtype

this.getSubtype = function getSubtype()

Returns the subtype of this Node.

Returns

the node subtype, the string equals either HAPI.H_SUBTYPE_NUMBER, HAPI.H_SUBTYPE_INTERVAL, HAPI.H_SUBTYPE_BOOLEAN, HAPI.H_SUBTYPE_LABEL or HAPI.H_SUBTYPE_OTHER.

Example

  • get the subtype of Node ‘N’:
subtype = N.getSubtype();

getLabel

this.getLabel = function getLabel()

Returns the label of this Node.

Returns

a string

Example

  • get the node label for Node ‘N’:
label = N.getLabel();

likelihoodIsPropagated

this.likelihoodIsPropagated = function likelihoodIsPropagated()

Returns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is a likelihood; otherwise, returns false.

Returns

a boolean

Example

  • Check if likelihoods in Node ‘N’ has been propagated:
likelihoodIsPropagated = N.likelihoodIsPropagated();

likelihoodIsEntered

this.likelihoodIsEntered = function likelihoodIsEntered()

Returns true if the evidence potential, currently registered with this Node, is a likelihood; otherwise, returns false.

Returns

a boolean

Example

  • Check if likelihood has been entered for Node ‘N’:
likelihoodEntered = N.likelihoodIsEntered();

removeParent

this.removeParent = function removeParent(node)

Removes the directed link between a parent and this Node.  The table (if any) of the Node will be updated such that the updated table will be the portion of the old table that corresponds to the parent being in its first state.

Parameters

nodea Node

Returns

void

Example

  • Remove parent Node ‘P’ from Node ‘C’:
C.removeParent(N);

reverseEdge

this.reverseEdge = function reverseEdge(node)

Reverses the edge between this Node and the specified neighbor.  Both nodes must be chance nodes, and they must be of the same kind (that is, both nodes are discrete or both nodes are continuous).

Parameters

nodea neighboring Node

Returns

void

Example

  • reverse edge between neighboring Nodes ‘A’ and ‘B’:
A.reverseEdge(B);

setAttribute

this.setAttribute = function setAttribute(key,
value)

Sets a value for a particular attribute in the attribute list for this Node.  If no value is provided, the attribute is removed.

Parameters

keyThe key identifying the attribute to be updated.
valueThe value of the attribute.

Returns

void

Example

  • Set the value ‘abc’ for key ‘A’ in Node ‘N’:
N.setAttribute("A", "abc");

setEdgeConstraint

this.setEdgeConstraint = function setEdgeConstraint(node,
constraint)

Sets a constraint between this Node and another Node.

Parameters

nodea Node
constraintthe node constraint.  Must be one of either HAPI.H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN, HAPI.H_CONSTRAINT_BACKWARD_EDGE_REQUIRED, HAPI.H_CONSTRAINT_EDGE_FORBIDDEN, HAPI.H_CONSTRAINT_EDGE_REQUIRED, HAPI.H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN, HAPI.H_CONSTRAINT_FORWARD_EDGE_REQUIRED or HAPI.H_CONSTRAINT_NONE

Returns

void

Example

  • set constraint between Nodes ‘A’ and ‘B’:
A.setEdgeConstraint(B, HAPI.H_CONSTRAINT_NONE);

setLabel

this.setLabel = function setLabel(label)

Sets the label of this Node.

Parameters

labelthe label

Returns

void

Example

  • Set label ‘My Node Label!’ for Node ‘N’:
N.setLabel("My Node Label!");

switchParent

this.switchParent = function switchParent(oldParent,
newParent)

Replace the given parent node with the new node.  The old and new parent must be compatible.  That is, they must be of the same class, and have an identical state set.

Parameters

oldParenta Node, the old parent.
newParenta Node, the new parent.

Returns

void

Example

  • switch Nodes ‘A’ and ‘B’ as parents for Node ‘C’:
C.switchParent(A, B);

caseIsSet

this.caseIsSet = function caseIsSet(caseindex)

Returns true if a value has been set for this continuous chance or discete node in case caseindex; otherwise, returns false.

Notice: Only possible for discrete and continuous nodes.

Parameters

caseindexthe case index represented as an integer.

Returns

a boolean

Example

  • Check if a value for case 10 has been set for continuous chance Node ‘CC’:
isset = CC.caseIsSet(10);

getAlpha

this.getAlpha = function getAlpha(i)

Returns the alpha component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.

Parameters

ithe index of a discrete parent configuration. an integer.

Returns

A real number.

Example

  • get alpha component of CG distribution of continuous chance Node ‘CC’ for discrete parent configuration 2:
alpha = CC.getAlpha(2);

getBeta

this.getBeta = function getBeta(parent,
i)

Returns the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.

Parameters

parenta Node object; must be a continuous chance node.
ithe index of a discrete parent configuration. an integer.

Returns

A real number.

Example

  • get beta component of CG distribution of continuous chance Node ‘CC’ for discrete parent configuration 2 and continuous parent ‘P’:
beta = CC.getBeta(P, 2);

getCaseValue

this.getCaseValue = function getCaseValue(caseindex)

Returns the value set for this continuous chance node in case caseindex.

Parameters

caseindexthe case index. an integer.

Returns

A real number.

Example

  • get the value set for continuous chance Node ‘CC’ in case 10:
caseval = CC.getCaseValue(10);

getDistribution

this.getDistribution = function getDistribution()

Returns the distribution for this continuous node.  The distribution for a continuous chance node is in general a mixture of several Gaussian distributions.  This method actually computes a joint distribution of this CG node and a set of discrete nodes.  These discrete nodes are chosen such that the computed marginal is a strong marginal, but it is not necessarily minimal.

Returns

A Table.

Example

  • get the distribution for continuous chance Node ‘CC’:
t = CC.getDistribution();

getExperienceTable

this.getExperienceTable = function getExperienceTable()

Returns the experience table of this continuous or discrete chance node.

Notice: Only possible for discrete and continuous chance nodes.

Returns

A Table.

Example

  • get the experience table for continuous chance Node ‘CC’:
t = CC.getExperienceTable();

getGamma

this.getGamma = function getGamma(i)

Returns the gamma component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.

Parameters

ithe index of a discrete parent configuration. an integer.

Returns

A real number.

Example

  • get gamma component of CG distribution of continuous chance Node ‘CC’ for discrete parent configuration 2:
gamma = CC.getGamma(2);

getMean

this.getMean = function getMean()

Returns the mean of the marginal distribution of this continuous chance node.

Returns

A real number.

Example

  • get the mean of the marginal distribution of this continuous chance Node ‘CC’:
mean = CC.getMean();

getPropagatedValue

this.getPropagatedValue = function getPropagatedValue()

Retrieves the value that has been propagated for this continuous chance Node.  That is, the value incorporated in the current junction tree potentials as the state of this node.

Returns

A real number.

Example

  • get the propagated value of this continuous chance Node ‘CC’:
value = CC.getPropagatedValue();

getSampledValue

this.getSampledValue = function getSampledValue()

Returns the value of this function or continuous chance Node for the configuration generated by the most recent call to Domain.simulate.

Notice: Only possible for continuous and function nodes.

Returns

A real number.

Example

  • get the sampled value for function or continuous chance Node ‘N’:
value = N.getSampledValue();

getVariance

this.getVariance = function getVariance()

Returns the variance of the marginal distribution of this continuous chance Node.

Returns

A real number.

Example

  • get the variance for continuous chance Node ‘CC’:
variance = CC.getVariance();

hasExperienceTable

this.hasExperienceTable = function hasExperienceTable()

Returns true if this continuous or discrete chance Node has an experience table; returns false otherwise.

Notice: Only possible for discrete and continuous chance nodes.

Returns

A boolean.

Example

  • check if continuous chance Node ‘CC’ has an experience table:
hasTable = CC.hasExperienceTable();

setAlpha

this.setAlpha = function setAlpha(alpha,
i)

Sets the alpha component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.

Parameters

alphathe value of the alpha component. a real number.
ithe index of a discrete parent configuration. an integer.

Returns

void

Example

  • Set alpha for continuous chance Node ‘CC’ to ‘0.5’ for parent configuration ‘1’:
CC.setAlpha(0.5, 1);

setBeta

this.setBeta = function setBeta(beta,
parent,
i)

Sets the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.

Parameters

betathe value of the beta component. a real number.
parenta Node object; must be a continuous chance node.
ithe index of a discrete parent configuration. an integer.

Returns

void

Example

  • Set beta for continuous chance Node ‘CC’ to ‘0.5’ continuous parent ‘P’ and discrete parent configuration ‘1’:
CC.setBeta(0.5, P, 1);

setCaseValue

this.setCaseValue = function setCaseValue(c,
value)

Sets the value of this continuous chance node to value in case c.

Parameters

cthe case index represented as an integer.
valuethe value represented as a real number.

Returns

void

Example

  • Set case value for for continuous chance Node ‘CC’ to ‘0.5’ in case ‘10’:
CC.setCaseValue(10, 0.5);

setGamma

this.setGamma = function setGamma(gamma,
i)

Sets the gamma component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.

Parameters

gammathe value of the gamma component. a real number.
ithe index of a discrete parent configuration. an integer.

Returns

void

Example

  • set gamma component for continuous chance Node ‘CC’ to ‘0.5’ in parent configuration ‘1’:
CC.setGamma(0.5, 1);

unsetCase

this.unsetCase = function unsetCase(caseindex)

Specifies that the value of this continuous chance or discrete node is “unknown” for case caseindex.

Notice: Only possible for discrete and continuous nodes.

Parameters

caseindexthe case index represented as an integer.

Returns

void

Example

  • unset case 10 for continuous chance Node ‘CC’:
CC.unsetCase(10);

computeSensitivityData

this.computeSensitivityData = function computeSensitivityData(state)

Computes the constants of the sensitivity functions for the specified output probability and all CPT/policy parameters in the network.

This method simply calls Node.computeSensitivityData with the specified output probability as argument.

Notice: Only possible for discrete chance nodes.

Parameters

statethe index of a state of this node - the probability of this state is the desired output probability.

Returns

void

Example

  • compute sensitivity data for discrete chance Node ‘N’ for state ‘1’:
N.computeSensitivityData(1);

getFadingTable

this.getFadingTable = function getFadingTable()

Returns the fading table of this discrete chance node.

Notice: Only possible for discrete chance nodes.

Returns

A Table.

Example

  • get the fading table for discrete chance Node ‘N’:
t = N.getFadingTable();

hasFadingTable

this.hasFadingTable = function hasFadingTable()

Returns true if this discrete chance Node has a fading table; returns false otherwise.

Notice: Only possible for discrete chance nodes.

Returns

A boolean.

Example

  • check if discrete chance Node ‘N’ has a fading table:
hasTable = N.hasFadingTable();

getRequisiteAncestors

this.getRequisiteAncestors = function getRequisiteAncestors()

Get an array of Nodes containing the requisite ancestors of this decision Node.

The requisite ancestors are found by augmenting the network with additional information links as prescribed by the “no-forgetting” rule (which states that past observations and decisions are taken into account by all future decisions) and applying the minimal reduction algorithm for LIMIDs.

Notice: Only possible for discrete decision nodes.

Returns

an array of Nodes.

Example

  • get the requisite ancestors for decision node ‘n’:
requisite = n.getRequisiteAncestors();

getRequisiteParents

this.getRequisiteParents = function getRequisiteParents()

Get an array of Nodes containing the requisite parents of this decision Node.

Notice: Only possible for discrete decision nodes.

Returns

an array of Nodes.

Example

  • get the requisite parents for decision node ‘n’:
requisite = n.getRequisiteParents();

enterFinding

this.enterFinding = function enterFinding(state,
finding)

Specifies a finding value for a given state with all other states unaffected.

Notice: Only possible for discrete nodes.

Parameters

statean integer representing the state to be selected.  States are numbered consecutively from 0 and upwards.
findingA nonnegative real number as the finding value.

Returns

void

Example

  • Enter a finding of 0.5 for state 1 in discrete Node ‘N’:
N.enterFinding(1, 0.5);

generateTable

this.generateTable = function generateTable()

Generates the table of this discrete Node from its Model (a missing Model will trigger an error).

Notice: Only possible for discrete nodes.

Returns

void

Example

  • generate table for discrete Node ‘N’:
N.generateTable();

getCaseState

this.getCaseState = function getCaseState(c)

Returns the state of this discrete node for case c.

Notice: Only possible for discrete nodes.

Parameters

cthe case index (an integer in the range 0, ..., number of cases)

Returns

an integer.

Example

  • get the state of discrete node ‘N’ in case 10:
state = N.getCaseState(10);

getEnteredFinding

this.getEnteredFinding = function getEnteredFinding(state)

Returns the entered finding for the specified state of this node.

Notice: Only possible for discrete nodes.

Parameters

statean integer value representing which state to examine.

Returns

A real number.

Example

  • get the entered finding for discrete node ‘N’ in state 0:
enteredFinding = N.getEnteredFinding(0);

getEntropy

this.getEntropy = function getEntropy()

Computes the entropy of this node.

Notice: Only possible for discrete nodes.

Returns

A real number.

Example

  • get the entropy for discrete node ‘N’:
entropy = N.getEntropy();

getMutualInformation

this.getMutualInformation = function getMutualInformation(node)

Computes the mutual information between this discrete Node and the specified discrete Node.

Notice: Only possible for discrete nodes.

Parameters

nodea discrete Node

Returns

A real number.

Example

  • get mutual information between between discrete Nodes ‘A’ and ‘B’:
mi = A.getMutualInformation(B);

getPropagatedFinding

this.getPropagatedFinding = function getPropagatedFinding(state)

Returns the propagated finding.  That is, it returns the finding value incorporated within the current junction tree potentials for the specified {state} of this node.

Notice: Only possible for discrete nodes.

Parameters

statean integer representing the state to be examined.

Returns

A real number.

Example

  • get the propagated finding for state 1 of discrete Node ‘N’:
probFind = N.getPropagatedFinding(1);

getSampledState

this.getSampledState = function getSampledState()

Returns the state index of this discrete node for the configuration generated by the most recent call to Domain.simulate.

Notice: Only possible for discrete nodes.

Returns

An integer.  The state index.

Example

  • get the sampled state for discrete Node ‘N’:
state = N.getSampledState();

getSensitivityConstants

this.getSensitivityConstants = function getSensitivityConstants(input)

Returns the four constants of the specified sensitivity function.  The output probability of this function was specified in the preceding call to Domain.computeSensitivityData.  If the results produced by that call have been invalidated, an error is returned.

Notice: Only possible for discrete nodes.

Parameters

inputspecifies a conditional probability (or policy) parameter of this node (i.e., input is the index of an entry in the CPT/policy of this node).  An integer.

Returns

the four constants of the specified sensitivity functionan array of real numbers.

Example

  • get sensitivity constants for discrete Node ‘N’ for the first entry of the CPT:
constants = N.getSensitivityConstants(0);

getSensitivityConstantsByOutput

this.getSensitivityConstantsByOutput = function getSensitivityConstantsByOutput(
   input,
   output
)

Returns the four constants of the specified sensitivity function.  The output probability of this function must be one of the output probabilities specified in the preceding call to Domain.computeSensitivityData.  If the results produced by that call have been invalidated, an error is returned.

Notice: Only possible for discrete nodes.

Parameters

inputspecifies a conditional probability (or policy) parameter of this node (i.e., input is the index of an entry in the CPT/policy of this node).  An integer.
outputidentifies one of the output probabilities specified in the call to Domain.computeSensitivityData.  An integer.

Returns

the four constants of the specified sensitivity functionan array of real numbers.

Example

constants = N.getSensitivityConstantsByOutput(0, 0);

setCaseState

this.setCaseState = function setCaseState(c,
state)

Sets the state of this discrete node to state in case c.

Notice: Only possible for discrete nodes.

Parameters

cthe case index represented as an integer.
statethe state represented as an integer.

Returns

void

Example

  • set state to ‘1’ in case ‘10’ for discrete Node ‘N’:
N.setCaseState(10, 1);

getStateIndexFromLabel

this.getStateIndexFromLabel = function getStateIndexFromLabel(label)

Returns the index of the state matching the specified label.  If there is no (unique) state with the specified state label, -1 is returned.

Notice: Only possible for discrete nodes.

Parameters

labelthe state label to search for

Returns

An integer.  A state index.

Example

  • get the index for state with label ‘State 1’ for discrete Node ‘N’:
state = N.getStateIndexFromLabel("State 1");

computeExplanationData

this.computeExplanationData = function computeExplanationData(x,
Y,
y,
maxSubsetSize)

Computes Bayes factor data for all (nonempty) subsets of evidence nodes up to the specified maximum size.  Two hypotheses are compared: (this node)=x and Y=y.  For each subset of evidence nodes (up to the specified maximum size), the Bayes factor (the support for the first hypothesis relative to the second hypothesis) is computed.  The results of the computations can be accessed using Domain.getExplanation and Domain.getExplanationScore.

Notice: Only possible for discrete nodes.

Parameters

xstate of the primary hypothesis node (this discrete Node)
Ythe alternative hypothesis Node (a discrete node)
ystate of the alternative hypothesis node
maxSubsetSizedata for all subsets of evidence nodes up to this size are computed

Returns

void

computeExplanationData2

this.computeExplanationData2 = function computeExplanationData2(x,
maxSubsetSize)

Computes “normalized likelihoods” for the specified hypothesis and all (nonempty) subsets of evidence nodes up to the specified maximum size.  For each subset of evidence nodes (up to the specified maximum size), the normalized likelihood of the hypothesis is computed.  The results of the computations can be accessed using Domain.getExplanation and Domain.getExplanationScore.

Notice: Only possible for discrete nodes.

Parameters

xstate of the hypothesis node (this discrete Node)
maxSubsetSizedata for all subsets of evidence nodes up to this size are computed

Returns

void

addToInputs

this.addToInputs = function addToInputs()

Makes this Node become an input node of its Class.  The node must not already be an input or output node of its class, it must not be an output clone associated with an instancenode, and, most importantly, it must not have parents.

Notice: Only possible for nodes of a Class.

Returns

void

addToOutputs

this.addToOutputs = function addToOutputs()

Makes this Node become an output node of its Class.  The node must not already be an output or input node of its class.

Notice: Only possible for nodes of a Class.

Returns

void

createTemporalClone

this.createTemporalClone = function createTemporalClone()

Constructs a temporal clone of this Node.  This node (known as the “master” node) must not be an instance node, or a temporal or an output clone, and the node must belong to a class without input and output nodes.  Moreover, this class must not be instantiated.  Only one temporal clone can be created for each master node.

Notice: Only possible for nodes of a Class.

Returns

a Node

getHome

this.getHome = function getHome()

Returns the NetworkModel containing this Node.

Returns

a Domain or Class object

Example

  • get the home for Node ‘N’:
net = N.getHome();

getHomeClass

this.getHomeClass = function getHomeClass()

Returns the Class containing this Node.

Returns

a Class object

Example

cls = N.getHomeClass();

getInstance

this.getInstance = function getInstance()

Returns the instance Node containing this (cloned) output node.  Or an error if this is not an output node.  Note that we clone all output nodes when we create an instance node.  This is done in order to make it possible to specify conditional probability tables involving output nodes from instance nodes.

Notice: Only possible for nodes of a Class.

Returns

a Node object

getMaster

this.getMaster = function getMaster()

Returns the “master” of this (cloned) output Node of an instance node (i.e., the node cloned to get this output node).  Or an error if node is not cloned output.  Note that “master” belongs to another Class.  Note also that we clone all output nodes when we create an instance node.  This is done in order to make it possible to specify conditional probability tables involving output nodes from instance nodes.

Notice: Only possible for nodes of a Class.

Returns

a Node object

getSource

this.getSource = function getSource()

Get an array of Nodes of Class nodes that identifies this Domain node.

The Class.createDomain method of the Class unfolds an object-oriented (nested) specification of a Bayesian network or a LIMID into a regular Domain.

Nodes in this Domain which originates from nodes residing in nested sub-networks (via instance nodes) can be uniquely related to a sequence of instance node Node and an ordinary Node of the object-oriented network.

Notice: Only possible for nodes of a Domain.

Returns

an array of Nodes (the source list)

Example

  • get the source for node ‘n’:
source = n.getSource();

getTemporalClone

this.getTemporalClone = function getTemporalClone()

Get the “temporal clone” of this Node.

Notice: Only possible for nodes of a Class.

Returns

a Node object

getTemporalMaster

this.getTemporalMaster = function getTemporalMaster()

Get the “temporal master” of this Node.

Notice: Only possible for nodes of a Class.

Returns

a Node object

removeFromInputs

this.removeFromInputs = function removeFromInputs()

Removes this Node from the set of input nodes of its class.

Notice: Only possible for nodes of a Class.

Returns

void

removeFromOutputs

this.removeFromOutputs = function removeFromOutputs()

Removes this Node from the set of output nodes of its class.

Notice: Only possible for nodes of a Class.

Returns

void

getPredictedBelief

this.getPredictedBelief = function getPredictedBelief(state,
time)

Returns the predicted belief for the specified state of this discrete Node at the specified time point.  This method accesses the predictions computed by a previous call to Domain.computeDBNPredictions.

Parameters

statean integer value representing which state to examine.
timetime slice index (a nonnegative integer less than the number of predicted time slices)

Returns

A real number representing the belief at the specified time point.

getPredictedValue

this.getPredictedValue = function getPredictedValue(time)

Gets the predicted value of this FunctionNode at the specified time point.  This method accesses the predictions computed by a previous call to Domain.computeDBNPredictionsNotice: Only possible for function nodes.

Parameters

timetime slice index (a nonnegative integer less than the number of predicted time slices)

Returns

A real number representing the predicted value at the specified time point.

getPredictedMean

this.getPredictedMean = function getPredictedMean(time)

Returns the predicted mean of the marginal distribution of this continuous chance node at the specified time point.  This method accesses the predictions computed by a previous call to Domain.computeDBNPredictionsNotice: Only possible for continuous nodes.

Parameters

timetime slice index (a nonnegative integer less than the number of predicted time slices)

Returns

A real number representing the predicted mean of the marginal distribution of this continuous chance node at the specified time point.

getPredictedVariance

this.getPredictedVariance = function getPredictedVariance(time)

Returns the predicted variance of the marginal distribution of this continuous chance node at the specified time point.  This method accesses the predictions computed by a previous call to Domain.computeDBNPredictionsNotice: Only possible for continuous nodes.

Parameters

timetime slice index (a nonnegative integer less than the number of predicted time slices)

Returns

A real number representing the predicted variance of the marginal distribution of this continuous chance node at specified time.

Table

Hugin uses Tables for representing the conditional probability and utility potentials of individual Nodes, the probability and utility potentials on separators and Cliques of JunctionTrees, evidence potentials, etc.  A potential is a function from the state space of a set of variables into the set of real numbers.  A Table is a representation of a potential.

Tables are acquired using the Node.getTable function.

Summary
Functions
getHAPIGet the HAPI object that owns this Table
deleteObjectDeletes this Table.
getSizeGet the size of this Table.
getNodesGet all Nodes associated with this Table.
getDataItemGet the data item at position index of the discrete data of this Table.
setDataItemSets a specific data item of the discrete data of this Table.
setDataSets a region of the discrete data of this Table.
getDataGets a region of the discrete data of this Table.
getMeanGet the mean of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.
getVarianceGet the variance of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.
getCovarianceGet the covariance of a pair of continuous chance Nodes given a configuration of the discrete chance Nodes of this Table.
computeProbabilityOfIntervalCompute the probability of a given interval for the mixture distribution represented by this Table.
reorderNodesReorders the list of Nodes of this Table.
getCGSizeReturns the CG size of this Table.
setAllDataItemsSets all data items of the discrete data of this Table.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this Table

Returns

the owning HAPI instancs.

deleteObject

this.deleteObject = function deleteObject()

Deletes this Table.

Returns

void

Example

  • delete the table ‘t’:
t.deleteObject();

getSize

this.getSize = function getSize()

Get the size of this Table.

Returns

size of the Table.

Example

  • get size of table ‘t’:
tableSize = t.getSize();

getNodes

this.getNodes = function getNodes()

Get all Nodes associated with this Table.

Returns

An array of Nodes associated with this Table.

Example

  • get an array of Nodes associated with Table ‘t’:
nodes = t.getNodes();

getDataItem

this.getDataItem = function getDataItem(index)

Get the data item at position index of the discrete data of this Table.  The index is interpreted as the index of a one-dimensional row-major representation of the actual multi-dimensional data.

Parameters

indexthe index of the data item

Returns

A real number; the data item at requested index.

Example

  • get the data item at indices 0, 1, 2 and 3 in Table ‘t’:
data0 = t.getDataItem(0);
data1 = t.getDataItem(1);
data2 = t.getDataItem(2);
data3 = t.getDataItem(3);

setDataItem

this.setDataItem = function setDataItem(index,
value)

Sets a specific data item of the discrete data of this Table.

Parameters

indexindex of the data item to set
valuereal number; the new value of the data item at the specified index.

Returns

void

Example

  • set the data item at indices 0, 1, 2 and 3 in Table ‘t’:
t.setDataItem(0, 0.3);
t.setDataItem(1, 0.4);
t.setDataItem(2, 0.8);
t.setDataItem(3, 0.05);

setData

this.setData = function setData(data,
startIndex,
count)

Sets a region of the discrete data of this Table.  The region is specified by a start position and the number of elements to copy.  The data is copied from the data array to the table.

The indexes startIndex, ..., startIndex+count-1 must be valid indexes of this table.  Also, count must be less than or equal to the size of the data array.

Parameters

dataarray of real numbers holding the data to copy to this table
startIndexindex of the first element to be set
countnumber of elements to copy

Returns

void

Example

  • set the the first four data item in Table ‘t’:
dataItems = [0.3, 0.4, 0.8, 0.05];
t.setData(dataItems, 0, 4);

getData

this.getData = function getData(startIndex,
count)

Gets a region of the discrete data of this Table.  The region is specified by a start position and the number of elements to copy.

The indexes startIndex, ..., startIndex+count-1 must be valid indexes of this Table.

Parameters

startIndexindex of the first element to get
countnumber of elemets to retrieve

Returns

Requested region of data items as an array of real numbers

Example

  • get an array of the the first four data items in Table ‘t’:
dataItems = t.getData(0, 4);

getMean

this.getMean = function getMean(index,
node)

Get the mean of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.

Parameters

indexthe index of the discrete configuration.
nodecontinuous chance Node.

Returns

a real number; the mean of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.

Example

  • get mean of CG node ‘n’ given configuration ‘i’ of table ‘t’:
mean = t.getMean(i, n);

getVariance

this.getVariance = function getVariance(index,
node)

Get the variance of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.

Parameters

indexthe index of the discrete configuration.
nodecontinuous chance Node.

Returns

a real number; the variance of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.

Example

  • get variance of CG node ‘n’ given configuration ‘i’ of table ‘t’:
variance = t.getVariance(i, n);

getCovariance

this.getCovariance = function getCovariance(index,
node1,
node2)

Get the covariance of a pair of continuous chance Nodes given a configuration of the discrete chance Nodes of this Table.

Parameters

indexthe index of the discrete configuration.
node1continuous chance Node.
node2continuous chance Node.

Returns

a real number; the covariance of a pair of continuous chance Nodes given a configuration of the discrete chance Nodes of this Table.

Example

  • get the covariance of CG nodes ‘n1’ and ‘n2’ given configuration ‘i’ of table ‘t’:
covariance = t.getCovariance(i, n1, n2);

computeProbabilityOfInterval

this.computeProbabilityOfInterval = function computeProbabilityOfInterval(x,
y)

Compute the probability of a given interval for the mixture distribution represented by this Table.

Parameters

xthe left endpoint of the interval.
ythe right endpoint of the interval.

Returns

a real number; the probability of the given interval.

Example

  • get the probability of the interval with endpoints ‘x’ and ‘y’ of the mixture distribution represented by table ‘t’:
probability = t.computeProbabilityOfInterval(x, y);

reorderNodes

this.reorderNodes = function reorderNodes(nodes)

Reorders the list of Nodes of this Table.

Parameters

nodesthe new order (which must be a permutation of the current order) of the Nodes of this Table; an array of Nodes.

Returns

void

getCGSize

this.getCGSize = function getCGSize()

Returns the CG size of this Table.  This is the number of CG data elements stored in the table.

Returns

an integer; the number of CG data elements stored in the table.

Example

  • get number of CG data elements stored in table ‘t’:
cgsize = t.getCGSize();

setAllDataItems

this.setAllDataItems = function setAllDataItems(value)

Sets all data items of the discrete data of this Table.

Parameters

valuereal number; the value to set for all data items.

Returns

void

Example

  • set value of all data items in Table ‘t’ to 0:
t.setAllDataItems(0);

Model

A Model is a compact description of a table.  A model consists of a list of discrete nodes and a set of expressions (one expression per configuration of states of the nodes.

Models are created using Domain.getNewModel and acquired from nodes using the Node.getModel function.

Summary
Functions
getHAPIGet the HAPI object that owns this Model
deleteObjectDeletes this Model.
setExpressionAssociates an expression (specified as a string) with a specific configuration of the Nodes of this Model.
getExpressionReturns the expression (as a string) associated with a specific configuration of the NodeResources of this ModelResource.
setNumberOfSamplesPerIntervalSets the number of values taken within each bounded interval of an interval parent when generating the conditional probability table for a node with interval parents.
getNumberOfSamplesPerIntervalGets the number of values per interval used when generating the conditional probability table for a node with interval parents.
getSizeReturns the number of configurations of the Node of this Model.
getNodesGet all Nodes in this Model.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this Model

Returns

the owning HAPI instancs.

deleteObject

this.deleteObject = function deleteObject()

Deletes this Model.

Returns

void

Example

  • delete the model ‘m’:
m.deleteObject();

setExpression

this.setExpression = function setExpression(index,
expression)

Associates an expression (specified as a string) with a specific configuration of the Nodes of this Model.

Parameters

indexindex of configuration
expressionthe expression as a string

Returns

void

Example

  • set the simple expression “true” for model ‘m’ in configuration 0 (in this context m is the model for a boolean node):
m.setExpression(0, "true");

getExpression

this.getExpression = function getExpression(index)

Returns the expression (as a string) associated with a specific configuration of the NodeResources of this ModelResource.

Parameters

indexindex of configuration

Returns

a string representation of the expression associated with configuration index of the Node of this Model.

Example

  • get the expression for model ‘m’ in configuration 0:
expr = m.getExpression(0);

setNumberOfSamplesPerInterval

this.setNumberOfSamplesPerInterval = function setNumberOfSamplesPerInterval(
   count
)

Sets the number of values taken within each bounded interval of an interval parent when generating the conditional probability table for a node with interval parents.

When generating the conditional probability table for a node with interval nodes as parents, a number of values are taken within each bounded interval of an interval parent.  By default, the interval is divided into 25 subintervals, and the midpoints of these subintervals are then used in the computation of the value of the child.

Parameters

countthe number of subintervals (an integer).

Returns

void

Example

  • set number of samples per interval to 20:
m.setNumberOfSamplesPerInterval(20);

getNumberOfSamplesPerInterval

this.getNumberOfSamplesPerInterval = function getNumberOfSamplesPerInterval()

Gets the number of values per interval used when generating the conditional probability table for a node with interval parents.

Returns

requested number of samples per interval (an integer).

Example

  • get the number of samples per interval:
numSam = m.getNumberOfSamplesPerInterval();

getSize

this.getSize = function getSize()

Returns the number of configurations of the Node of this Model.

Returns

number of configurations of the nodes of this model.

Example

  • get number of configurations of the nodes of Model ‘m’:
numConf = m.getSize();

getNodes

this.getNodes = function getNodes()

Get all Nodes in this Model.

Returns

An array of Nodes in this Model.

Example

nodes = m.getNodes();

Clique

Cliques represents the cliques in the junction tree.

Cliques are acquired using JunctionTree.getCliques, JunctionTree.getRoot and Clique.getNeighbors functions.  JunctionTrees are acquired using the Domain.getJunctionTrees function.

Summary
Functions
getHAPIGet the HAPI object that owns this Clique
getJunctionTreeGet the JunctionTree to which this Clique belongs.
getMembersGet the list of Nodes that are members of this Clique.
getNeighborsGet a list of Cliques that are neighbors of this Clique.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this Clique

Returns

the owning HAPI instancs.

getJunctionTree

this.getJunctionTree = function getJunctionTree()

Get the JunctionTree to which this Clique belongs.

Returns

the JunctionTree to which this Clique belongs.

Example

jt = c.getJunctionTree();

getMembers

this.getMembers = function getMembers()

Get the list of Nodes that are members of this Clique.

Returns

An array of Nodes that are members of this Clique.

Example

  • get an array of Nodes that are members of Clique ‘c’:
nodes = c.getMembers();

getNeighbors

this.getNeighbors = function getNeighbors()

Get a list of Cliques that are neighbors of this Clique.

Returns

An array of Cliques that are neighbors of this Clique.

Example

neighbors = c.getNeighbors();

JunctionTree

JunctionTrees represents the junction trees in the compiled Domain.

JunctionTrees are acquired using the Domain.getJunctionTrees function.

Summary
Functions
getHAPIGet the HAPI object that owns this JunctionTree
cgEvidenceIsPropagatedCheck if CG evidence has been propagated in this JunctionTree.
equilibriumIsTests the Equilibrium type.
evidenceIsPropagatedTests if evidence has been propagated for this JunctionTree.
evidenceModeIsTests the EvidenceMode.
evidenceToPropagateTests if evidence has been entered since the last propagation.
getCliquesGet the list of Cliques in this JunctionTree.
getConflictGet the conflict measure of the data inserted in this JunctionTree.
getRootGet the root Clique of this JunctionTree.
getTotalCGSizeGet the total number of CG table entries for this JunctionTree.
getTotalSizeGet the total number of discrete table configurations for this JunctionTree.
likelihoodIsPropagatedTests if likelihoods have been propagated in this JunctionTree.
tablesToPropagateTests if this JunctionTree contains updated tables that have not been propagated.
propagatePropagates evidence in this JunctionTree.

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this JunctionTree

Returns

the owning HAPI instancs.

cgEvidenceIsPropagated

this.cgEvidenceIsPropagated = function cgEvidenceIsPropagated()

Check if CG evidence has been propagated in this JunctionTree.

Returns

Returns true if CG evidence has been propagated in this JunctionTree; otherwise, returns false.

Example

  • Check if evidence in JunctionTree ‘jt’ has been propagated:
cgIsPropagated = jt.cgEvidenceIsPropagated();

equilibriumIs

this.equilibriumIs = function equilibriumIs(equilibrium)

Tests the Equilibrium type.  Returns true if the equilibrium of this JunctionTree can be obtained through a propagation using equilibrium as the Equilibrium type; otherwise, returns false.

Parameters

equilibriumthe type of Equilibrium to test for.  The normal Equilibrium type is HAPI.H_EQUILIBRIUM_SUM.

Returns

Returns true if the equilibrium of this JunctionTree can be obtained through a propagation using equilibrium as the Equilibrium type; otherwise, returns false.

Example

result = jt.equilibriumIs(HAPI.H_EQUILIBRIUM_SUM);

evidenceIsPropagated

this.evidenceIsPropagated = function evidenceIsPropagated()

Tests if evidence has been propagated for this JunctionTree.

Returns

Returns true if evidence has been propagated; otherwise, returns false.

Example

  • Check if evidence in JunctionTree ‘jt’ has been propagated:
evidenceIsPropagated = jt.evidenceIsPropagated();

evidenceModeIs

this.evidenceModeIs = function evidenceModeIs(mode)

Tests the EvidenceMode.

Parameters

modethe type of EvidenceMode to test for.  The normal EvidenceMode type is HAPI.H_EVIDENCE_MODE_NORMAL.

Returns

Returns true if the EvidenceMode matches mode; otherwise, returns false.

Example

result = jt.evidenceModeIs(HAPI.H_EVIDENCE_MODE_NORMAL);

evidenceToPropagate

this.evidenceToPropagate = function evidenceToPropagate()

Tests if evidence has been entered since the last propagation.

Returns

Returns true if evidence has been entered since the last propagation; otherwise, returns false.

Example

result = jt.evidenceToPropagate();

getCliques

this.getCliques = function getCliques()

Get the list of Cliques in this JunctionTree.

Returns

An array of Cliques in this JunctionTree.

Example

cliques = jt.getCliques();

getConflict

this.getConflict = function getConflict()

Get the conflict measure of the data inserted in this JunctionTree.

Returns

Returns the conflict measure of the data inserted in this JunctionTree (a real number).

Example

conflict = jt.getConflict();

getRoot

this.getRoot = function getRoot()

Get the root Clique of this JunctionTree.

Returns

Returns the root Clique of this JunctionTree.

Example

root = jt.getRoot();

getTotalCGSize

this.getTotalCGSize = function getTotalCGSize()

Get the total number of CG table entries for this JunctionTree.  Both clique and separator table entries are counted.

Returns

total number of CG table entries for this JunctionTree.

Example

numEntries = jt.getTotalCGSize();

getTotalSize

this.getTotalSize = function getTotalSize()

Get the total number of discrete table configurations for this JunctionTree.  Both clique and separator table configurations are counted.  Also, if the junction tree has utility potentials, then the clique and separator configurations will effectively be counted twice.

Returns

total number of discrete table configurations for this JunctionTree.

Example

  • getn total number of discrete table configurations for JunctionTree ‘jt’:
numConf = jt.getTotalSize();

likelihoodIsPropagated

this.likelihoodIsPropagated = function likelihoodIsPropagated()

Tests if likelihoods have been propagated in this JunctionTree.

Returns

Returns true if likelihoods have been propagated in this JunctionTree; otherwise, returns false.

Example

  • Check if likelihoods in JunctionTree ‘jt’ has been propagated:
likelihoodIsPropagated = jt.likelihoodIsPropagated();

tablesToPropagate

this.tablesToPropagate = function tablesToPropagate()

Tests if this JunctionTree contains updated tables that have not been propagated.

Returns

Returns true if this JunctionTree contains updated tables that have not been propagated; otherwise, returns false.

Example

  • Check if JunctionTree ‘jt’ contains updated tables that have not been propagated:
result = jt.tablesToPropagate();

propagate

this.propagate = function propagate(equilibrium,
evidenceMode)

Propagates evidence in this JunctionTree.

Parameters

equilibriumEquilibrium type.  The normal Equilibrium type is HAPI.H_EQUILIBRIUM_SUM.
evidenceModeEvidenceMode type.  The normal EvidenceMode type is HAPI.H_EVIDENCE_MODE_NORMAL.

Returns

void

Example

jt.propagate(HAPI.H_EQUILIBRIUM_SUM, HAPI.H_EVIDENCE_MODE_NORMAL);

DataSet

Instances of the DataSet represents a data set as a “matrix” with cases as rows and variables as columns.

A DataSet is instantiated using one of the HAPI dataset functions HAPI.loadDataSet or HAPI.getNewDataSet.

Summary
Functions
getHAPIGet the HAPI object that owns this DataSet
deleteObjectDeletes this DataSet.
deleteColumnDeletes the specified column from this DataSet.
deleteRowDeletes the specified row from this DataSet.
getColumnNameReturns the name of the specified column of this DataSet.
getDataItemReturns the data item at the specified location of this DataSet.
getNumberOfColumnsReturns the number of columns in this DataSet.
getNumberOfRowsReturns the number of rows in this DataSet.
moveColumnMoves the specified column to a new position.
moveRowMoves the specified row to a new position.
newColumnCreates a new column in this DataSet.
newRowCreates a new row in this DataSet.
setColumnNameSets the name of the specified column of this DataSet.
setDataItemSets (or deletes) the data item at the specified location of this DataSet.
saveSubmits this DataSet in the form of a CSV file to the service located at a target URL.
downloadGenerate an URL for downloading this DataSet as a CSV file

Functions

getHAPI

this.getHAPI = function getHAPI()

Get the HAPI object that owns this DataSet

Returns

the owning HAPI instancs.

deleteObject

this.deleteObject = function deleteObject()

Deletes this DataSet.

Returns

void

Example

  • Delete the DataSet object ‘data’:
data.deleteObject();

deleteColumn

this.deleteColumn = function deleteColumn(column)

Deletes the specified column from this DataSet.

Parameters

columnthe index of the column to be deleted.

Returns

void

Example

  • Delete column 0 from dataset ‘d’:
d.deleteColumn(0);

deleteRow

this.deleteRow = function deleteRow(row)

Deletes the specified row from this DataSet.

Parameters

rowthe index of the row to be deleted.

Returns

void

Example

  • Delete row 10 from dataset ‘d’:
d.deleteRow(0);

getColumnName

this.getColumnName = function getColumnName(column)

Returns the name of the specified column of this DataSet.

Parameters

columnthe index of the column.

Returns

the column name string.

Example

  • get column name of column 1 in DataSet object ‘d’:
result = d.getColumnName(1);

getDataItem

this.getDataItem = function getDataItem(row,
column)

Returns the data item at the specified location of this DataSet.

Parameters

rowthe index of the row.
columnthe index of the column.

Returns

data item string.

Example

  • get data item at row 1 column 2 in DataSet object ‘d’:
result = d.getDataItem(1, 2);

getNumberOfColumns

this.getNumberOfColumns = function getNumberOfColumns()

Returns the number of columns in this DataSet.

Returns

an integer; the number of columns.

Example

  • get number of columns in DataSet object ‘d’:
result = d.getNumberOfColumns();

getNumberOfRows

this.getNumberOfRows = function getNumberOfRows()

Returns the number of rows in this DataSet.  Returns: an integer; the number of rows.

Example

  • get number of rows in DataSet object ‘d’:
result = d.getNumberOfRows();

moveColumn

this.moveColumn = function moveColumn(column,
newColumn)

Moves the specified column to a new position.  The columns between the old and the new column positions will be shifted one position to the left or to the right depending on the direction of the move.

Parameters

columnthe index of the column to be moved
newColumnthe index of the destination column

Returns

void

Example

  • Move column 0 to 2 in dataset ‘d’:
d.moveColumn(0, 2);

moveRow

this.moveRow = function moveRow(row,
newRow)

Moves the specified row to a new position.  The rows between the old and the new row positions will be shifted one position to the left or to the right depending on the direction of the move.

Parameters

rowthe index of the row to be moved.
newRowthe index of the destination row.

Returns

void

Example

  • Move row 0 to 2 in dataset ‘d’:
d.moveRow(0, 2);

newColumn

this.newColumn = function newColumn(name)

Creates a new column in this DataSet.

Parameters

namethe name of the new column.

Returns

integer; index of new column

Example

  • Create a new column ‘mycolumn’ in dataset ‘d’:
d.newColumn('mycolumn');

newRow

this.newRow = function newRow()

Creates a new row in this DataSet.

Returns

integer; index of new row

Example

  • Create a new row in dataset ‘d’:
d.newRow();

setColumnName

this.setColumnName = function setColumnName(column,
name)

Sets the name of the specified column of this DataSet.

Parameters

columnthe index of the column.
namethe new name of the column.

Returns

void

Example

  • Set column 2 name to ‘mynewname’ in dataset ‘d’:
d.setColumnName(2, 'mynewname');

setDataItem

this.setDataItem = function setDataItem(row,
column,
data)

Sets (or deletes) the data item at the specified location of this DataSet.

Parameters

rowthe index of the row.
columnthe index of the column.
datathe new data item (the empty string causes the item to be deleted).

Returns

void

Example

  • Set dataitem at row 10 column 2 to ‘mydata’ in dataset ‘d’:
d.setDataItem(10, 2, 'mydata');

save

this.save = function save(url,
method,
delimiter)

Submits this DataSet in the form of a CSV file to the service located at a target URL.

Parameters

URLthe URL to submit CSV file
methodthe HTTP method to use: POST | PUT
delimiterCSV delimiter character

Returns

void

Example

d.save("http://somehost/someservice", "POST", ";");

download

this.download = function download(delimiter,
filename)

Generate an URL for downloading this DataSet as a CSV file

Parameters

delimiterCSV delimiter character
filenameused for setting the Content-Disposition filename header of response.

Returns

the URL as a string

Example

  • generate an URL for downloading DataSet object ‘d’ as a CSV file:
url = d.download(',', "data.csv");

Globals

Summary
Constants
HAPI.H_CONSTRAINT_BACKWARD_EDGE_FORBIDDENRepresents the domain knowledge that a directed edge is forbidden from the second to the first Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_BACKWARD_EDGE_REQUIREDRepresents the domain knowledge that a directed edge is required from the second to the first Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_EDGE_FORBIDDENRepresents the domain knowledge that an edge is forbidden between a particular pair of Nodes.
HAPI.H_CONSTRAINT_EDGE_REQUIREDRepresents the domain knowledge that an edge is required for a particular pair of Nodes.
HAPI.H_CONSTRAINT_FORWARD_EDGE_FORBIDDENRepresents the domain knowledge that a directed edge is forbidden from the first to the second Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_FORWARD_EDGE_REQUIREDRepresents the domain knowledge that a directed edge is required from the first to the second Node in an ordered pair of Nodes.
HAPI.H_CONSTRAINT_NONERepresents that no domain knowledge is available for a particular pair of Nodes.
HAPI.H_TM_BEST_GREEDYRepresents the best-greedy triangulation heuristic.
HAPI.H_TM_CLIQUE_SIZERepresents the clique-size triangulation heuristic.
HAPI.H_TM_CLIQUE_WEIGHTRepresents the clique-weight triangulation heuristic.
HAPI.H_TM_FILL_IN_SIZERepresents the fill-in-size triangulation heuristic.
HAPI.H_TM_FILL_IN_WEIGHTRepresents the fill-in-weight triangulation heuristic.
HAPI.H_TM_TOTAL_WEIGHTRepresents the total clique-table size triangulation algorithm.
HAPI.H_EVIDENCE_MODE_NORMALRepresents the normal evidence mode used for propagating evidence in this Domain.
HAPI.H_EVIDENCE_MODE_FAST_RETRACTIONRepresents the fast retraction evidence mode used for propagating evidence in this Domain.
HAPI.H_EQUILIBRIUM_MAXRepresents max equilibrium.
HAPI.H_EQUILIBRIUM_SUMRepresents sum equilibrium.
HAPI.H_CATEGORY_DECISIONRepresents the Category tag attached to DecisionNodes.
HAPI.H_CATEGORY_FUNCTIONRepresents the Category tag attached to FunctionNodes.
HAPI.H_CATEGORY_UTILITYRepresents the Category tag attached to UtilityNodes.
HAPI.H_CATEGORY_CHANCERepresents the Category tag attached to ChanceNodes.
HAPI.H_CATEGORY_INSTANCERepresents the Category tag attached to InstanceNodes.
HAPI.H_KIND_CONTINUOUSRepresents the Kind tag attached to continuous nodes.
HAPI.H_KIND_DISCRETERepresents the Kind tag attached to discrete nodes.
HAPI.H_KIND_OTHERRepresents the Kind tag attached to utility, function, and instance nodes.
HAPI.H_SUBTYPE_NUMBERRepresents the discrete node subtype for numbered nodes
HAPI.H_SUBTYPE_INTERVALRepresents the discrete node subtype for interval nodes
HAPI.H_SUBTYPE_BOOLEANRepresents the discrete node subtype for boolean nodes
HAPI.H_SUBTYPE_LABELRepresents the discrete node subtype for labelled nodes
HAPI.H_SUBTYPE_OTHERSubtype placeholder for specifying node other than discrete.

Constants

HAPI.H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN

Represents the domain knowledge that a directed edge is forbidden from the second to the first Node in an ordered pair of Nodes.

HAPI.H_CONSTRAINT_BACKWARD_EDGE_REQUIRED

Represents the domain knowledge that a directed edge is required from the second to the first Node in an ordered pair of Nodes.

HAPI.H_CONSTRAINT_EDGE_FORBIDDEN

Represents the domain knowledge that an edge is forbidden between a particular pair of Nodes.

HAPI.H_CONSTRAINT_EDGE_REQUIRED

Represents the domain knowledge that an edge is required for a particular pair of Nodes.

HAPI.H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN

Represents the domain knowledge that a directed edge is forbidden from the first to the second Node in an ordered pair of Nodes.

HAPI.H_CONSTRAINT_FORWARD_EDGE_REQUIRED

Represents the domain knowledge that a directed edge is required from the first to the second Node in an ordered pair of Nodes.

HAPI.H_CONSTRAINT_NONE

Represents that no domain knowledge is available for a particular pair of Nodes.

HAPI.H_TM_BEST_GREEDY

Represents the best-greedy triangulation heuristic.

HAPI.H_TM_CLIQUE_SIZE

Represents the clique-size triangulation heuristic.

HAPI.H_TM_CLIQUE_WEIGHT

Represents the clique-weight triangulation heuristic.

HAPI.H_TM_FILL_IN_SIZE

Represents the fill-in-size triangulation heuristic.

HAPI.H_TM_FILL_IN_WEIGHT

Represents the fill-in-weight triangulation heuristic.

HAPI.H_TM_TOTAL_WEIGHT

Represents the total clique-table size triangulation algorithm.

HAPI.H_EVIDENCE_MODE_NORMAL

Represents the normal evidence mode used for propagating evidence in this Domain.

HAPI.H_EVIDENCE_MODE_FAST_RETRACTION

Represents the fast retraction evidence mode used for propagating evidence in this Domain.

HAPI.H_EQUILIBRIUM_MAX

Represents max equilibrium.

HAPI.H_EQUILIBRIUM_SUM

Represents sum equilibrium.

HAPI.H_CATEGORY_DECISION

Represents the Category tag attached to DecisionNodes.

HAPI.H_CATEGORY_FUNCTION

Represents the Category tag attached to FunctionNodes.

HAPI.H_CATEGORY_UTILITY

Represents the Category tag attached to UtilityNodes.

HAPI.H_CATEGORY_CHANCE

Represents the Category tag attached to ChanceNodes.

HAPI.H_CATEGORY_INSTANCE

Represents the Category tag attached to InstanceNodes.

HAPI.H_KIND_CONTINUOUS

Represents the Kind tag attached to continuous nodes.

HAPI.H_KIND_DISCRETE

Represents the Kind tag attached to discrete nodes.

HAPI.H_KIND_OTHER

Represents the Kind tag attached to utility, function, and instance nodes.

HAPI.H_SUBTYPE_NUMBER

Represents the discrete node subtype for numbered nodes

HAPI.H_SUBTYPE_INTERVAL

Represents the discrete node subtype for interval nodes

HAPI.H_SUBTYPE_BOOLEAN

Represents the discrete node subtype for boolean nodes

HAPI.H_SUBTYPE_LABEL

Represents the discrete node subtype for labelled nodes

HAPI.H_SUBTYPE_OTHER

Subtype placeholder for specifying node other than discrete.

function HAPI(webServiceHome)
Initializes a new instance of the HAPI class and binds it internally to the RESTful HUGIN Web Service API.
The HUGIN Web Service API exposes a RESTful HTTP interface for interacting with the HUGIN decision engine.
this.getNewClassCollection = function getNewClassCollection()
Construct an empty classcollection.
this.loadClassCollection = function loadClassCollection(url)
Construct a classcollection from a HUGIN Knowledge Base retrieved over HTTP.
this.loadDomain = function loadDomain(url)
Instantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.
Instances of the Domain class represent Bayesian networks and LIMIDs in which you can propagate evidence and calculate updated beliefs and expected utilities.
this.loadCompileDomain = function loadCompileDomain(url)
Instantiates a Domain object from a HUGIN Knowledge Base (HKB) file located at specifid URL.
this.getNewDomain = function getNewDomain()
Constructs a new empty Domain.
this.loadDataSet = function loadDataSet(url,
delimiter)
Instantiate a DataSet from a CSV file retrieved over HTTP.
Instances of the DataSet represents a data set as a “matrix” with cases as rows and variables as columns.
this.getNewDataSet = function getNewDataSet()
Construct an empty DataSet.
this.refetch = function refetch(huginObject)
Refetch cached responses from remote decision engine.
this.getNewBatch = function getNewBatch()
Constructs a new Batch object.
A Batch can be used to group together a sequence of batchable function calls and then carry out the function calls using a single HTTP request - effectively saving the round-trip-time delay of having to perform individual HTTP requests for each function.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this Batch
The HAPI class is a container for all functionality in the JavaScript for HUGIN Web Service API.
this.reset = function reset()
Reset the Batch.
this.add = function add(command //,
 arg1,
 arg2,
 arg3,
 ...,
 argN)
Add a function call to the Batch queue.
this.execute = function execute()
Execute the queued up function calls in a synchronously blocking fashion.
this.dispatch = function dispatch(onSuccess,
onError)
Dispatch execution of queued up function calls in an asynchronously non-blocking fashion.
Instances of Class represent object-oriented Bayesian networks and LIMIDs.
Classes are grouped into ClassCollections.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this ClassCollection
this.deleteObject = function deleteObject()
Deletes this ClassCollection object, including all nested HUGIN objects belonging to it (e.g.
this.getClassByName = function getClassByName(name)
Returns a Class by name.
this.getMembers = function getMembers()
Get all Classes of this ClassCollection.
this.save = function save(url,
method)
Submits this ClassCollection in the form of a HKB file to the service located at a target URL.
this.download = function download(filename)
Generate an URL for downloading this ClassCollection as a HKB file
this.getNewClass = function getNewClass(name)
Creates a new Class.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this NetworkModel
NetworkModel interface is implemented by Class and Domain.
this.getNodeByName = function getNodeByName(name)
Returns a Node by name.
Nodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs.
this.getNewNode = function getNewNode(category,
kind,
subtype)
Creates a new Node.
this.getNodes = function getNodes()
Get all Nodes in this NetworkModel.
this.generateTables = function generateTables()
Generates the conditional probability tables for all nodes of this NetworkModel.
this.getAttribute = function getAttribute(key)
Returns an attribute value.
this.parseNodes = function parseNodes(url)
Parses the file retrieved from an URL and returns a list of Nodes.
this.setAttribute = function setAttribute(key,
value)
Inserts the key/value pair in the attribute list for this NetworkModel.
this.deleteObject = function deleteObject()
Deletes this Class, including all Node objects belonging to it.
this.createDBNDomain = function createDBNDomain(numberOfSlices)
Creates a DBN runtime Domain from this Class.
this.createDomain = function createDomain()
Creates a flat runtime Domain from this Class.
this.getNewInstanceNode = function getNewInstanceNode(instanceOf)
Creates a new instance Node.
this.getClassCollection = function getClassCollection()
Get the ClassCollection to which this Class belongs.
this.getInputs = function getInputs()
Get all input Nodes defined for this Class.
this.getInstances = function getInstances()
Get all instance Nodes that are instances of this Class.
this.getOutputs = function getOutputs()
Get all output Nodes defined for this Class.
this.getName = function getName()
Returns the name of this Class.
this.setName = function setName(name)
Sets the name of this Class.
this.deleteObject = function deleteObject()
Deletes this Domain, including all Node and JunctionTree objects belonging to it.
JunctionTrees represents the junction trees in the compiled Domain.
this.parseCase = function parseCase(url)
Parses a case retrieved from an URL and enters the associated findings into this Domain.
this.saveCase = function saveCase(url,
method)
Submits all evidence entered in this Domain to the service located at a target URL.
this.save = function save(url,
method)
Submits this Domain in the form of a HKB file to the service located at a target URL.
this.download = function download(filename)
Generate an URL for downloading this Domain as a HKB file
this.parseCases = function parseCases(url)
Parses the cases retrieved form an URL and enters the cases into this Domain.
this.saveCases = function saveCases(url,
method,
nodes,
cases,
caseCounts,
separator,
missingData)
Submits all cases in this Domain to the service located at a target URL.
this.propagate = function propagate(equilibrium,
evidenceMode)
Establishes the specified equilibrium using the evidence mode indicated for incorporation of evidence on all JunctionTrees of this Domain.
this.compile = function compile()
Compiles this Domain.
this.adapt = function adapt()
Adapts this Domain according to the evidence entered.
this.adaptClassTablesUsingFractionalUpdate = function adaptClassTablesUsingFractionalUpdate()
For each discrete node of this Domain (which must be a runtime domain) such that both the node and its source node have experience tables, the conditional probability and experience tables of both nodes are learned/updated, and the tables of the domain node will be identical to those of its source node.
this.adaptClassTablesUsingOnlineEM = function adaptClassTablesUsingOnlineEM()
This function updates (adapts), for all discrete chance nodes of this Domain, the experience count (retrieval of experience) and the conditional probability distribution (dissemination of experience) for all parent configurations having a valid experience count.
this.approximate = function approximate(epsilon)
Removes “near-zero” probabilities from the clique probability tables.
this.cgEvidenceIsPropagated = function cgEvidenceIsPropagated()
Check if evidence on CG nodes has been propagated.
this.evidenceIsPropagated = function evidenceIsPropagated()
Tests if evidence has been propagated for this Domain.
this.evidenceToPropagate = function evidenceToPropagate()
Tests if evidence has been entered since the last propagation.
this.retractFindings = function retractFindings()
Retracts (all) evidence for all nodes in this Domain.
this.getNewModel = function getNewModel(belongsTo,
modelNodes)
Constructs a Model over a Node given a list of Nodes.
A Model is a compact description of a table.
this.getExpectedUtility = function getExpectedUtility()
Gets the total expected utility associated with this Domain.
this.isCompiled = function isCompiled()
Tests whether this Domain is compiled.
this.isTriangulated = function isTriangulated()
Tests whether this Domain is triangulated.
this.isTriangulatedForBK = function isTriangulatedForBK()
Tests whether this Domain has been triangulated for Boyen-Koller approximate inference.
this.initialize = function initialize()
Establishes the initial values for all tables of this Domain (which must be compiled).
this.getJunctionTrees = function getJunctionTrees()
Gets all JunctionTrees of this Domain.
this.compress = function compress()
Removes the zero entries from the clique and separator tables of the junction trees in this Domain.
this.computeSensitivityData = function computeSensitivityData(nodes,
states)
Computes the constants of the sensitivity functions for the specified output probabilities and all CPT parameters in the network.
this.getLogLikelihood = function getLogLikelihood()
Computes the log-likelihood of the case data.
this.getLogLikelihoodTolerance = function getLogLikelihoodTolerance()
Returns the log-likelihood tolerance for this Domain.
this.getLogNormalizationConstant = function getLogNormalizationConstant()
Returns the log of the normalization constant.
this.getMAPConfiguration = function getMAPConfiguration(index)
Returns a MAP configuration.
this.getMarginal = function getMarginal(nodes)
Computes the marginal distribution for the Nodes provided as argument with respect to the (imaginary) joint potential, determined by the current potentials on the JunctionTrees of this Domain.
this.getMaxNumberOfEMIterations = function getMaxNumberOfEMIterations()
Returns the maximum number of iterations allowed for the EM algorithm.
this.getMaxNumberOfSeparators = function getMaxNumberOfSeparators()
Returns the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.
Represents the total clique-table size triangulation algorithm.
this.getNormalDeviate = function getNormalDeviate(mean,
variance)
Use the pseudo-random number generator for this Domain to sample a real number from a normal (aka Gaussian) distribution.
this.getNormalizationConstant = function getNormalizationConstant()
Retrieves the normalization constant for the most recent propagation.
this.getNumberOfCases = function getNumberOfCases()
Returns the number of data cases.
this.getNumberOfMAPConfigurations = function getNumberOfMAPConfigurations()
Returns the number of MAP configurations.
this.getProbabilityOfMAPConfiguration = function getProbabilityOfMAPConfiguration(
   index
)
Returns the probability of a MAP configuration.
this.getSensitivitySet = function getSensitivitySet()
Returns the sensitivity set computed by the most recent call to Domain.computeSensitivityData.
this.getSignificanceLevel = function getSignificanceLevel()
Returns the significance level of the dependency tests performed during structure learning using the PC-algorithm.
this.getUniformDeviate = function getUniformDeviate()
Use the pseudo-random number generator for this Domain to sample a real number from the uniform distribution over the interval [0,1).
this.enterCase = function enterCase(index)
Enters a case as evidence.
this.equilibriumIs = function equilibriumIs(equilibrium)
Tests the Equilibrium type.
this.isCompressed = function isCompressed()
Tests whether this Domain is compressed.
this.evidenceModeIs = function evidenceModeIs(mode)
Tests for evidence mode.
this.learnStructure = function learnStructure()
Learn the structure (graph) of the Bayesian network from data using the PC-algorithm.
this.learnTables = function learnTables()
Learns the conditional probability tables from data using the EM algorithm.
this.likelihoodIsPropagated = function likelihoodIsPropagated()
Tests if likelihood has been propagated for this Domain
this.newCase = function newCase()
Creates a new case.
this.findMAPConfigurations = function findMAPConfigurations(nodes,
minprobability)
Finds all configurations of nodes with probability at least minprobability.
this.getAIC = function getAIC()
Computes the AIC score (Akaike’s Information Criterion) of the case data.
this.getApproximationConstant = function getApproximationConstant()
Returns the approximation constant.
this.getBIC = function getBIC()
Computes the BIC score (Bayesian Information Criterion) of the case data.
this.getCaseCount = function getCaseCount(caseindex)
Returns case count for a case.
this.getConflict = function getConflict()
Returns the conflict value.
this.getDConnectedNodes = function getDConnectedNodes(source,
hard,
soft)
Performs a d-separation test and returns a list of d-connected nodes.
this.getDSeparatedNodes = function getDSeparatedNodes(source,
hard,
soft)
Performs a d-separation test and returns a list of d-separated nodes.
this.getEliminationOrder = function getEliminationOrder()
Returns the triangulation order.
this.resetInferenceEngine = function resetInferenceEngine()
Establishes the initial state of the inference engine, which is sum-equilibrium with no evidence incorporated.
this.saveToMemory = function saveToMemory()
Creates a copy in memory of the belief and junction tree tables of this Domain.
this.seedRandom = function seedRandom(seed)
Seeds the pseudo-random number generator for this Domain.
this.setCaseCount = function setCaseCount(caseindex,
count)
Sets case count for a case.
this.setLogLikelihoodTolerance = function setLogLikelihoodTolerance(tolerance)
Sets the log-likelihood tolerance for this Domain.
this.setMaxNumberOfEMIterations = function setMaxNumberOfEMIterations(maxnumber)
Sets the maximum number of iterations allowed for the EM algorithm.
this.setMaxNumberOfSeparators = function setMaxNumberOfSeparators(maxnumber)
Sets the maximum number of separators allowed when using the HAPI.H_TM_TOTAL_WEIGHT triangulation method.
this.setNumberOfCases = function setNumberOfCases(size)
Sets the number of cases.
this.setSignificanceLevel = function setSignificanceLevel(alpha)
Sets the significance level of the dependency tests performed during structure learning using the PC-algorithm.
this.simulate = function simulate()
Generates a sample configuration from the joint distribution represented by this Domain.
this.batchSimulate = function batchSimulate(iterations,
nodes)
Generates a number of sample configurations by invoking Domain.simulate a number of times and for each iteration recording the results of Node.getSampledValue, Node.getSampledState or Node.getSampledUtility for specified Nodes.
this.getSampledValue = function getSampledValue()
Returns the value of this function or continuous chance Node for the configuration generated by the most recent call to Domain.simulate.
this.getSampledState = function getSampledState()
Returns the state index of this discrete node for the configuration generated by the most recent call to Domain.simulate.
this.getSampledUtility = function getSampledUtility()
Returns the sampled utility associated with this utility node.
this.tablesToPropagate = function tablesToPropagate()
Tests for new node tables.
this.triangulate = function triangulate()
Triangulates the graph of this Domain using the default triangulation method.
this.uncompile = function uncompile()
Uncompiles this Domain.
this.updatePolicies = function updatePolicies()
Updates the policy tables of the domain.
this.getExplanation = function getExplanation(index)
Returns the evidence subset associated with the explanation of rank index computed by the most recent call to Node.computeExplanationData.
this.computeExplanationData = function computeExplanationData(x,
Y,
y,
maxSubsetSize)
Computes Bayes factor data for all (nonempty) subsets of evidence nodes up to the specified maximum size.
this.getExplanationScore = function getExplanationScore(index)
Returns the score of the specified explanation.
this.getNumberOfExplanations = function getNumberOfExplanations()
Returns the number of explanations.
this.addCases = function addCases(data,
start,
count)
Adds the specified range of rows of the data set to this Domain as cases.
this.computeDBNPredictions = function computeDBNPredictions()
Computes predictions for {numberOfTimePoints} time slices beyond the current time window.
this.getDBNWindowOffset = function getDBNWindowOffset()
Returns the total number of time steps that the time window of this DBN runtime domain has been moved.
this.initializeDBNWindow = function initializeDBNWindow()
Moves the time window of this DBN back to its initial position, and removes all evidence.
this.moveDBNWindow = function moveDBNWindow()
Slides the time window of this DBN delta steps into the future.
this.triangulateDBN = function triangulateDBN(tm)
Triangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.
this.triangulateDBNForBK = function triangulateDBNForBK(tm)
Triangulates a Domain produced by Class.createDBNDomain such that Domain.moveDBNWindow can be used.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this Node
this.deleteObject = function deleteObject()
Deletes this Node.
this.getModel = function getModel()
Gets the Model for this Node.
this.getName = function getName()
Returns the name of this Node.
this.setName = function setName(name)
Sets the name of this Node.
this.setPosition = function setPosition(X,
Y)
Sets the position of this Node.
this.getPositionX = function getPositionX()
Returns the position of this Node on the X-axis.
this.getPositionY = function getPositionY()
Returns the position of this Node on the Y-axis.
this.setNumberOfStates = function setNumberOfStates(stateCount)
Sets the number of states of this node.
this.getNumberOfStates = function getNumberOfStates()
Get the number of states of this discrete node.
this.setStateLabel = function setStateLabel(state,
newLabel)
Sets the label of the specified state.
this.getStateLabel = function getStateLabel(state)
Gets the label of the specified state.
this.getTable = function getTable()
Gets the Table associated with this Node.
Hugin uses Tables for representing the conditional probability and utility potentials of individual Nodes, the probability and utility potentials on separators and Cliques of JunctionTrees, evidence potentials, etc.
this.getBelief = function getBelief(state)
Gets the belief for the specified state of this Node.
this.getParents = function getParents()
Get an array of parent Nodes for this Node.
this.getChildren = function getChildren()
Get an array of child Nodes for this Node.
this.addParent = function addParent(parentNode)
Adds a Node as a new parent of this Node.
this.selectState = function selectState(state)
Selects the specified state of this Node.
this.getSelectedState = function getSelectedState()
Gets (the index of) the selected state of this node.
this.retractFindings = function retractFindings()
Retracts all findings for this Node.
this.getExpectedUtility = function getExpectedUtility(state)
Gets the expected utility associated with this utility node or specified action of this discrete node.
this.getValue = function getValue()
Gets the value of this FunctionNode.
this.setValue = function setValue(value)
Sets the function associated with this function node to a number value.
this.evidenceIsEntered = function evidenceIsEntered()
Test if the evidence potential, currently registered with this Node, is non-vacuous.
this.getStateIndex = function getStateIndex(value)
Get the index of the state matching the specified value.
this.getStateValue = function getStateValue(state)
Gets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.
this.setStateValue = function setStateValue(state,
value)
Sets the value associated with a particular state of this numbered node or the low value of the interval associated with a particular state of this interval node.
this.enterValue = function enterValue(value)
Enters evidence (observation of the value) for this continuous chance node.
this.getEnteredValue = function getEnteredValue()
Gets the evidence (value) entered for this continuous chance node.
this.evidenceIsPropagated = function evidenceIsPropagated()
Returns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is non-vacuous; otherwise, returns false.
this.evidenceToPropagate = function evidenceToPropagate()
Returns true if the entered and the propagated evidence differ; otherwise, returns false.
this.getAttribute = function getAttribute(key)
Returns an attribute value.
this.getCategory = function getCategory()
Returns the category of this Node.
this.getEdgeConstraint = function getEdgeConstraint(node)
Returns the constraint between this and Node.
this.getHomeDomain = function getHomeDomain()
Returns the Domain containing this Node.
this.getJunctionTree = function getJunctionTree()
Returns the JunctionTree to which this Node belongs.
this.getKind = function getKind()
Returns the kind of this Node.
this.getSubtype = function getSubtype()
Returns the subtype of this Node.
this.getLabel = function getLabel()
Returns the label of this Node.
this.likelihoodIsPropagated = function likelihoodIsPropagated()
Returns true if the evidence potential for this Node, incorporated within the current junction tree potentials, is a likelihood; otherwise, returns false.
this.likelihoodIsEntered = function likelihoodIsEntered()
Returns true if the evidence potential, currently registered with this Node, is a likelihood; otherwise, returns false.
this.removeParent = function removeParent(node)
Removes the directed link between a parent and this Node.
this.reverseEdge = function reverseEdge(node)
Reverses the edge between this Node and the specified neighbor.
this.setAttribute = function setAttribute(key,
value)
Sets a value for a particular attribute in the attribute list for this Node.
this.setEdgeConstraint = function setEdgeConstraint(node,
constraint)
Sets a constraint between this Node and another Node.
this.setLabel = function setLabel(label)
Sets the label of this Node.
this.switchParent = function switchParent(oldParent,
newParent)
Replace the given parent node with the new node.
this.caseIsSet = function caseIsSet(caseindex)
Returns true if a value has been set for this continuous chance or discete node in case caseindex; otherwise, returns false.
this.getAlpha = function getAlpha(i)
Returns the alpha component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.
this.getBeta = function getBeta(parent,
i)
Returns the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.
this.getCaseValue = function getCaseValue(caseindex)
Returns the value set for this continuous chance node in case caseindex.
this.getDistribution = function getDistribution()
Returns the distribution for this continuous node.
this.getExperienceTable = function getExperienceTable()
Returns the experience table of this continuous or discrete chance node.
this.getGamma = function getGamma(i)
Returns the gamma component of the CG distribution of this continuous chance node given the discrete parent configuration corresponding to i.
this.getMean = function getMean()
Returns the mean of the marginal distribution of this continuous chance node.
this.getPropagatedValue = function getPropagatedValue()
Retrieves the value that has been propagated for this continuous chance Node.
this.getVariance = function getVariance()
Returns the variance of the marginal distribution of this continuous chance Node.
this.hasExperienceTable = function hasExperienceTable()
Returns true if this continuous or discrete chance Node has an experience table; returns false otherwise.
this.setAlpha = function setAlpha(alpha,
i)
Sets the alpha component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.
this.setBeta = function setBeta(beta,
parent,
i)
Sets the beta component of the CG distribution of this continuous chance node given a continuous parent and the discrete parent configuration corresponding to i.
this.setCaseValue = function setCaseValue(c,
value)
Sets the value of this continuous chance node to value in case c.
this.setGamma = function setGamma(gamma,
i)
Sets the gamma component of the CG distribution of this continuous chance Node given the discrete parent configuration corresponding to i.
this.unsetCase = function unsetCase(caseindex)
Specifies that the value of this continuous chance or discrete node is “unknown” for case caseindex.
this.computeSensitivityData = function computeSensitivityData(state)
Computes the constants of the sensitivity functions for the specified output probability and all CPT/policy parameters in the network.
this.getFadingTable = function getFadingTable()
Returns the fading table of this discrete chance node.
this.hasFadingTable = function hasFadingTable()
Returns true if this discrete chance Node has a fading table; returns false otherwise.
this.getRequisiteAncestors = function getRequisiteAncestors()
Get an array of Nodes containing the requisite ancestors of this decision Node.
this.getRequisiteParents = function getRequisiteParents()
Get an array of Nodes containing the requisite parents of this decision Node.
this.enterFinding = function enterFinding(state,
finding)
Specifies a finding value for a given state with all other states unaffected.
this.generateTable = function generateTable()
Generates the table of this discrete Node from its Model (a missing Model will trigger an error).
this.getCaseState = function getCaseState(c)
Returns the state of this discrete node for case c.
this.getEnteredFinding = function getEnteredFinding(state)
Returns the entered finding for the specified state of this node.
this.getEntropy = function getEntropy()
Computes the entropy of this node.
this.getMutualInformation = function getMutualInformation(node)
Computes the mutual information between this discrete Node and the specified discrete Node.
this.getPropagatedFinding = function getPropagatedFinding(state)
Returns the propagated finding.
this.getSensitivityConstants = function getSensitivityConstants(input)
Returns the four constants of the specified sensitivity function.
this.getSensitivityConstantsByOutput = function getSensitivityConstantsByOutput(
   input,
   output
)
Returns the four constants of the specified sensitivity function.
this.setCaseState = function setCaseState(c,
state)
Sets the state of this discrete node to state in case c.
this.getStateIndexFromLabel = function getStateIndexFromLabel(label)
Returns the index of the state matching the specified label.
this.computeExplanationData2 = function computeExplanationData2(x,
maxSubsetSize)
Computes “normalized likelihoods” for the specified hypothesis and all (nonempty) subsets of evidence nodes up to the specified maximum size.
this.addToInputs = function addToInputs()
Makes this Node become an input node of its Class.
this.addToOutputs = function addToOutputs()
Makes this Node become an output node of its Class.
this.createTemporalClone = function createTemporalClone()
Constructs a temporal clone of this Node.
this.getHome = function getHome()
Returns the NetworkModel containing this Node.
this.getHomeClass = function getHomeClass()
Returns the Class containing this Node.
this.getInstance = function getInstance()
Returns the instance Node containing this (cloned) output node.
this.getMaster = function getMaster()
Returns the “master” of this (cloned) output Node of an instance node (i.e., the node cloned to get this output node).
this.getSource = function getSource()
Get an array of Nodes of Class nodes that identifies this Domain node.
this.getTemporalClone = function getTemporalClone()
Get the “temporal clone” of this Node.
this.getTemporalMaster = function getTemporalMaster()
Get the “temporal master” of this Node.
this.removeFromInputs = function removeFromInputs()
Removes this Node from the set of input nodes of its class.
this.removeFromOutputs = function removeFromOutputs()
Removes this Node from the set of output nodes of its class.
this.getPredictedBelief = function getPredictedBelief(state,
time)
Returns the predicted belief for the specified state of this discrete Node at the specified time point.
this.getPredictedValue = function getPredictedValue(time)
Gets the predicted value of this FunctionNode at the specified time point.
this.getPredictedMean = function getPredictedMean(time)
Returns the predicted mean of the marginal distribution of this continuous chance node at the specified time point.
this.getPredictedVariance = function getPredictedVariance(time)
Returns the predicted variance of the marginal distribution of this continuous chance node at the specified time point.
Cliques represents the cliques in the junction tree.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this Table
this.deleteObject = function deleteObject()
Deletes this Table.
this.getSize = function getSize()
Get the size of this Table.
this.getNodes = function getNodes()
Get all Nodes associated with this Table.
this.getDataItem = function getDataItem(index)
Get the data item at position index of the discrete data of this Table.
this.setDataItem = function setDataItem(index,
value)
Sets a specific data item of the discrete data of this Table.
this.setData = function setData(data,
startIndex,
count)
Sets a region of the discrete data of this Table.
this.getData = function getData(startIndex,
count)
Gets a region of the discrete data of this Table.
this.getMean = function getMean(index,
node)
Get the mean of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.
this.getVariance = function getVariance(index,
node)
Get the variance of a continuous chance Node given a configuration of the discrete chance Nodes of this Table.
this.getCovariance = function getCovariance(index,
node1,
node2)
Get the covariance of a pair of continuous chance Nodes given a configuration of the discrete chance Nodes of this Table.
this.computeProbabilityOfInterval = function computeProbabilityOfInterval(x,
y)
Compute the probability of a given interval for the mixture distribution represented by this Table.
this.reorderNodes = function reorderNodes(nodes)
Reorders the list of Nodes of this Table.
this.getCGSize = function getCGSize()
Returns the CG size of this Table.
this.setAllDataItems = function setAllDataItems(value)
Sets all data items of the discrete data of this Table.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this Model
this.deleteObject = function deleteObject()
Deletes this Model.
this.setExpression = function setExpression(index,
expression)
Associates an expression (specified as a string) with a specific configuration of the Nodes of this Model.
this.getExpression = function getExpression(index)
Returns the expression (as a string) associated with a specific configuration of the NodeResources of this ModelResource.
Nodes are one of the fundamental objects used in the construction of Bayesian networks and LIMIDs.
A Model is a compact description of a table.
this.setNumberOfSamplesPerInterval = function setNumberOfSamplesPerInterval(
   count
)
Sets the number of values taken within each bounded interval of an interval parent when generating the conditional probability table for a node with interval parents.
this.getNumberOfSamplesPerInterval = function getNumberOfSamplesPerInterval()
Gets the number of values per interval used when generating the conditional probability table for a node with interval parents.
this.getSize = function getSize()
Returns the number of configurations of the Node of this Model.
this.getNodes = function getNodes()
Get all Nodes in this Model.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this Clique
this.getJunctionTree = function getJunctionTree()
Get the JunctionTree to which this Clique belongs.
this.getMembers = function getMembers()
Get the list of Nodes that are members of this Clique.
this.getNeighbors = function getNeighbors()
Get a list of Cliques that are neighbors of this Clique.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this JunctionTree
this.cgEvidenceIsPropagated = function cgEvidenceIsPropagated()
Check if CG evidence has been propagated in this JunctionTree.
this.equilibriumIs = function equilibriumIs(equilibrium)
Tests the Equilibrium type.
this.evidenceIsPropagated = function evidenceIsPropagated()
Tests if evidence has been propagated for this JunctionTree.
this.evidenceModeIs = function evidenceModeIs(mode)
Tests the EvidenceMode.
this.evidenceToPropagate = function evidenceToPropagate()
Tests if evidence has been entered since the last propagation.
this.getCliques = function getCliques()
Get the list of Cliques in this JunctionTree.
this.getConflict = function getConflict()
Get the conflict measure of the data inserted in this JunctionTree.
this.getRoot = function getRoot()
Get the root Clique of this JunctionTree.
this.getTotalCGSize = function getTotalCGSize()
Get the total number of CG table entries for this JunctionTree.
this.getTotalSize = function getTotalSize()
Get the total number of discrete table configurations for this JunctionTree.
this.likelihoodIsPropagated = function likelihoodIsPropagated()
Tests if likelihoods have been propagated in this JunctionTree.
this.tablesToPropagate = function tablesToPropagate()
Tests if this JunctionTree contains updated tables that have not been propagated.
this.propagate = function propagate(equilibrium,
evidenceMode)
Propagates evidence in this JunctionTree.
this.getHAPI = function getHAPI()
Get the HAPI object that owns this DataSet
this.deleteObject = function deleteObject()
Deletes this DataSet.
this.deleteColumn = function deleteColumn(column)
Deletes the specified column from this DataSet.
this.deleteRow = function deleteRow(row)
Deletes the specified row from this DataSet.
this.getColumnName = function getColumnName(column)
Returns the name of the specified column of this DataSet.
this.getDataItem = function getDataItem(row,
column)
Returns the data item at the specified location of this DataSet.
this.getNumberOfColumns = function getNumberOfColumns()
Returns the number of columns in this DataSet.
this.getNumberOfRows = function getNumberOfRows()
Returns the number of rows in this DataSet.
this.moveColumn = function moveColumn(column,
newColumn)
Moves the specified column to a new position.
this.moveRow = function moveRow(row,
newRow)
Moves the specified row to a new position.
this.newColumn = function newColumn(name)
Creates a new column in this DataSet.
this.newRow = function newRow()
Creates a new row in this DataSet.
this.setColumnName = function setColumnName(column,
name)
Sets the name of the specified column of this DataSet.
this.setDataItem = function setDataItem(row,
column,
data)
Sets (or deletes) the data item at the specified location of this DataSet.
this.save = function save(url,
method,
delimiter)
Submits this DataSet in the form of a CSV file to the service located at a target URL.
this.download = function download(delimiter,
filename)
Generate an URL for downloading this DataSet as a CSV file
The JavaScript for HUGIN Web Service API provides a scripting interface to the HUGIN Web Service API for using HUGIN in a browser context.
The HUGIN Widgets Library is a tool-box of UI elements for exercising the Javascript for HUGIN Web services API through point-and-click on a web page.
Represents the Category tag attached to ChanceNodes.
Represents the Category tag attached to DecisionNodes.
Represents the Category tag attached to UtilityNodes.
Represents the Category tag attached to FunctionNodes.
Represents the Kind tag attached to discrete nodes.
Represents the Kind tag attached to continuous nodes.
Represents the Kind tag attached to utility, function, and instance nodes.
Represents the discrete node subtype for labelled nodes
Represents the discrete node subtype for boolean nodes
Represents the discrete node subtype for numbered nodes
Represents the discrete node subtype for interval nodes
Subtype placeholder for specifying node other than discrete.
Represents sum equilibrium.
Represents the normal evidence mode used for propagating evidence in this Domain.
Generates a sample configuration from the joint distribution represented by this DomainResource.
Represents the Category tag attached to InstanceNodes.
Represents the domain knowledge that a directed edge is forbidden from the second to the first Node in an ordered pair of Nodes.
Represents the domain knowledge that a directed edge is required from the second to the first Node in an ordered pair of Nodes.
Represents the domain knowledge that an edge is forbidden between a particular pair of Nodes.
Represents the domain knowledge that an edge is required for a particular pair of Nodes.
Represents the domain knowledge that a directed edge is forbidden from the first to the second Node in an ordered pair of Nodes.
Represents the domain knowledge that a directed edge is required from the first to the second Node in an ordered pair of Nodes.
Represents that no domain knowledge is available for a particular pair of Nodes.
Close