ComparableExt<Field>
public class FuzzyField extends CompoundField
Possibility
elements.
In a fuzzy field you are able to store as many values from the domain with possibility assigned as you want.
If you don't give the value, it means its possibility is zero.
Each value from the domain should be inserted only once (but is's not checked). Domain of all elements must be the same and once assigned cannot be changed. When you create new fuzzy field you have to assign one value from the domain as a pattern for next element, which you are going to insert. This is to prevent from changing the domain while modifying fuzzy field.
Modifier and Type | Field | Description |
---|---|---|
SimpleField |
template |
A template of simple fields, which can be added to the fuzzy field list.
|
Constructor | Description |
---|---|
FuzzyField(java.util.List<Possibility> possibilities,
SimpleField field) |
Creates new fuzzy field and stores possibilities.
|
FuzzyField(SimpleField field) |
Creates new fuzzy field with an empty possibility list.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addElement(Possibility possibility) |
Adds new possibility to this fuzzy field.
|
void |
addElement(SimpleField field,
double prob) |
Adds a new simple field and possibility to the fuzzy field.
|
boolean |
checkConstraints() |
Checks if the type of each simple field stored in possibility list is identical.
|
void |
clear() |
It clears the list, so you can start adding elements from beginnig.
|
java.lang.Integer |
compareTo(Field object) |
Compares other field to this field.
|
void |
copy(Field field) |
It makes a copy of class variables.
|
void |
deleteElement(int index) |
Removes the possibility at specified index.
|
Field |
duplicate() |
Makes a new instance of a field.
|
Possibility |
getElement(int index) |
Gives an element at specified index.
|
java.lang.Class<? extends SimpleField> |
getInnerType() |
Gives a type of fields which are held inside the trapeziodal value.
|
boolean |
isSimilarTo(Field field) |
Tests if given field's type is similar to this one.
|
int |
isUnknown() |
Tests if fuzzy field value is determined.
|
void |
setUnknown() |
Makes this fuzzy field unknown.
|
int |
size() |
Reads the length of fuzzy's list.
|
java.lang.String |
toString() |
Returns a
String which represents value of this field. |
isGenerated, setGenerated
public final SimpleField template
public FuzzyField(java.util.List<Possibility> possibilities, SimpleField field)
addExample
method (take a look).
But if the list is not empty, it can contain simple fields (indirectly) only,
which are values from the same domain. The sequence of values is insignificant.
If simple fields' domain is not identical for all of them or when the list doesn't contain
elements of Possibility
class, the InvalidTypeException
is thrown.
Given simple field is stored in template
variable. It will be duplicated and cannot be null.
possibilities
- list of Possibility
class elements to be storedfield
- pattern for fields stored in the fuzzy field (this field is not added to the list)InvalidTypeException
- if values' type in possibilities is not identicaljava.lang.NullPointerException
- if simple field given as template is nullpublic FuzzyField(SimpleField field)
template
field.
This fuzzy field represents a domain of values with possibility equaled zero.field
- pattern for simple fields stored in the fuzzy field (this field is not added to the list)java.lang.NullPointerException
- if given field is nullpublic void clear()
public boolean checkConstraints()
checkConstraints
in class CompoundField
public void addElement(SimpleField field, double prob)
Possiblility
element using
Possibility(SimpleField value, double p)
constructor,
so the simple field is being duplicated.
The type of the inserted element should be the same as in the template.
It doesn't check if such a value of the domain still exists on the list,
so be aware of using this method to change possibility assigned to a simple field
(use getElement(int)
to modify elements).
Notice, that after adding a new element, the result of isUnknown()
may change.field
- simple field stored in this classprob
- possibility for this elementInvalidTypeException
- if the type of the simple field in the possibility is incorrectjava.lang.NullPointerException
- when given field is nullpublic void addElement(Possibility possibility)
addElement(SimpleField,prob)
method.possibility
- element to addInvalidTypeException
- if the type of simple field in possibility is incorrectjava.lang.NullPointerException
- when given possibility is nullpublic void deleteElement(int index)
index
- position of element to be deletedInvalidValueException
- when index is out of rangepublic void copy(Field field)
copy
in class Field
field
- object which is fuzzy field with possibilities containing simple fields of the same typeInvalidTypeException
- when field is not FuzzyField or if simple fields cannot be copiedjava.lang.NullPointerException
- if given field is nullpublic Field duplicate()
Field
public java.lang.Class<? extends SimpleField> getInnerType()
public int size()
public Possibility getElement(int index)
index
- position of element at the listInvalidValueException
- when index is out of rangepublic boolean isSimilarTo(Field field)
isSimilarTo
in class Field
field
- compared fuzzy fieldtrue
if both fuzzy fields have list with similar simple fieldsjava.lang.NullPointerException
- if given field is nullpublic java.lang.String toString()
String
which represents value of this field.
For known fuzzy field its result should be a set
of possibilities separated by comma and enclosed in brackets.
To add each element to the string, Possibility.toString()
method is used.
The sequence of simple fields' values is the same as stored on the list,
so you can use index to change one.toString
in class java.lang.Object
public int isUnknown()
unknown
field (so it cannot be semiknown then).
Otherwise fuzzy field is known when all simple fields on the list are known (except template
of course, which is not there). When a few of them stay unknown,
the result is semiknown.public void setUnknown()
true
to unknown
,
so the fuzzy is unknown when you use isUnknown()
method.
If you want to change this state, add any element on the list.
You can also use clear
if you want to make empty fuzzy field known.
setUnknown
in class Field
public java.lang.Integer compareTo(Field object)
object
- other field to compare with