|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.Bayesia.api.APIModeling
public final class APIModeling
The class APIModeling is used to create bayesian networks. The bayesian network is loaded from an xbl file. This format is generated by BayesiaLab from Bayesia.
It allows to create dicrete or continuous chance nodes and decision nodes as well as constraint nodes and utility nodes.
It allows also to use temporal relationships between chance nodes and a time counter that is very useful to describe a time-dependent node.
It provides methods to create and remove arcs and nodes, to set the conditional probability tables, the decision tables and the utility tables. You can also generate automatically these tables by creating formulas. The creation of formulas is described in a specification document.
The created network can be saved to a file with the xbl format used by BayesiaLab and can be exported through the BayesianNetworkTransferHandler interface in order to be used directly with the APIInference.
All the methods of this class can throw an instance of IllegalOperationException which is a subclass of RuntimeException so you can avoid to catch them.
| Constructor Summary | |
|---|---|
APIModeling(BayesianNetworkTransferHandler networkHandler,
java.lang.String licenceKey)
Create a new APIModeling with the network stored in the specified BayesianNetworkTransferHandler. |
|
APIModeling(BayesianNetworkTransferHandler networkHandler,
java.lang.String licenceServerHost,
int licenseServerPort,
java.lang.String userGroup)
Create a new APIModeling with the network stored in the specified BayesianNetworkTransferHandler. |
|
APIModeling(java.lang.String licenceKey)
Create a new APIModeling with an empty bayesian network named new.xbl. |
|
APIModeling(java.lang.String licenceServerHost,
int licenseServerPort,
java.lang.String userGroup)
Create a new APIModeling with an empty bayesian network named new.xbl. |
|
APIModeling(java.lang.String fileName,
java.lang.String licenceKey)
Create a new APIModeling with the network stored in the specified file. |
|
APIModeling(java.lang.String fileName,
java.lang.String licenceServerHost,
int licenseServerPort,
java.lang.String userGroup)
Create a new APIModeling with the network stored in the specified file. |
|
| Method Summary | |
|---|---|
boolean |
addArc(java.lang.String nodeName1,
java.lang.String nodeName2)
Try to add an arc from nodeName1 to nodeName2. |
void |
addChanceIntervalNode(java.lang.String nodeName,
java.lang.String[] modalities,
float[][] intervals)
Create a new continuous (interval) chance node with the specified modalities and the specified limits for each interval and add it to the network. |
void |
addChanceLabelNode(java.lang.String nodeName,
java.lang.String[] modalities)
Create a new discrete chance node with the specified modalities and add it to the network. |
void |
addConstraintNode(java.lang.String nodeName)
And a constraint node with two boolean modalities. |
void |
addDecisionIntervalNode(java.lang.String nodeName,
java.lang.String[] decisionNames,
float[][] intervals)
Add a new continuous (interval) decision node with the specified names for the decisions and the specified intervals. |
void |
addDecisionLabelNode(java.lang.String nodeName,
java.lang.String[] decisionNames)
Add a new discrete decision node with the specified names for the decisions. |
boolean |
addTemporalArc(java.lang.String nodeName1,
java.lang.String nodeName2)
Try to add a temporal arc from nodeName1 to nodeName2. |
void |
addUtilityNode(java.lang.String nodeName)
Add a new utility node to the network. |
void |
close()
Method used to close the current instance of APIModeling. |
BayesianNetworkTransferHandler |
exportNetwork(java.lang.String networkName)
Export the created network with the specified name into a BayesianNetworkTransferHandler in order to used it with the APIInference for example. |
java.lang.String |
getArcComment(java.lang.String nodeName1,
java.lang.String nodeName2)
Return the comment associated to the arc between the nodes named nodeName1 and nodeName2. |
int |
getArcOrientationBetween(java.lang.String nodeName1,
java.lang.String nodeName2)
Return the orientation of the arc between nodeName1 and nodeName2. |
java.lang.String[] |
getChildren(java.lang.String nodeName)
Return the name of the children of the specified node |
java.lang.String |
getComment()
Return the comment associated to the network. |
double[] |
getConditionalProbabilityTable(java.lang.String nodeName)
Get the conditional probability table for the specified node. |
double[] |
getDecisionTable(java.lang.String nodeName)
Get the decision table for the specified node. |
java.lang.String |
getFormula(java.lang.String nodeName)
Return the formula associated to the node as String. |
int |
getFormulaSampleNumber(java.lang.String nodeName)
Return the number of samples the formula uses to evaluate the probabilities or the decisions for an interval node. |
int |
getFormulaSmoothingPower(java.lang.String nodeName)
Return the smoothing power of the formula of the specified node. |
float[][] |
getIntervals(java.lang.String nodeName)
Return an array containing the minimum and the maximum of each interval of the node as floats. |
int[] |
getIntValues(java.lang.String nodeName)
Return an array containing the values of the node as integers if the node is an integer node. |
java.lang.String |
getName()
Return the name of the loaded network. |
java.lang.String |
getNodeComment(java.lang.String nodeName)
Return the comment associated to the specified node |
java.lang.String[] |
getNodeNames()
Return an array containing the name of the nodes in the network |
int |
getNodeNumber()
Return the number of nodes in the network |
java.lang.String[] |
getParents(java.lang.String nodeName)
Return the name of the parents of the specified node |
java.lang.String[] |
getStringValues(java.lang.String nodeName)
Return an array containing the values of the node as String. |
double[] |
getUtilityTable(java.lang.String nodeName)
Get the utility table for the specified decision node. |
int |
getValueNumber(java.lang.String nodeName)
Return the number of values of the specified node. |
boolean |
hasArcBetween(java.lang.String nodeName1,
java.lang.String nodeName2)
Test if there is an arc between the specified nodes |
boolean |
hasTemporalArcBetween(java.lang.String nodeName1,
java.lang.String nodeName2)
Test if there is a temporal arc between the specified nodes |
boolean |
isBoolean(java.lang.String nodeName)
Test if the specified node is boolean, i.e. its values are equivalent to true and false. |
boolean |
isChildOf(java.lang.String nodeName1,
java.lang.String nodeName2)
Test if there is an arc from nodeName2 to nodeName1 |
boolean |
isConstraint(java.lang.String nodeName)
Test if the node is a constraint node. |
boolean |
isDecision(java.lang.String nodeName)
Test if the node is a decision node. |
boolean |
isFormulaProbabilist(java.lang.String nodeName)
Test if the formula of the specified node is probabilist or not. |
boolean |
isInteger(java.lang.String nodeName)
Test if all the values of the specified node are integers. |
boolean |
isInterval(java.lang.String nodeName)
Test if the node is described by a list of consecutives intervals. |
boolean |
isParentOf(java.lang.String nodeName1,
java.lang.String nodeName2)
Test if there is an arc from nodeName1 to nodeName2 |
boolean |
isTemporal()
Test if the network is temporal. |
boolean |
isTimeUsed()
Return true if the time is used in the network. |
boolean |
isUtility(java.lang.String nodeName)
Test if the node is a utility node. |
void |
removeArc(java.lang.String nodeName1,
java.lang.String nodeName2)
Remove the arc between the specified nodes. |
void |
removeNode(java.lang.String nodeName)
Remove the specified node. |
void |
save(java.lang.String path)
Save the created network to the file specified by the given path. |
void |
setArcComment(java.lang.String nodeName1,
java.lang.String nodeName2,
java.lang.String comment)
Set the comment associated to the arc between the nodes named nodeName1 and nodeName2. |
void |
setComment(java.lang.String comment)
Set the comment associated to the network. |
void |
setConditionalProbabilityTable(java.lang.String nodeName,
double[] table)
Set the conditional probability table for the specified node. |
void |
setDecisionTable(java.lang.String nodeName,
double[] table)
Set the decision table for the specified node. |
void |
setFormula(java.lang.String nodeName,
java.lang.String formula,
boolean probabilist,
int sampleNumber,
int smoothingPower)
|
void |
setNodeComment(java.lang.String nodeName,
java.lang.String comment)
Set the comment associated to the specified node |
void |
setTimeUsed(boolean b)
Specify that we want to use the time counter in the network. |
void |
setUtilityTable(java.lang.String nodeName,
double[] table)
Set the utility table for the specified decision node. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public APIModeling(java.lang.String licenceKey)
APIModeling with an empty bayesian network named new.xbl. You must provide a valid licence key for modeling.
licenceKey - the key of the licence.
public APIModeling(java.lang.String licenceServerHost,
int licenseServerPort,
java.lang.String userGroup)
APIModeling with an empty bayesian network named new.xbl. You must provide the host and the port of the license server. The user group is optional, depending on the configuration of the license ont the license server. Use this constructor if you use a license server.
licenceServerHost - the host of the license server.licenseServerPort - the port of the license server.userGroup - the user group corresponding to the license, maybe null if no user group is specified on the license server.
public APIModeling(java.lang.String fileName,
java.lang.String licenceKey)
APIModeling with the network stored in the specified file. You must provide a valid licence key for modeling.
fileName - the name of the xbl file containing the networklicenceKey - the key of the licence.
public APIModeling(java.lang.String fileName,
java.lang.String licenceServerHost,
int licenseServerPort,
java.lang.String userGroup)
APIModeling with the network stored in the specified file. You must provide the host and the port of the license server. The user group is optional, depending on the configuration of the license ont the license server. Use this constructor if you use a license server.
fileName - the name of the xbl file containing the networklicenceServerHost - the host of the license server.licenseServerPort - the port of the license server.userGroup - the user group corresponding to the license, maybe null if no user group is specified on the license server.
public APIModeling(BayesianNetworkTransferHandler networkHandler,
java.lang.String licenceKey)
APIModeling with the network stored in the specified BayesianNetworkTransferHandler. You must provide a valid licence key for modeling.
networkHandler - the transfer handler containing the networklicenceKey - the key of the licence.
public APIModeling(BayesianNetworkTransferHandler networkHandler,
java.lang.String licenceServerHost,
int licenseServerPort,
java.lang.String userGroup)
APIModeling with the network stored in the specified BayesianNetworkTransferHandler. You must provide the host and the port of the license server. The user group is optional, depending on the configuration of the license ont the license server. Use this constructor if you use a license server.
networkHandler - the transfer handler containing the networklicenceServerHost - the host of the license server.licenseServerPort - the port of the license server.userGroup - the user group corresponding to the license, maybe null if no user group is specified on the license server.| Method Detail |
|---|
public final java.lang.String getName()
public final java.lang.String[] getNodeNames()
public final int getNodeNumber()
public final java.lang.String getComment()
public final void setComment(java.lang.String comment)
comment - the comment associated to the network.public final java.lang.String getNodeComment(java.lang.String nodeName)
nodeName - the name of the node we want the comment
public final void setNodeComment(java.lang.String nodeName,
java.lang.String comment)
nodeName - the name of the node we want to set the commentcomment - the new comment
public final java.lang.String getArcComment(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 and nodeName2.
nodeName1 - the name of the first extremity nodenodeName2 - the name of the second extremity node
public final void setArcComment(java.lang.String nodeName1,
java.lang.String nodeName2,
java.lang.String comment)
nodeName1 and nodeName2.
nodeName1 - the name of the first extremity nodenodeName2 - the name of the second extremity nodecomment - the new comment of the arcpublic final boolean isTimeUsed()
setTimeUsed(boolean)public final void setTimeUsed(boolean b)
?t? can be used in formulas as an positive integer variable.
Warning: Do not forget to set the time to false if it was previously set to true and it is not used in any formula.
b - true if the time should be used, false otherwise.isTimeUsed()public final java.lang.String[] getParents(java.lang.String nodeName)
nodeName - the name of the node we want the parents
public final java.lang.String[] getChildren(java.lang.String nodeName)
nodeName - the name of the node we want the children
public final boolean hasArcBetween(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 - nodeName2 -
public final boolean hasTemporalArcBetween(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 - nodeName2 -
public final boolean isParentOf(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 to nodeName2
nodeName1 - the name of the supposed parentnodeName2 - the name of the supposed child
nodeName1 is parent of nodeName2
public final boolean isChildOf(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName2 to nodeName1
nodeName1 - the name of the supposed childnodeName2 - the name of the supposed parent
nodeName1 is child of nodeName2
public final int getArcOrientationBetween(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 and nodeName2. The possible values are : -1 if there is no arc, 0 if there is an arc from nodeName1 to nodeName2 and 1 if there is an arc from nodeName2 to nodeName1
nodeName1 - nodeName2 -
nodeName1 and nodeName2
public final void addChanceLabelNode(java.lang.String nodeName,
java.lang.String[] modalities)
nodeName - the name of the new node.modalities - an array containing the name of the modalitites
public final void addChanceIntervalNode(java.lang.String nodeName,
java.lang.String[] modalities,
float[][] intervals)
nodeName - the name of the new node.modalities - an array containing the name of the modalititesintervals - an array containing arrays storing the minimum and the maximum of each intervalpublic final void addConstraintNode(java.lang.String nodeName)
nodeName - the name of the nodepublic final void addUtilityNode(java.lang.String nodeName)
nodeName - the name of the node.
public final void addDecisionLabelNode(java.lang.String nodeName,
java.lang.String[] decisionNames)
nodeName - decisionNames - an array containing the names of the decisions.
public final void addDecisionIntervalNode(java.lang.String nodeName,
java.lang.String[] decisionNames,
float[][] intervals)
nodeName - the name of the nodedecisionNames - an array containing the names of the decisions.intervals - an array containing arrays storing the minimum and the maximum of each interval
public final boolean addArc(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 to nodeName2. If there is an arc between the two nodes or if the new arc introduces a cycle in the network, the new arc is not added and false is returned.
nodeName1 - the parent nodenodeName2 - the child node
public final boolean addTemporalArc(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 to nodeName2. If there is an arc between the two nodes, if the new arc introduces a cycle in the network or if the nodes are not compatible, the new arc is not added and false is returned. The nodes must be compatible, i.e. they must have the same modalities. A temporal arc can be added from node1 to node2, if and only if there is no temporal arc from any parent of node1 to node1, there is no temporal arc from node1 to any child
of node1 and there is no temoral arc from node2 to any child of node2. All these cases throw a IllegalOperationException.
nodeName1 - the parent nodenodeName2 - the child node
public final void removeArc(java.lang.String nodeName1,
java.lang.String nodeName2)
nodeName1 - nodeName2 - public final void removeNode(java.lang.String nodeName)
nodeName - the name of the node we want to removepublic final double[] getConditionalProbabilityTable(java.lang.String nodeName)
The probabilities are enumerated with a specific order; it follows the enumeration of the parents, for examples : Node N with 3 modalities (Values ni), Parents X with 2 modalities(xj), Y with 3 modalitites(yk) : the size of the table if 3*2*3 = 18 and the order of the probabilities will be :
n0x0y0, n0x0y1, n0x0y2, n0x1y0, n0x1y1, n0x1y2,
n1x0y0, n1x0y1, n1x0y2, n1x1y0, n1x1y1, n1x1y2,
n2x0y0, n2x0y1, n2x0y2, n2x1y0, n2x1y1, n2x1y2
nodeName - the name of the node
public final void setConditionalProbabilityTable(java.lang.String nodeName,
double[] table)
The probabilities are enumerated with a specific order; it follows the enumeration of the parents, for examples : Node N with 3 modalities (Values ni), Parents X with 2 modalities(xj), Y with 3 modalitites(yk) : the size of the table if 3*2*3 = 18 and the order of the probabilities will be :
Note: If a formula was previously set for this node, it is removed.
n0x0y0, n0x0y1, n0x0y2, n0x1y0, n0x1y1, n0x1y2,
n1x0y0, n1x0y1, n1x0y2, n1x1y0, n1x1y1, n1x1y2,
n2x0y0, n2x0y1, n2x0y2, n2x1y0, n2x1y1, n2x1y2
nodeName - the name of the nodetable - the new conditional probability table
public final double[] getDecisionTable(java.lang.String nodeName)
The decisions are enumerated with a specific order; it follows the enumeration of the parents, for examples : Node N with 3 modalities (Values ni), Parents X with 2 modalities(xj), Y with 3 modalitites(yk) : the size of the table if 3*2*3 = 18 and the order of the decisions will be :
n0x0y0, n0x0y1, n0x0y2, n0x1y0, n0x1y1, n0x1y2,
n1x0y0, n1x0y1, n1x0y2, n1x1y0, n1x1y1, n1x1y2,
n2x0y0, n2x0y1, n2x0y2, n2x1y0, n2x1y1, n2x1y2
nodeName - the name of the node
public final void setDecisionTable(java.lang.String nodeName,
double[] table)
The decisions are enumerated with a specific order; it follows the enumeration of the parents, for examples : Node N with 3 modalities (Values ni), Parents X with 2 modalities(xj), Y with 3 modalitites(yk) : the size of the table if 3*2*3 = 18 and the order of the decisions will be :
Note: If a formula was previously set for this node, it is removed.
n0x0y0, n0x0y1, n0x0y2, n0x1y0, n0x1y1, n0x1y2,
n1x0y0, n1x0y1, n1x0y2, n1x1y0, n1x1y1, n1x1y2,
n2x0y0, n2x0y1, n2x0y2, n2x1y0, n2x1y1, n2x1y2
nodeName - the name of the nodetable - the new decision table
public final double[] getUtilityTable(java.lang.String nodeName)
The utilities are enumerated with a specific order; it follows the enumeration of the parents, for examples : Parents X with 2 modalities(xj), Y with 3 modalitites(yk) : the size of the table if 2*3 = 6 and the order of the decisions will be :
If there is no parent, the size of the table is 1.
x0y0, x0y1, x0y2, x1y0, x1y1, x1y2
nodeName - the name of the node
public final void setUtilityTable(java.lang.String nodeName,
double[] table)
The utilities are enumerated with a specific order; it follows the enumeration of the parents, for examples : Parents X with 2 modalities(xj), Y with 3 modalitites(yk) : the size of the table if 2*3 = 6 and the order of the decisions will be :
If there is no parent, the size of the table is 1.
Note: If a formula was previously set for this node, it is removed.
x0y0, x0y1, x0y2, x1y0, x1y1, x1y2
nodeName - the name of the nodetable - the new utility table
public final void setFormula(java.lang.String nodeName,
java.lang.String formula,
boolean probabilist,
int sampleNumber,
int smoothingPower)
nodeName - the name of the nodeformula - the formulaprobabilist - true if the formula is probabilist, false if is deterministsampleNumber - >0 if the node is an interval node.smoothingPower - >0 if you want to smooth the probabilities or 0 if you don't want.public final boolean isInteger(java.lang.String nodeName)
nodeName - the name of the tested node
public final boolean isBoolean(java.lang.String nodeName)
nodeName - the name of the tested node
public final boolean isInterval(java.lang.String nodeName)
nodeName - the name of the tested node
public final boolean isDecision(java.lang.String nodeName)
nodeName - the name of the tested node
public final boolean isUtility(java.lang.String nodeName)
nodeName - the name of the tested node
public final boolean isConstraint(java.lang.String nodeName)
nodeName - the name of the tested node
public final int getValueNumber(java.lang.String nodeName)
public final java.lang.String[] getStringValues(java.lang.String nodeName)
String. It can't be used on constraint and utility nodes.
nodeName - the name of the node
public final int[] getIntValues(java.lang.String nodeName)
nodeName - the name of the node
public final float[][] getIntervals(java.lang.String nodeName)
nodeName - the name of the node
public final java.lang.String getFormula(java.lang.String nodeName)
String. If the node doesn't have a formula it returns null.
nodeName - the name of the node
String representing the formula of the nodepublic final boolean isFormulaProbabilist(java.lang.String nodeName)
nodeName - the name of the node we want to test the formula
public final int getFormulaSampleNumber(java.lang.String nodeName)
nodeName - the name of the interval node
public final int getFormulaSmoothingPower(java.lang.String nodeName)
nodeName - the name of the node
public final boolean isTemporal()
public final void save(java.lang.String path)
xbl. The name of the network is now the name of the file.
path - the path to an xbl filepublic final BayesianNetworkTransferHandler exportNetwork(java.lang.String networkName)
BayesianNetworkTransferHandler in order to used it with the APIInference for example. The name of the network must be terminated by .xbl
networkName - the new name of the network with the xbl extension
public final void close()
APIModeling.
WARNING: If you use a license server, this method must be called once you don't need the instance anymore. It allows to release the license on the license server.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||