public class Model
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Model.Evaluation
Evaluation types, which specify hot to evaluate value distributions.
|
Modifier and Type | Field and Description |
---|---|
java.util.ArrayList<Attribute> |
aggregate
List of all aggregate (output) attributes.
|
java.util.ArrayList<Attribute> |
basic
List of all all basic (input) attributes.
|
java.util.ArrayList<Attribute> |
linked
List of all linked attributes.
|
Constructor and Description |
---|
Model(java.io.File xmlFile)
Model constructor.
|
Model(java.lang.String xmlString)
Model constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
attributesToString(java.util.ArrayList<Attribute> aList)
attributestoString.
|
void |
clearInputValues()
Clear the values of all input attributes.
|
void |
clearOutputValues()
Clear the values of all output attributes.
|
void |
evaluate()
Fast evaluation method.
|
void |
evaluate(Model.Evaluation evalType,
boolean normalize)
Full evaluation method.
|
Value |
evaluate(java.lang.String strAttribute,
java.lang.String variables)
Deprecated.
|
Attribute |
findAttribute(java.lang.String name)
Find attribute in the model by name.
|
Attribute |
findAttribute(java.lang.String name,
java.util.ArrayList<Attribute> aList)
Find attribute by name in list.
|
java.util.ArrayList<Attribute> |
getAllAttributes()
Collects all model attributes.
|
java.lang.Boolean |
getCompleteness()
Get model completeness, that is, whether or not all functions have a
required number of rule.
|
java.lang.Boolean |
getExplicitness()
Get model explicitness, that is, whether or not all functions are 100%
defined.
|
Value |
getInputValue(int index)
Get the value of the index-th basic (input) attribute.
|
Value |
getInputValue(java.lang.String name)
Get the value of some aggregate (input) attribute.
|
java.lang.String |
getInputValues()
Get a ";"-separated string of all input value assignments.
|
Distribution |
getOutputDistr(int index)
Get the value distribution of the index-th aggregate (output) attribute.
|
Distribution |
getOutputDistr(java.lang.String name)
Get the value distribution of some aggregate (output) attribute.
|
java.lang.String |
getOutputDistrString(int index)
Get value distribution of index-th output attribute.
|
java.lang.String |
getOutputDistrString(java.lang.String name)
Get value distribution of some output attribute.
|
Value |
getOutputValue(int index)
Get the value of the index-th aggregate (output) attribute.
|
Value |
getOutputValue(java.lang.String name)
Get the value of some aggregate (output) attribute.
|
java.lang.String |
getOutputValues()
Get a ";"-separated string of all output value assignments.
|
java.lang.String[] |
inputs()
Return a String array of input attribute names.
|
java.lang.String[] |
listAttributes(java.util.ArrayList<Attribute> attlist)
Return a String array of names of attributes in attlist.
|
static java.lang.String |
loadFile(java.lang.String xmlFileName)
Deprecated.
|
java.lang.String[] |
outputs()
Return a String array of output attribute names.
|
void |
print(java.io.OutputStream stream)
Print object values to OutputStream.
|
void |
setInputValue(int index,
Distribution distr)
Set input value distribution of an individual attribute.
|
void |
setInputValue(int index,
double[] distr)
Set input value distribution of an individual attribute.
|
void |
setInputValue(int index,
int value)
Set input value of an individual attribute.
|
void |
setInputValue(int index,
int value,
double fact)
Set input distribution value of an individual attribute.
|
void |
setInputValue(int index,
java.lang.String value)
Set input value of an individual attribute.
|
void |
setInputValue(int index,
java.lang.String value,
double fact)
Set input distribution value of an individual attribute.
|
void |
setInputValue(java.lang.String name,
Distribution distr)
Set input value distribution of an individual attribute.
|
void |
setInputValue(java.lang.String name,
double[] distr)
Set input value distribution of an individual attribute.
|
void |
setInputValue(java.lang.String name,
int value)
Set input value of an individual attribute.
|
void |
setInputValue(java.lang.String name,
int value,
double fact)
Set input distribution value of an individual attribute.
|
void |
setInputValue(java.lang.String name,
java.lang.String value)
Set input value of an individual attribute.
|
void |
setInputValue(java.lang.String name,
java.lang.String value,
double fact)
Set input distribution value of an individual attribute.
|
void |
setInputValues(int[] values)
Set the values of input attributes, in the order of basic attributes.
|
void |
setInputValues(java.lang.String[] values)
Set the values of input attributes, in the order of basic attributes.
|
void |
setInputValuesByNames(java.lang.String variables)
Set the values of input attributes.
|
void |
setInputValuesSmart(java.lang.String[] values)
Set the values of input attributes, in the order of basic attributes.
|
java.lang.String |
tabbedAttributes(java.util.ArrayList<Attribute> attlist)
Return a tab-delimited string of attribute names.
|
java.lang.String |
tabbedInputs()
Return a tab-delimited string of input attribute names.
|
java.lang.String |
tabbedOutputs()
Return a tab-delimited string of output attribute names.
|
public java.util.ArrayList<Attribute> basic
public java.util.ArrayList<Attribute> aggregate
public java.util.ArrayList<Attribute> linked
public Model(java.lang.String xmlString)
xmlString
- String, containing DEXi model in standard DEXi XML format.public Model(java.io.File xmlFile)
xmlFile
- File, containing DEXi model in standard DEXi XML format.public java.lang.String attributesToString(java.util.ArrayList<Attribute> aList)
aList
- List of attributes.public java.util.ArrayList<Attribute> getAllAttributes()
public void clearInputValues()
public void clearOutputValues()
public void setInputValuesByNames(java.lang.String variables)
variables
- String in the form: "name=value;...". Unspecified names remain
undefined.public void setInputValues(java.lang.String[] values)
values
- String[] containing attribute values (as strings). Array
length must exactly match the number of basic attributes.public void setInputValuesSmart(java.lang.String[] values)
values
- String[] containing attribute values (as strings). Array
length must exactly match the number of basic attributes.
Individual strings can have one of the forms: (1) literal
string, indicating attribute name, (2) numeric string,
indicating one-based ordinal number, or (3) numeric string
starting with "0", indicating zero-based ordinal.public void setInputValues(int[] values)
values
- int[] containing ordinal values of attributes. Array length
must exactly match the number of basic attributes.public void setInputValue(java.lang.String name, int value)
name
- Attribute name.value
- Ordinal value.public void setInputValue(java.lang.String name, java.lang.String value)
name
- Attribute name.value
- String value.public void setInputValue(int index, int value)
index
- Attribute index in the list of basic attribute.value
- Ordinal value.public void setInputValue(int index, java.lang.String value)
index
- Attribute index in the list of basic attribute.value
- String value.public void setInputValue(java.lang.String name, Distribution distr)
name
- Attribute name.distr
- Distribution of values. Should contain a number between 0.0
and 1.0 for each value that can be assigned to the attribute.
The size of distr must much the number of values that can be
assigned to the attribute..public void setInputValue(java.lang.String name, double[] distr)
name
- Attribute name.distr
- double[] containing a distribution of values, that is numbers
between 0.0 and 1.0, of length equal to attribute scale size.public void setInputValue(int index, Distribution distr)
index
- Attribute index in the list of basic attributes.distr
- Distribution of values. Should contain a number between 0.0
and 1.0 for each value that can be assigned to the attribute.
The size of distr must much the number of values that can be
assigned to the attribute..public void setInputValue(int index, double[] distr)
index
- Attribute index in the list of basic attributes.distr
- double[] containing a distribution of values, that is numbers
between 0.0 and 1.0, of length equal to attribute scale size.public void setInputValue(java.lang.String name, int value, double fact)
name
- Attribute name.value
- Ordinal value.fact
- Probability or possibility (fuzzy membership) of value.
Typically, fact is a number between 0.0 and 1.0.public void setInputValue(java.lang.String name, java.lang.String value, double fact)
name
- Attribute name.value
- String value.fact
- Probability or possibility (fuzzy membership) of value.public void setInputValue(int index, int value, double fact)
index
- Attribute index in the list of basic attributes.value
- Ordinal value.fact
- Probability or possibility (fuzzy membership) of value.public void setInputValue(int index, java.lang.String value, double fact)
index
- Attribute index in the list of basic attributes.value
- String value.fact
- Probability or possibility (fuzzy membership) of value.public java.lang.String getInputValues()
public java.lang.String getOutputValues()
public Value getInputValue(int index)
index
- Index of the attribute in the depth-first list of basic
attributespublic Value getInputValue(java.lang.String name)
name
- Name of the input attribute.public Value getOutputValue(int index)
index
- Index of the attribute in the depth-first list of aggregate
attributes. index=0 corresponds to the first root attribute.public Value getOutputValue(java.lang.String name)
name
- Name of the output attribute.public Distribution getOutputDistr(int index)
index
- Index of the attribute in the depth-first list of aggregate
attributes. index=0 corresponds to the first root attribute.public Distribution getOutputDistr(java.lang.String name)
name
- Attribute name.public java.lang.String getOutputDistrString(int index)
index
- Output attribute index.public java.lang.String getOutputDistrString(java.lang.String name)
name
- Output attribute name.public Value evaluate(java.lang.String strAttribute, java.lang.String variables)
strAttribute
- Name of the attribute whose evaluated value should be
returned.variables
- ";"-separated list of "name=value" pairs representing input
data.evaluate()
public void evaluate()
After successful evaluation, values of output attributes are defined and can be retrieved by getOutputValue() methods.
public void evaluate(Model.Evaluation evalType, boolean normalize)
Overall, this method operates on value distributions rather than single values. Before evaluation, all single values assigned to input attributes are converted into distributions (when both a single value and distribution have been specified for an individual attribute, only the distribution is used). After evaluation, all output distributions that can be represented by a single value, are converted to corresponding single values. That is, after evaluation, all output distributions are defined and can be retrieved with getOuputDistr() methods. Some attributes may also have assigned single values, which can be retrieved with getOutputValue() methods.
evalType
- Type of evaluation.normalize
- Boolean value indicating whether or not distributions are
normalized before (for input attributes) and after (output
attributes) evaluation.
Normalization depends on evaluation type: SET: all non zero
membership values are converted to 1.0 PROB: the sum of
probabilities is normalized to 1.0 FUZZY: the maximum set
membership is normalized to 1.0enum type.
public Attribute findAttribute(java.lang.String name)
name
- Attribute name.public Attribute findAttribute(java.lang.String name, java.util.ArrayList<Attribute> aList)
name
- Attribute name.aList
- List of attributes.public java.lang.Boolean getExplicitness()
public java.lang.Boolean getCompleteness()
public java.lang.String[] listAttributes(java.util.ArrayList<Attribute> attlist)
attlist
- ArrayList of attributes.public java.lang.String[] inputs()
public java.lang.String[] outputs()
public java.lang.String tabbedAttributes(java.util.ArrayList<Attribute> attlist)
attlist
- List of attributes.public java.lang.String tabbedInputs()
public java.lang.String tabbedOutputs()
public void print(java.io.OutputStream stream) throws java.io.IOException
stream
- OutputStream object parameter.java.io.IOException
- Throws exception if stream cannot write.public static java.lang.String loadFile(java.lang.String xmlFileName) throws java.io.IOException
xmlFileName
- File pathjava.io.IOException
- Throws exception