public interface Evidence
query
.
Evidence is always associated with a particular network, however if necessary can be detached or attached to an instance of an inference engine. This has the follwing advantages: - Evidence can be set before an inference engine is created, or retained when an inference engine is destroyed. - Evidence can be switched between inference engines. - An inference engine can switch between different evidence instances.Modifier and Type | Method and Description |
---|---|
void |
beginUpdate()
Disables change notifications (if present), until
endUpdate() is called. |
void |
clear()
Clears any evidence on all variables, and resets the
getWeight() to 1. |
void |
clear(Node node)
Clears evidence on a node's variables.
|
void |
clear(Node node,
Integer time)
Clears evidence on a node's single variable.
|
void |
clear(Variable variable)
Clears evidence on a variable.
|
void |
clear(Variable variable,
Integer time)
Clears evidence on a variable at the specified time.
|
void |
copy(Evidence evidence)
Replaces the current evidence, with that from another
Evidence instance. |
void |
copy(Evidence evidence,
Variable variable)
Replaces the current evidence for an individual variable, with that from another
Evidence instance. |
void |
copy(Evidence evidence,
Variable variable,
Integer time)
Replaces the current evidence for an individual variable at a specific time, with that from another
Evidence instance. |
void |
endUpdate()
Enables change notifications (if available).
|
Double |
get(Node node)
Gets the hard evidence value for a particular node's variable, or returns null if the
EvidenceType equals EvidenceType.NONE or EvidenceType.SOFT . |
void |
get(Node node,
Double[] destination,
int destinationStart,
int startTime,
int count)
Gets the evidence for a node's single temporal variable.
|
Double |
get(Node node,
Integer time)
Gets the evidence for a node with a single variable at the specified time.
|
Double |
get(Variable variable)
Gets the hard evidence for a discrete variable or continuous variable, or returns null if the
EvidenceType equals EvidenceType.NONE or EvidenceType.SOFT . |
void |
get(Variable variable,
Double[] destination,
int destinationStart,
int startTime,
int count)
Gets the evidence for a temporal variable.
|
Double |
get(Variable variable,
Integer time)
Gets the evidence for a discrete variable at the specified time.
|
EvidenceType |
getEvidenceType(Node node)
Returns the type of evidence currently set for a node with a single variable.
|
EvidenceType |
getEvidenceType(Node node,
Integer time)
Returns the type of evidence currently set for a node with a single variable at a given time.
|
EvidenceType |
getEvidenceType(Variable variable)
Returns the type of evidence currently set for a variable (if any).
|
EvidenceType |
getEvidenceType(Variable variable,
Integer time)
Returns the type of evidence currently set for a variable at a given time.
|
EvidenceTypes |
getEvidenceTypes(Node node)
Gets the type of evidence (if any) and whether or not it is an intervention (do-operator).
|
EvidenceTypes |
getEvidenceTypes(Node node,
Integer time)
Gets the type of evidence (if any) and whether or not it is an intervention (do-operator).
|
EvidenceTypes |
getEvidenceTypes(Variable variable)
Gets the type of evidence (if any) and whether or not it is an intervention (do-operator).
|
EvidenceTypes |
getEvidenceTypes(Variable variable,
Integer time)
Gets the type of evidence (if any) and whether or not it is an intervention (do-operator).
|
double |
getLogWeight()
Gets the natural logarithm of
getWeight() . |
Integer |
getMaxTime()
Gets the maximum time containing evidence.
|
Integer |
getMaxTime(Variable variable)
Gets the maximum time containing evidence for a variable.
|
Network |
getNetwork()
Gets the Bayesian network that is the the target of the evidence.
|
Integer |
getState(Node node)
Gets the hard evidence state for node with a single variable, or returns null if the
EvidenceType equals EvidenceType.NONE or EvidenceType.SOFT . |
Integer |
getState(Node node,
Integer time)
Gets the hard evidence state for node with a single variable, or returns null if the
EvidenceType equals EvidenceType.NONE or EvidenceType.SOFT . |
Integer |
getState(Variable variable)
Gets the hard evidence state for a particular variable, or returns null if the
EvidenceType equals EvidenceType.NONE or EvidenceType.SOFT . |
Integer |
getState(Variable variable,
Integer time)
Gets the hard evidence state for a particular variable, or returns null if the
EvidenceType equals EvidenceType.NONE or EvidenceType.SOFT . |
void |
getStates(Node node,
double[] buffer)
Fills out a buffer containing the soft evidence for a node with a single variable.
|
void |
getStates(Node node,
double[] buffer,
Integer time)
Fills out a buffer containing the soft evidence for a node with a single variable at a specified time.
|
void |
getStates(Table table)
Fills out a table containing the soft evidence for a particular variable.
|
void |
getStates(Variable variable,
double[] buffer)
Fills out a buffer containing the soft evidence for a particular variable.
|
void |
getStates(Variable variable,
double[] buffer,
Integer time)
Fills out a buffer containing the soft evidence for a particular variable at a specified time.
|
void |
getVariables(Variable[] buffer)
Fills out a buffer with all variables that have either hard or soft evidence.
|
double |
getWeight()
Gets a weight that can be applied to the evidence.
|
void |
load(InputStream input)
Loads evidence from the specified stream.
|
void |
load(String fileName)
Loads evidence from the specified file.
|
void |
loadFromString(String value)
Loads evidence from a string using UTF-8 encoding.
|
void |
loadFromString(String value,
String charSetName)
Loads evidence from a string using the specified encoding.
|
void |
save(OutputStream output)
Saves the evidence to the specified stream.
|
void |
save(String fileName)
Saves the specified to the specified file.
|
String |
saveToString()
Saves evidemce to a string, with UTF-8 encoding.
|
String |
saveToString(String charSetName)
Saves evidence to a string, with the specified encoding.
|
void |
set(Node node,
Double value)
Sets a node's variable to a particular value (hard evidence).
|
void |
set(Node node,
Double[] source,
int sourceStart,
int startTime,
int count)
Sets temporal evidence on a node with a single variable.
|
void |
set(Node node,
Double value,
Integer time)
Sets evidence on a node's single variable at a specified time.
|
void |
set(Variable variable,
Double value)
Sets a variable to a particular value (hard evidence).
|
void |
set(Variable variable,
Double[] source,
int sourceStart,
int startTime,
int count)
Sets temporal evidence on a variable.
|
void |
set(Variable variable,
Double value,
Integer time)
Sets evidence on a variable at a specified time.
|
void |
set(Variable variable,
Double value,
Integer time,
InterventionType interventionType)
Sets evidence on the variable, in the form of an intervention (do-operator).
|
void |
setLogWeight(double value)
Sets the natural logarithm of
getWeight() . |
void |
setState(Node node,
Integer state)
Sets evidence on a node with a single discrete variable to a particular state (hard evidence).
|
void |
setState(Node node,
Integer state,
Integer time)
Sets evidence on a node with a single discrete variable to a particular state (hard evidence) specifiying a time if the node is temporal.
|
void |
setState(State state)
Sets evidence on a discrete state (hard evidence).
|
void |
setState(State state,
Integer time)
Sets evidence on a discrete state (hard evidence) at a particular time (zero based).
|
void |
setState(State state,
Integer time,
InterventionType interventionType)
Sets evidence on a discrete state (hard evidence), in the form of an intervention (do-operator).
|
void |
setState(Variable variable,
Integer state)
Sets a discrete variable to a particular state (hard evidence).
|
void |
setState(Variable variable,
Integer state,
Integer time)
Sets a discrete variable to a particular state (hard evidence), specifiying a time if the state belongs to a variable whose node is temporal.
|
void |
setStates(Node node,
double[] values)
Sets soft evidence for a discrete node with a single variable.
|
void |
setStates(Node node,
double[] values,
Integer time)
Sets soft evidence for a discrete node with a single variable, at a specified time.
|
void |
setStates(Variable variable,
double[] values)
Sets soft evidence for a particular discrete variable.
|
void |
setStates(Variable variable,
double[] values,
Integer time)
Sets soft evidence for a particular discrete variable at a specified time.
|
void |
setWeight(double value)
Sets a weight that can be applied to the evidence.
|
int |
size()
Gets the count of variables with either hard, soft or temporal evidence set.
|
int size()
Network getNetwork()
Network
.double getWeight()
Note that setting the weight to anything but 1, will effect the QueryOutput.getLogLikelihood()
statistic.
void setWeight(double value)
Note that setting the weight to anything but 1, will effect the QueryOutput.getLogLikelihood()
statistic.
double getLogWeight()
getWeight()
.void setLogWeight(double value)
getWeight()
.void beginUpdate()
endUpdate()
is called.
Calls to beginUpdate()
can be nested, in which case notifications only continue after the final call to endUpdate()
.void clear()
getWeight()
to 1.void clear(Variable variable)
variable
- The variable whose evidence you want to clear.void clear(Variable variable, Integer time)
variable
- The variable whose evidence you want to clear.time
- The time at which to clear evidence. Can be null.void clear(Node node, Integer time)
node
- A node with a single variable whose evidence you want to clear.time
- The time at which to clear evidence. Can be null.void clear(Node node)
node
- The node whose variables you want to clear evidence on.void copy(Evidence evidence)
Evidence
instance.evidence
- The source evidence to copy from.void copy(Evidence evidence, Variable variable)
Evidence
instance.
For temporal variables, evidence is copied from the source at all times.evidence
- The source evidence to copy from.variable
- The variable to copy evidence for.void copy(Evidence evidence, Variable variable, Integer time)
Evidence
instance.evidence
- The source evidence to copy from.variable
- The variable to copy evidence for.time
- The time at which to copy evidence.void endUpdate()
beginUpdate()
to disable notifications.void getVariables(Variable[] buffer)
size()
.buffer
- A container for any variables with evidence. It must have length equal to or greater than the current size()
.void load(InputStream input) throws XMLStreamException
input
- The input stream.XMLStreamException
void load(String fileName) throws IOException, XMLStreamException
fileName
- Name of the file.IOException
XMLStreamException
void save(OutputStream output) throws XMLStreamException
output
- The output stream.XMLStreamException
void save(String fileName) throws IOException, XMLStreamException
fileName
- Name of the file.IOException
XMLStreamException
String saveToString(String charSetName) throws XMLStreamException
charSetName
- The encoding to use.XMLStreamException
String saveToString() throws XMLStreamException
XMLStreamException
void loadFromString(String value, String charSetName) throws UnsupportedEncodingException, XMLStreamException
value
- The persisted string value of the evidence.charSetName
- The encoding the evidence was originally saved in.UnsupportedEncodingException
XMLStreamException
void loadFromString(String value) throws UnsupportedEncodingException, XMLStreamException
value
- The persisted string value of the evidence.UnsupportedEncodingException
XMLStreamException
Integer getMaxTime(Variable variable)
variable
- The variable to check.Integer getMaxTime()
EvidenceType getEvidenceType(Variable variable)
variable
- The variable in question.EvidenceType
.EvidenceType getEvidenceType(Node node)
node
- The node in question.EvidenceType
.EvidenceTypes getEvidenceTypes(Variable variable)
variable
- The variable in question.EvidenceTypes
.EvidenceTypes getEvidenceTypes(Node node)
node
- The node in question.EvidenceTypes
.EvidenceTypes getEvidenceTypes(Node node, Integer time)
node
- The node in question.time
- The time at which evidence is set. Can be null.EvidenceTypes
.EvidenceTypes getEvidenceTypes(Variable variable, Integer time)
variable
- The variable in question.time
- The time at which evidence is set. Can be null.EvidenceTypes
.EvidenceType getEvidenceType(Node node, Integer time)
node
- The node in question.time
- The time at which evidence is set. Can be null.EvidenceType
.EvidenceType getEvidenceType(Variable variable, Integer time)
variable
- The variable in question.time
- The time at which evidence is set. Can be null.EvidenceType
.Integer getState(Variable variable)
EvidenceType
equals EvidenceType.NONE
or EvidenceType.SOFT
.variable
- The variable.State
with hard evidence set, or null if the EvidenceType
does not equal EvidenceType.HARD
..NullPointerException
- [variable] is null.IllegalArgumentException
- The variable does not belong to the appropriate network, or is not discrete.Integer getState(Variable variable, Integer time)
EvidenceType
equals EvidenceType.NONE
or EvidenceType.SOFT
.variable
- The variable.time
- Time at which to retrieve evidence, if the variable belongs to a temporal node, otherwise null.State
with hard evidence set, or null if the EvidenceType
does not equal EvidenceType.HARD
..NullPointerException
- [variable] is null.IllegalArgumentException
- The variable does not belong to the appropriate network, or is not discrete.Integer getState(Node node)
EvidenceType
equals EvidenceType.NONE
or EvidenceType.SOFT
.node
- The node with a single discrete variable.State
with hard evidence set, or null if the EvidenceType
does not equal EvidenceType.HARD
..NullPointerException
- [node] is null.IllegalArgumentException
- The node does not belong to the appropriate network, or does not have a single discrete variable.Integer getState(Node node, Integer time)
EvidenceType
equals EvidenceType.NONE
or EvidenceType.SOFT
.node
- The node with a single discrete variable.time
- Time at which to retrieve evidence, if the node is temporal, otherwise null.State
with hard evidence set, or null if the EvidenceType
does not equal EvidenceType.HARD
..NullPointerException
- [node] is null.IllegalArgumentException
- The node does not belong to the appropriate network, or does not have a single discrete variable.void setState(Variable variable, Integer state)
variable
- The discrete variable to set evidence on.state
- The zero based index of the state to set, or null to clear the evidence.void setState(Variable variable, Integer state, Integer time)
variable
- The discrete variable to set evidence on.state
- The zero based index of the state to set, or null to clear the evidence.time
- The time at which to set evidence, if the state belongs to a variable whose node is temporal, otherwise null.void setState(State state)
state
- The state to set, cannot be null.void setState(State state, Integer time, InterventionType interventionType)
state
- The state to set, cannot be null.time
- The time at which to set evidence, if the node is temporal, otherwise null.interventionType
- Whether or not the evidence is an intervention.void set(Variable variable, Double value, Integer time, InterventionType interventionType)
variable
- The variable to set evidence on.value
- The value to set, or null to clear the evidence.time
- The time at which to set evidence, if the node is temporal, otherwise null.interventionType
- Whether or not the evidence is an intervention.void setState(State state, Integer time)
state
- The state to set, cannot be null.time
- The time at which to set evidence, if the node is temporal, otherwise null.void setState(Node node, Integer state)
node
- The node with a single discrete variable to set evidence on.state
- The zero based index of the state to set, or null to clear the evidence.void setState(Node node, Integer state, Integer time)
node
- The node with a single discrete variable to set evidence on.state
- The zero based index of the state to set, or null to clear the evidence.time
- The time at which to set evidence, if the node is temporal, otherwise null.Double get(Variable variable)
EvidenceType
equals EvidenceType.NONE
or EvidenceType.SOFT
.variable
- The discrete or continuous variable.EvidenceType
does not equal EvidenceType.HARD
.NullPointerException
- [variable] is null.IllegalArgumentException
- The variable does not belong to the appropriate network.Double get(Variable variable, Integer time)
variable
- The variable.time
- The time at which to retrieve evidence. Can be null.void get(Variable variable, Double[] destination, int destinationStart, int startTime, int count)
variable
- The temporal variable.destination
- The destination buffer which will be filled with the evidence values.destinationStart
- The position in the buffer to start copying.startTime
- The time to start copying from.count
- The number of evidence values to copy.void get(Node node, Double[] destination, int destinationStart, int startTime, int count)
node
- A node with a single temporal variable.destination
- The destination buffer which will be filled with the evidence values.destinationStart
- The position in the buffer to start copying.startTime
- The time to start copying from.count
- The number of evidence values to copy.Double get(Node node)
EvidenceType
equals EvidenceType.NONE
or EvidenceType.SOFT
.node
- A node with a single variable in question.EvidenceType
does not equal EvidenceType.HARD
.Double get(Node node, Integer time)
node
- A node with a single variable.time
- The time to retrieve evidence for. Can be null.void set(Variable variable, Double value)
variable
- The variable to set evidence on.value
- The value to set, or null to clear the evidence.void set(Variable variable, Double value, Integer time)
variable
- The variable to set evidence on.value
- The value to set, or null to clear the evidence.time
- The time at which to set evidence. Can be null.void set(Node node, Double value, Integer time)
node
- A node with a single variable to set evidence on.value
- The value to set, or null to clear the evidence.time
- The time at which to set evidence. Can be null.void set(Variable variable, Double[] source, int sourceStart, int startTime, int count)
variable
- The variable to set evidence on.source
- The evidence values.sourceStart
- The position in [source] to start copying from.startTime
- The time to start copying at.count
- The number of values to copy.void set(Node node, Double[] source, int sourceStart, int startTime, int count)
node
- A node with a single variable to set evidence on.source
- The evidence values.sourceStart
- The position in [source] to start copying from.startTime
- The time to start copying at.count
- The number of values to copy.void set(Node node, Double value)
node
- A node with a single variable to set evidence on.value
- The value to set, or null to clear the evidence.void getStates(Variable variable, double[] buffer)
Get
.
The resulting values will depend on the current EvidenceType
for the variable:EvidenceType.NONE
- All values will equal 1.EvidenceType.HARD
- All values will equal 0, except at the hard evidence state, where the value will equal 1.EvidenceType.NONE
- The soft evidence values will be used.variable
- The variable to retrieve evidence for.buffer
- A buffer whose values are replaced with the current evidence.void getStates(Node node, double[] buffer)
Get
.
The resulting values will depend on the current EvidenceType
for the variable:EvidenceType.NONE
- All values will equal 1.EvidenceType.HARD
- All values will equal 0, except at the hard evidence state, where the value will equal 1.EvidenceType.NONE
- The soft evidence values will be used.node
- A node with a single variable to retrieve evidence for.buffer
- A buffer whose values are replaced with the current evidence.void getStates(Variable variable, double[] buffer, Integer time)
Get
.
The resulting values will depend on the current EvidenceType
for the variable:EvidenceType.NONE
- All values will equal 1.EvidenceType.HARD
- All values will equal 0, except at the hard evidence state, where the value will equal 1.EvidenceType.NONE
- The soft evidence values will be used.variable
- The variable to retrieve evidence for.buffer
- A buffer whose values are replaced with the current evidence.time
- The time at which to retrieve evidence. Can be null. Used by Dynamic Bayesian networks.void getStates(Node node, double[] buffer, Integer time)
Get
.
The resulting values will depend on the current EvidenceType
for the variable:EvidenceType.NONE
- All values will equal 1.EvidenceType.HARD
- All values will equal 0, except at the hard evidence state, where the value will equal 1.EvidenceType.NONE
- The soft evidence values will be used.node
- A node with a single variable to retrieve evidence for.buffer
- A buffer whose values are replaced with the current evidence.time
- The time at which to retrieve evidence. Can be null. Used by Dynamic Bayesian networks.void getStates(Table table)
Get
.
The resulting values will depend on the current EvidenceType
for the variable:EvidenceType.NONE
- All values will equal 1.EvidenceType.HARD
- All values will equal 0, except at the hard evidence state, where the value will equal 1.EvidenceType.NONE
- The soft evidence values will be used.void setStates(Variable variable, double[] values)
EvidenceType
will not be EvidenceType.SOFT
.variable
- The variable to set evidence on.values
- An array of soft evidence values.void setStates(Node node, double[] values)
EvidenceType
will not be EvidenceType.SOFT
.node
- The node with a single variable to set evidence on.values
- An array of soft evidence values.void setStates(Variable variable, double[] values, Integer time)
EvidenceType
will not be EvidenceType.SOFT
.variable
- The variable to set evidence on.values
- An array of soft evidence values.time
- The time at which to set evidence. Can be null. Used by Dynamic Bayesian networks.void setStates(Node node, double[] values, Integer time)
EvidenceType
will not be EvidenceType.SOFT
.node
- The node with a single variable to set evidence on.values
- An array of soft evidence values.time
- The time at which to set evidence. Can be null. Used by Dynamic Bayesian networks.Copyright © 2023. All rights reserved.