RuleGenerationMode
OptRule
public class Rule extends java.lang.Object implements RuleGenerationMode
getRuleStatistics()
method.covers
method) by means of invoking
TestMemoryContainerDeliverer.getTestMemoryContainer
method. Such solution allows to set test
memory container for many rules at once,
using TestMemoryContainerDeliverer.setTestMemoryContainer(MemoryContainer)
method.Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
andConjunction |
Conjunction used when concatenating conditions while transforming rule to textual form.
|
static int |
APPROXIMATE |
Possible value of the rule's type, assigned when rule is approximate (induced from boundary of decision class
or from boundary of a union of decision classes)
|
static int |
AT_LEAST |
Possible value of the rule's characteristic decision class usage tip,
assigned when given characteristic decision class should be treated as basic class for union of type
AT_LEAST |
static int |
AT_MOST |
Possible value of the rule's characteristic decision class usage tip,
assigned when given characteristic decision class should be treated as basic class for union of type
AT_MOST |
static java.lang.String |
briefDescriptionDelimiter |
Delimiter inserted before and after brief description at the end of textual form of this rule.
|
static int |
CERTAIN |
Possible value of the rule's type, assigned when rule is certain (induced from lower approximation of decision
class or from lower approximation of a union of decision classes)
|
static java.lang.String |
conditionsAndDecisionsDelimiter |
Delimiter inserted between condition and decision part of the rule while transforming rule to textual form.
|
static boolean |
DEFAULT_RULE_IN_GENERATION_MODE |
Default value of the flag indicating if this rule is currently in rule generation mode.
|
static int |
DOWNWARD |
Alias for
Rule.AT_MOST |
static int |
EQUAL |
Possible value of the rule's characteristic decision class usage tip,
assigned when given characteristic decision class should be taken directly into account
and when decision (decisions) on the right (decision) side of the rule contains (contain) only relation =
|
static int |
LEARNING_MEMORY_CONTAINER |
Possible value of memory container type method parameter,
applied when learning memory container should be used while checking if this rule covers example with given number
|
static java.lang.String |
orConjunction |
Conjunction used when concatenating decisions while transforming rule to textual form.
|
static int |
POSSIBLE |
Possible value of the rule's type, assigned when rule is possible (induced from upper approximation of decision
class or from upper approximation of a union of decision classes)
|
static java.lang.String |
ruleStarter |
Value appended to the beginning of the rule while transforming rule to textual form.
|
static int |
TEST_MEMORY_CONTAINER |
Possible value of memory container type method parameter,
applied when test memory container should be used while checking if this rule covers example with given number.
|
static int |
UPWARD |
Alias for
Rule.AT_LEAST |
Constructor | Description |
---|---|
Rule(int type,
int characteristicDecisionClassUsageTip,
Field characteristicDecisionClass,
ConditionValidator conditionValidator,
java.util.HashSet<Condition> conditions,
java.util.HashSet<Condition> decisions,
MemoryContainer learningMemoryContainer,
double consistencyLevel,
ApproximatedEntity approximatedEntity,
ApproximatedEntityDecisionsPredictor approximatedEntityDecisionsPredictor) |
Constructs rule of given type, for given characteristic decision class
and tip for its usage, from given conditions and decisions and for given learning memory container.
|
Rule(int type,
int characteristicDecisionClassUsageTip,
Field characteristicDecisionClass,
ConditionValidator conditionValidator,
java.util.HashSet<Condition> conditions,
java.util.HashSet<Condition> decisions,
MemoryContainer learningMemoryContainer,
int[] numbersOfPositiveExamples) |
Constructs rule of given type, for given characteristic decision class
and tip for its usage, from given conditions and decisions, for given learning memory container
and for given array with numbers of positive examples from learning memory container for which this rule
was induced.
|
Rule(int type,
int characteristicDecisionClassUsageTip,
Field characteristicDecisionClass,
ConditionValidator conditionValidator,
java.util.HashSet<Condition> conditions,
java.util.HashSet<Condition> decisions,
Attribute[] learningAttributes) |
Constructs rule of given type, for given characteristic decision class
and tip for its usage, from given conditions and decisions and for given attributes from learning memory container.
Stores references to condition validator and learning attributes, without coping. |
Rule(int type,
int characteristicDecisionClassUsageTip,
Field characteristicDecisionClass,
ConditionValidator conditionValidator,
java.util.HashSet<Condition> decisions,
MemoryContainer learningMemoryContainer,
int[] numbersOfPositiveExamples) |
Constructs rule of given type, for given characteristic decision class
and tip for its usage, from given decisions, for given learning memory container
and for given array with numbers of positive examples from learning memory container for which this rule
was induced.
|
Rule(int type,
int characteristicDecisionClassUsageTip,
Field characteristicDecisionClass,
ConditionValidator conditionValidator,
MemoryContainer learningMemoryContainer,
int[] numbersOfPositiveExamples) |
Constructs rule of given type, for given characteristic decision class
and tip for its usage, for given learning memory container and for given array with numbers of positive examples
from learning memory container for which this rule was induced.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addCondition(Condition condition) |
Adds "regular" condition to the left (condition) side of this rule and deletes temporary additional condition.
|
void |
addDecision(Condition decision) |
Adds decision to the right (decision) side of this rule.
|
void |
addOrExchangeTemporaryCondition(Condition condition) |
Adds or exchange temporary additional condition, independent of "regular" conditions stored in
conditions hash table. |
boolean |
containsCondition(Condition condition) |
Checks if this rule already contains "regular" condition equal to given one
|
boolean |
containsConditionForAttribute(int attributeNumber) |
Checks if this rule already contains "regular" condition for attribute with given number
|
boolean |
covers(int exampleNumber,
int typeOfMemoryContainerUsed) |
Checks if example with given number from memory container of given type (learning or test) is covered by this rule.
|
boolean |
covers(int exampleNumber,
MemoryContainer memoryContainer) |
Checks if example with given number from given memory container is covered by this rule.
|
boolean |
covers(Example example) |
TODO - test of compatibility of rule and example?
|
boolean |
coversNotNeutral(int exampleNumber) |
Checks if example with given number from learning memory container is covered by this rule
and at the same time is not neutral to this rule.
|
boolean |
decisionsMatchedBy(int exampleNumber) |
Checks if example which comes from learning memory container and has given number matches at least one decision of this rule.
|
Rule[] |
decomposePairConditionsToSingleConditionsForPairOfValues() |
Decomposes each
PairCondition present in this rule into set of SingleConditionForPairOfValues objects
by means of PairCondition.decomposeToSingleConditionsForPairOfValues() method. |
void |
deleteCondition(Condition condition) |
Permanently deletes from this rule "regular" condition equal to given one (to given pattern).
|
void |
deleteTemporaryCondition() |
Deletes temporary additional condition for this rule (sets it to
null ) |
void |
enterRuleGenerationMode() |
Enters rule generation mode.
|
int |
getApproximatedEntitySize() |
Gets size (quantity of examples) of approximated entity for which this rule has been created.
|
Field |
getCharacteristicDecisionClass() |
Gets characteristic decision class of this rule.
|
int |
getCharacteristicDecisionClassUsageTip() |
Gets tip for usage of characteristic decision class of this rule.
|
static java.lang.String |
getCharacteristicDecisionClassUsageTipAsText(int characteristicDecisionClassUsageTip) |
Converts given characteristic decision class usage tip of the rule into
String . |
IHashtable<java.lang.Integer,java.lang.Object> |
getConditions() |
Gets hash table with all "regular" conditions present in this rule, indexed by attribute number.
|
Condition[] |
getConditionsAsArray() |
Gets array with all "regular" conditions present in this rule.
|
ConditionValidator |
getConditionValidator() |
Gets reference to condition validator used to validate all conditions and decisions added to this rule
|
Condition[] |
getDecisions() |
Gets array (
Condition[] ) with all decisions present in this rule.Because of efficiency, reference to the field of this class, not its copy, is returned. |
Attribute[] |
getLearningAttributes() |
Gets array with attributes from learning memory container for which this rule was generated (gives direct access)
|
MemoryContainer |
getLearningMemoryContainer() |
Gets reference to learning memory container for which this rule was generated.
|
int |
getQuantityOfConditions() |
Gets number of "regular" conditions on the left side of this rule.
|
int |
getQuantityOfDecisions() |
Gets number of decisions on the right side of this rule
|
RuleStatistics |
getRuleStatistics() |
Gets object which can store and calculate on demand (if not already stored) any statistic of this rule.
Gives direct access to that object, thus enabling not only to get any statistic, but also to set any. This method is especially important when after read from file this rule lacks reference to learning memory container. |
java.util.HashSet<java.lang.Integer> |
getSetOfNeutralExamplesNumbers() |
Gets set with numbers of examples from learning memory container which this rule should completely ignore
(i.e., they are neither positive nor negative).
|
java.util.HashSet<java.lang.Integer> |
getSetOfPositiveExamplesNumbers() |
Gets set with numbers of positive examples from learning memory container for which this rule was induced.
|
Condition |
getTemporarilyDeletedCondition() |
Gets temporarily deleted condition, belonging to "regular" conditions returned by
getConditions method. |
Condition |
getTemporaryCondition() |
Gets temporary additional condition, independent of "regular" conditions returned by
getConditions method. |
MemoryContainer |
getTestMemoryContainer() |
Gets reference to test memory container used by this rule, which is memory container stored in
TestMemoryContainerDeliverer class. |
int |
getType() |
Gets type of this rule.
|
static java.lang.String |
getTypeAsText(int type) |
Converts given type of the rule into
String . |
boolean |
isInRuleGenerationMode() |
Tells if decision rule is in generation mode, i.e. if it can be extended by new conditions
during rule generation process
|
void |
leaveRuleGenerationMode() |
Leaves rule generation mode.
|
boolean |
memoryContainerIsCompatible(MemoryContainer memoryContainer) |
Checks if given memory container is compatible with this rule.
|
void |
restoreTemporarilyDeletedCondition() |
Unmarks "regular" condition that was marked as temporarily deleted by
setOrExchangeTemporarilyDeletedCondition method. |
void |
setConditions(java.util.HashSet<Condition> conditions) |
Sets all conditions from given hash set on the left (condition) side of this rule,
deletes temporary additional condition and sets reference to temporarily deleted condition to
null . |
void |
setDecisions(java.util.HashSet<Condition> decisions) |
Sets all decisions from given hash set on the right (decision) side of this rule.
|
void |
setLearningMemoryContainer(MemoryContainer learningMemoryContainer) |
Sets reference to learning memory container.
|
boolean |
setNumbersOfNeutralExamples(int[] numbersOfNeutralExamples) |
Sets numbers of neutral examples for this rule.
Given list of numbers is transformed to Integer hash set and stored in this rule.Main goal of this method is to facilitate reconstruction of rule's set of neutral examples' numbers after rule is read from file. Currently this method always returns true . |
boolean |
setNumbersOfPositiveExamples(int[] numbersOfPositiveExamples) |
Sets numbers of positive examples for this rule.
Given list of numbers is transformed to Integer hash set and stored in this rule.Main goal of this method is to facilitate reconstruction of rule's set of positive examples' numbers after rule is read from file. Currently this method always returns true . |
boolean |
setOfNeutralExamplesNumbersContains(int exampleNumber) |
Checks if the set of neutral examples' numbers contains the example with given number.
|
boolean |
setOfNeutralExamplesNumbersIsSet() |
Checks if the set of neutral examples numbers is set (!
|
int |
setOfNeutralExamplesNumbersSize() |
Gets size of the set of neutral examples numbers
|
boolean |
setOfPositiveExamplesNumbersContains(int exampleNumber) |
Checks if the set of positive examples numbers contains example with given number
|
boolean |
setOfPositiveExamplesNumbersIsSet() |
Checks if the set of positive examples numbers is set (!
|
int |
setOfPositiveExamplesNumbersSize() |
Gets size of the set of positive examples numbers
|
void |
setOrExchangeTemporarilyDeletedCondition(Condition condition) |
Sets or exchanges temporarily deleted "regular" condition from this rule.
|
void |
setRuleStatistics(RuleStatistics ruleStatistics) |
Sets all statistics of this rule at once.
|
void |
setSetOfNeutralExamplesNumbers(java.util.HashSet<java.lang.Integer> setOfNeutralExamplesNumbers) |
Sets set with numbers of examples from learning memory container which this rule should completely ignore
(i.e., they are neither positive nor negative).
|
void |
setSetOfPositiveExamplesNumbers(java.util.HashSet<java.lang.Integer> setOfPositiveExamplesNumbers) |
Sets set with numbers of positive examples from learning memory container and thus affects all future checks
if this rule is supported by some example from learning memory container.
|
boolean |
supportedBy(int exampleNumber) |
Checks if example which comes from learning memory container and has given number supports this rule.
|
boolean |
supportedByCoveredExample(int exampleNumber) |
Checks if example that is covered by this rule also supports it.
|
java.lang.String |
toJAMMString() |
Gets textual form of rule by joining textual forms of conditions and decisions.
|
java.lang.String |
toShortString() |
Gets textual form of this rule by joining textual forms of conditions and decisions.
|
java.lang.String |
toString() |
Gets textual form of this rule by joining textual forms of conditions and decisions.
|
public static final int CERTAIN
public static final int POSSIBLE
public static final int APPROXIMATE
public static final int AT_LEAST
AT_LEAST
public static final int UPWARD
Rule.AT_LEAST
public static final int AT_MOST
AT_MOST
public static final int DOWNWARD
Rule.AT_MOST
public static final int EQUAL
public static final int LEARNING_MEMORY_CONTAINER
public static final int TEST_MEMORY_CONTAINER
TestMemoryContainerDeliverer
class should be used
(see description of that class for details).public static final boolean DEFAULT_RULE_IN_GENERATION_MODE
public static java.lang.String ruleStarter
public static java.lang.String andConjunction
public static java.lang.String orConjunction
public static java.lang.String conditionsAndDecisionsDelimiter
public static java.lang.String briefDescriptionDelimiter
public Rule(int type, int characteristicDecisionClassUsageTip, Field characteristicDecisionClass, ConditionValidator conditionValidator, java.util.HashSet<Condition> conditions, java.util.HashSet<Condition> decisions, MemoryContainer learningMemoryContainer, int[] numbersOfPositiveExamples)
Condition
or Condition[]
(array of conditions) if there is more than one condition for some attribute.
Decisions are transformed from given hash set to array stored in this class (Condition[]
).
Each condition and decision is duplicated before storing in this class.
Array with numbers of positive examples is transformed to a hash set stored in this class, because it allows
easier check if example with given number is a positive one.type
- Type of this rule. Can be CERTAIN
, POSSIBLE
or APPROXIMATE
.characteristicDecisionClassUsageTip
- Usage tip for characteristic decision class of this rule.
Can be AT_LEAST
, AT_MOST
or EQUAL
.characteristicDecisionClass
- Decision class characteristic for this rule. Decision class Cl is
characteristic for this rule if:conditionValidator
- condition validator stored in this rule and used to validate all conditions
and decisions added to this ruleconditions
- Hash set with conditions for left (condition) part of the rule.
Each element must be an object of type Condition
.
Given hash set cannot be null
, although it may be empty.decisions
- Hash set with decisions for right (decision) part of the rule.
Each element must be an object of type Condition
.
Given hash set cannot be null
, although it may be empty.learningMemoryContainer
- reference to learning memory container for which this rule was generated.
Given learning memory container cannot be null
.numbersOfPositiveExamples
- array with numbers of positive examples from learning memory container
for which this rule was induced.
Given array cannot be null
, although it may be empty.InvalidValueException
- when type of the rule in none of CERTAIN
, POSSIBLE
or APPROXIMATE
,
when characteristicDecisionClassUsageTip is none of AT_LEAST
, AT_MOST
or EQUAL
,
when any condition or decision is invalid according to condition validator
or when learning memory container contains no attributes or no examplesjava.lang.NullPointerException
- when decision class characteristic for this rule is null
,
when condition validator is null
,
when conditions or decisions are null
,
when learning memory container is null
or when array with numbers of positive examples is null
public Rule(int type, int characteristicDecisionClassUsageTip, Field characteristicDecisionClass, ConditionValidator conditionValidator, java.util.HashSet<Condition> decisions, MemoryContainer learningMemoryContainer, int[] numbersOfPositiveExamples)
addCondition
method (one by one)
or they may be set by means of setConditions
method (many at once).Condition[]
).
Each decision is duplicated before storing in this class.
Array with numbers of positive examples is transformed to a hash set stored in this class, because it allows
easier check if example with given number is a positive one.type
- Type of this rule. Can be CERTAIN
, POSSIBLE
or APPROXIMATE
.characteristicDecisionClassUsageTip
- Usage tip for characteristic decision class of this rule.
Can be AT_LEAST
, AT_MOST
or EQUAL
.characteristicDecisionClass
- Decision class characteristic for this rule. Decision class Cl is
characteristic for this rule if:conditionValidator
- condition validator stored in this rule and used to validate all conditions
and decisions added to this ruledecisions
- Hash set with decisions for right (decision) part of the rule.
Each element must be an object of type Condition
.
Given hash set cannot be null
, although it may be empty.learningMemoryContainer
- reference to learning memory container for which this rule was generated.
Given learning memory container cannot be null
.numbersOfPositiveExamples
- array with numbers of positive examples from learning memory container
for which this rule was induced.
Given array cannot be null
, although it may be empty.InvalidValueException
- when type of the rule in none of CERTAIN
, POSSIBLE
or APPROXIMATE
,
when characteristicDecisionClassUsageTip is none of AT_LEAST
, AT_MOST
or EQUAL
,
when any decision is invalid according to condition validator
or when learning memory container contains no attributes or no examplesjava.lang.NullPointerException
- when decision class characteristic for this rule is null
,
when condition validator is null
,
when decisions are null
,
when learning memory container is null
or when array with numbers of positive examples is null
public Rule(int type, int characteristicDecisionClassUsageTip, Field characteristicDecisionClass, ConditionValidator conditionValidator, MemoryContainer learningMemoryContainer, int[] numbersOfPositiveExamples)
addCondition
and addDecision
methods (one by one)
or they may be set by means of setConditions
and setDecisions
methods (many at once).type
- Type of this rule. Can be CERTAIN
, POSSIBLE
or APPROXIMATE
.characteristicDecisionClassUsageTip
- Usage tip for characteristic decision class of this rule.
Can be AT_LEAST
, AT_MOST
or EQUAL
.characteristicDecisionClass
- Decision class characteristic for this rule. Decision class Cl is
characteristic for this rule if:conditionValidator
- condition validator stored in this rule and used to validate all conditions
and decisions added to this rulelearningMemoryContainer
- reference to learning memory container for which this rule was generated.
Given learning memory container cannot be null
.numbersOfPositiveExamples
- array with numbers of positive examples from learning memory container
for which this rule was induced.
Given array cannot be null
, although it may be empty.InvalidValueException
- when type of the rule in none of CERTAIN
, POSSIBLE
or APPROXIMATE
,
when characteristicDecisionClassUsageTip is none of AT_LEAST
, AT_MOST
or EQUAL
or when learning memory container contains no attributes or no examplesjava.lang.NullPointerException
- when decision class characteristic for this rule is null
,
when condition validator is null
,
when learning memory container is null
or when array with numbers of positive examples is null
public Rule(int type, int characteristicDecisionClassUsageTip, Field characteristicDecisionClass, ConditionValidator conditionValidator, java.util.HashSet<Condition> conditions, java.util.HashSet<Condition> decisions, MemoryContainer learningMemoryContainer, double consistencyLevel, ApproximatedEntity approximatedEntity, ApproximatedEntityDecisionsPredictor approximatedEntityDecisionsPredictor)
Condition
or Condition[]
(array of conditions) if there is more than one condition for some attribute.
Decisions (if different than null
) are transformed from given hash set to array stored in this class (Condition[]
).
Each condition and decision (if decisions are given) is duplicated before storing in this class.
Array with numbers of positive examples is transformed to a hash set stored in this class, because it allows
easier check if example with given number is a positive one.null
. In this case decisions are automatically get
from given approximated entity, basing on type of the rule. See:
ApproximatedEntityDecisionsPredictor.getDecisionsForRuleInducedFromLowerApproximation
,
ApproximatedEntityDecisionsPredictor.getDecisionsForRuleInducedFromUpperApproximation
and
ApproximatedEntityDecisionsPredictor.getDecisionsForRuleInducedFromBoundary
methods for details.type
- Type of this rule. Can be CERTAIN
, POSSIBLE
or APPROXIMATE
.characteristicDecisionClassUsageTip
- Usage tip for characteristic decision class of this rule.
Can be AT_LEAST
, AT_MOST
or EQUAL
.characteristicDecisionClass
- Decision class characteristic for this rule. Decision class Cl is
characteristic for this rule if:conditionValidator
- condition validator stored in this rule and used to validate all conditions
and decisions added to this ruleconditions
- Hash set with conditions for left (condition) part of the rule.
Each element must be an object of type Condition
.
Given hash set cannot be null
, although it may be empty.decisions
- Hash set with decisions for right (decision) part of the rule or null
if decisions
should be automatically get from given approximated entity, basing on rule's type.
Given hash set may be null
; if it is not null
- it may be empty.
If hash table is not null
then each element must be an object of type Condition
.learningMemoryContainer
- reference to learning memory container for which this rule was generated.
Given learning memory container cannot be null
.consistencyLevel
- consistency level needed to calculate numbers of positive examples
from learning memory container for which this rule was induced. These numbers are get from given approximated entity,
depending on type
of the rule.
Value of consistency level must belong to [0, 1] range.approximatedEntity
- Approximated entity for which lower / upper approximation or boundary for given
consistency level need to be get. Obtained array is then the basis for creation of a set with numbers
of positive examples from learning memory container for which this rule was induced.
Approximated entity cannot be null
and it must be defined for memory container
which will be set as this rule's learning memory container.approximatedEntityDecisionsPredictor
- reference to object implementing ApproximatedEntityDecisionsPredictor
interface, which can predict right (decision) side of the rule of given type, induced for lower / upper approximation or boundary
of given approximated entity (union or single decision class).
Approximated entity decisions predictor cannot be null
.InvalidValueException
- when type of the rule in none of CERTAIN
, POSSIBLE
or APPROXIMATE
,
when characteristicDecisionClassUsageTip is none of AT_LEAST
, AT_MOST
or EQUAL
,
when any condition or decision (if decisions are given) is invalid according to condition validator,
when learning memory container contains no attributes or no examples,
when consistency level is outside [0, 1] range
or when given approximated entity is not defined for given learning memory containerjava.lang.NullPointerException
- when decision class characteristic for this rule is null
,
when condition validator is null
,
when conditions are null
,
when learning memory container is null
,
when approximated entity is null
or when given approximated entity decisions predictor is null
public Rule(int type, int characteristicDecisionClassUsageTip, Field characteristicDecisionClass, ConditionValidator conditionValidator, java.util.HashSet<Condition> conditions, java.util.HashSet<Condition> decisions, Attribute[] learningAttributes)
Condition
or Condition[]
(array of conditions) if there is more than one condition for some attribute.
Decisions are transformed from given hash set to array stored in this class (Condition[]
).
Each condition and decision is duplicated before storing in this class.Rule
class constructor is mainly intended to be used in situations when rules are
read from file. In such case, although learning memory container and numbers of positive examples from that
container may be unavailable, learning attributes are always at hand, since they are written to file with rules.
With learning attributes only it is not possible to calculate majority of rule's statistics. But those
statistics, which were calculated earlier for learning memory container, may be read from file.
Learning attributes are enough to perform a compatibility check for test memory container and to reconstruct
rule's conditions (especially conditions' AttributeInfo
objects).learningMemoryContainer
and setOfPositiveExamplesNumbers
fields to null
.type
- Type of this rule. Can be CERTAIN
, POSSIBLE
or APPROXIMATE
.characteristicDecisionClassUsageTip
- Usage tip for characteristic decision class of this rule.
Can be AT_LEAST
, AT_MOST
or EQUAL
.characteristicDecisionClass
- Decision class characteristic for this rule. Decision class Cl is
characteristic for this rule if:conditionValidator
- condition validator stored in this rule and used to validate all conditions
and decisions added to this ruleconditions
- Hash set with conditions for left (condition) part of the rule.
Each element must be an object of type Condition
.
Given hash set cannot be null
, although it may be empty.decisions
- Hash set with decisions for right (decision) part of the rule.
Each element must be an object of type Condition
.
Given hash set cannot be null
, although it may be empty.learningAttributes
- reference to array with attributes from learning memory container.
Learning attributes cannot be null
nor empty.InvalidValueException
- when type of the rule in none of CERTAIN
, POSSIBLE
or APPROXIMATE
,
when characteristicDecisionClassUsageTip is none of AT_LEAST
, AT_MOST
or EQUAL
,
when any condition or decision is invalid according to condition validator
or when array with attributes from learning memory container is emptyjava.lang.NullPointerException
- when decision class characteristic for this rule is null
,
when condition validator is null
,
when conditions or decisions are null
or when array with attributes from learning memory container is null
public boolean coversNotNeutral(int exampleNumber)
setOfNeutralExamplesNumbers
and covers(int, int)
.exampleNumber
- number of example belonging to memory container of given typetrue
if example with given number, from learning memory container,
is not neutral to this rule and covered by this rule, false
otherwisepublic boolean covers(int exampleNumber, int typeOfMemoryContainerUsed)
TestMemoryContainerDeliverer.setTestMemoryContainer
method.
Generally speaking TestMemoryContainerDeliverer
class is used to manage any test memory container,
which may be used by any rule. Each rule gets reference to test memory container by means of
TestMemoryContainerDeliverer.getTestMemoryContainer
method.exampleNumber
- number of example belonging to memory container of given typetypeOfMemoryContainerUsed
- Type of memory container which should be used to check coverage.
Can be LEARNING_MEMORY_CONTAINER
or TEST_MEMORY_CONTAINER
.true
if example with given number, from considered memory container,
is covered by this rule, false
otherwiseInvalidValueException
- when example number is too small or too big for used memory container
or when type of used memory container is not LEARNING_MEMORY_CONTAINER
nor TEST_MEMORY_CONTAINER
java.lang.NullPointerException
- when type of used memory container is LEARNING_MEMORY_CONTAINER
but
learning memory container is not set
or when type of used memory container is TEST_MEMORY_CONTAINER
but
test memory container is not setpublic boolean covers(int exampleNumber, MemoryContainer memoryContainer)
memoryContainerIsCompatible(MemoryContainer)
method first.exampleNumber
- number of example belonging to given memory containermemoryContainer
- reference to memory containertrue
if example with given number is covered by this rule, false
otherwisejava.lang.NullPointerException
- when given memory container is null
InvalidValueException
- when example number is too small or too big for given memory containerpublic boolean covers(Example example)
example
- example to be checkedtrue
if given example is covered by this rule, false
otherwisepublic boolean supportedBy(int exampleNumber)
exampleNumber
- number of example belonging to learning memory containertrue
if concerned example from learning memory container supports this rule,
false
otherwisejava.lang.NullPointerException
- when learning memory container is not setInvalidValueException
- when example number is too small or too big for learning memory containerpublic boolean supportedByCoveredExample(int exampleNumber)
exampleNumber
- number of example from rule's learning memory containertrue
if example with given number, that is covered by this rule, also supports it, false
otherwisejava.lang.NullPointerException
- when rule is in "standard" mode and rule's learning memory container is not setInvalidValueException
- when rule is in "standard" mode, rule's learning memory container is set, but given example number is
too small or too big for learning memory containerpublic boolean decisionsMatchedBy(int exampleNumber)
decisions
are already set (not null
).
If this rule has no decision, throws InvalidValueException
exception.exampleNumber
- number of example belonging to learning memory containertrue
if concerned example from learning memory container matches at least one decision of this rule,
false
otherwisejava.lang.NullPointerException
- when decisions are not already setInvalidValueException
- when rule has no decisionpublic IHashtable<java.lang.Integer,java.lang.Object> getConditions()
Condition
or an array of type Condition[]
if there is more than one condition for considered attribute.
Returned hash table does not contain additional temporary condition (since it's not "regular" one),
but contains temporarily deleted condition (since it's not permanently deleted).public Condition[] getConditionsAsArray()
public boolean containsConditionForAttribute(int attributeNumber)
attributeNumber
- number of attributetrue
if the rule already contains at least one "regular" condition for attribute with given number,
false
otherwisepublic boolean containsCondition(Condition condition)
condition
- condition which should be checkedtrue
if the rule already contains "regular" condition equal to given one, false
otherwisejava.lang.NullPointerException
- when given condition is null
public void setConditions(java.util.HashSet<Condition> conditions)
null
.
Deletes all previous conditions from the left (condition) side of this rule.
Conditions are transformed from given hash set to hash table stored in this class and indexed
by attribute number. Values of this hash table are objects of type Condition
or Condition[]
(array of conditions) if there is more than one condition for some attribute.
Each condition is duplicated before storing in hash table.conditions
- hash set with conditions which should be established on the left (condition) side
of this rule. Each element must be an object of type Condition
.java.lang.NullPointerException
- when conditions are null
InvalidValueException
- when any of the conditions is invalidpublic Condition[] getDecisions()
Condition[]
) with all decisions present in this rule.public void setDecisions(java.util.HashSet<Condition> decisions)
Condition[]
) stored in this class.decisions
- hash set with decisions which should be established on the right (decision) side of this rulejava.lang.NullPointerException
- when decisions are null
InvalidValueException
- when any of the decisions is invalidpublic void addCondition(Condition condition)
condition
- condition to add to the left (condition) side of this ruleInvalidValueException
- when condition added to the left (condition) side of this rule is invalidpublic void addOrExchangeTemporaryCondition(Condition condition)
conditions
hash table. Reference to the duplicate of given condition is stored.condition
- reference to temporary additional condition for this ruleInvalidValueException
- when temporary additional condition added to condition side of this rule is invalidpublic void deleteTemporaryCondition()
null
)public Condition getTemporaryCondition()
getConditions
method.
Reference to the duplicate of the object stored in this class is returned.getConditions
methodpublic void deleteCondition(Condition condition)
ValueNotFoundException
exception if given rule does not contain any "regular" condition equal to given one.
Sets reference to temporarily deleted "regular" condition to null
(no "regular" condition marked as temporarily deleted).condition
- condition for which equal "regular" condition stored in this rule should be permanently deletedjava.lang.NullPointerException
- when given condition (pattern) is null
ValueNotFoundException
- when this rule does not contain any "regular" condition equal to given one (to given pattern)public void setOrExchangeTemporarilyDeletedCondition(Condition condition)
Condition.equals(Object)
method for details) to given one (to given pattern)
is present in this rule then it gets marked as temporarily deleted.
There can be only one temporarily deleted "regular" condition at the same time, so if there is already one condition
marked as temporarily deleted, not equal to given one, this method moves marker to condition equal to given one,
thus restoring previously marked condition.
If given condition is equal to temporarily deleted one, nothing happens - when searching for equal "regular" condition,
temporarily deleted "regular" condition is taken into account.
If "regular" condition equal to given one is not present in this rule than ValueNotFoundException
exception is thrown.condition
- condition for which equal "regular" condition stored in this rule should be marked as temporarily deletedjava.lang.NullPointerException
- when given condition (pattern) is null
ValueNotFoundException
- when this rule does not contain any "regular" condition equal to given one (to given pattern)public void restoreTemporarilyDeletedCondition()
setOrExchangeTemporarilyDeletedCondition
method.
If there is no marked "regular" condition - does nothingpublic Condition getTemporarilyDeletedCondition()
getConditions
method.
Reference to the duplicate of the object stored in this class is returned.getConditions
methodpublic void addDecision(Condition decision)
decision
- decision to add to the right (decision) side of this rulejava.lang.NullPointerException
- when given decision is null
InvalidValueException
- when given decision is invalid according to condition validatorpublic RuleStatistics getRuleStatistics()
public void setRuleStatistics(RuleStatistics ruleStatistics)
RuleStatistics.set
... methods) and finally set ready statistics in considered rule, by means of this method.ruleStatistics
- all statistics of this ruleInvalidValueException
- where given statistics are defined for different rule than thispublic int getType()
CERTAIN
, POSSIBLE
or APPROXIMATE
,
if this rule is certain (induced from lower approximation), possible (induced from upper approximation) or
approximate (induced from boundary), respectively.public int getCharacteristicDecisionClassUsageTip()
AT_LEAST
- characteristic decision class is a basic class "starting" upward union of decision classes (DRSA / VC-DRSA),AT_MOST
- characteristic decision class is a basic class "starting" downward union of decision classes (DRSA / VC-DRSA),EQUAL
- characteristic decision class is a "normal" decision class, used separately from other decision classes (IRSA / VC-IRSA).AT_MOST
=> (technical_state <= bad)AT_LEAST
=> (technical_state <= medium) # for cost decision criterionEQUAL
=> (technical_state = good)EQUAL
=> (technical_state = medium) OR (technical_state = good).AT_LEAST
) is needed only to create proper (in this case upward)
union of decision classes.public Field getCharacteristicDecisionClass()
public ConditionValidator getConditionValidator()
public java.util.HashSet<java.lang.Integer> getSetOfPositiveExamplesNumbers()
null
.public java.util.HashSet<java.lang.Integer> getSetOfNeutralExamplesNumbers()
null
if there are no neutral examples.public boolean setOfPositiveExamplesNumbersContains(int exampleNumber)
exampleNumber
- number of the example from rule's learning memory containertrue
if rule's set of positive examples numbers contains given number,
false
otherwisejava.lang.NullPointerException
- when rule's set of positive examples numbers is null
public boolean setOfNeutralExamplesNumbersContains(int exampleNumber)
exampleNumber
- number of the example from rule's learning memory containertrue
if rule's set of neutral examples numbers contains given number,
false
otherwisejava.lang.NullPointerException
- when rule's set of neutral examples numbers is null
public boolean setOfPositiveExamplesNumbersIsSet()
null
)true
if the set of positive examples numbers is set, false
otherwisepublic boolean setOfNeutralExamplesNumbersIsSet()
null
)true
if the set of neutral examples numbers is set, false
otherwisepublic int setOfPositiveExamplesNumbersSize()
java.lang.NullPointerException
- when set of positive examples' numbers is not set (i.e., it is null
)public int setOfNeutralExamplesNumbersSize()
java.lang.NullPointerException
- when set of neutral examples' numbers is not set (i.e., it is null
)public void setSetOfPositiveExamplesNumbers(java.util.HashSet<java.lang.Integer> setOfPositiveExamplesNumbers)
setOfPositiveExamplesNumbers
- hash set with numbers of positive examples from learning memory containerjava.lang.NullPointerException
- when given set of positive examples' numbers is null
public void setSetOfNeutralExamplesNumbers(java.util.HashSet<java.lang.Integer> setOfNeutralExamplesNumbers)
setOfNeutralExamplesNumbers
- hash set with numbers of neutral examples from learning memory containerpublic boolean setNumbersOfPositiveExamples(int[] numbersOfPositiveExamples)
Integer
hash set and stored in this rule.true
.numbersOfPositiveExamples
- array with numbers of positive examples from learning memory container
for which this rule was createdtrue
if numbers of positive examples have been successfully stored in this class,
false
otherwisepublic boolean setNumbersOfNeutralExamples(int[] numbersOfNeutralExamples)
Integer
hash set and stored in this rule.true
.numbersOfNeutralExamples
- array with numbers of neutral examples from learning memory container
for which this rule was createdtrue
if numbers of neutral examples have been successfully stored in this class,
false
otherwisepublic MemoryContainer getLearningMemoryContainer()
null
) is returned.public Attribute[] getLearningAttributes()
public void setLearningMemoryContainer(MemoryContainer learningMemoryContainer)
learningAttributes
stored in this class
remain unchanged. They should be identical with the attributes from given memory container.learningMemoryContainer
- reference to learning memory containerpublic MemoryContainer getTestMemoryContainer()
TestMemoryContainerDeliverer
class.null
if no test memory container is
stored in TestMemoryContainerDeliverer
classpublic boolean memoryContainerIsCompatible(MemoryContainer memoryContainer)
memoryContainer
- memory container for which compatibility test should be performedtrue
if given memory container is compatible with this rule, false
otherwisejava.lang.NullPointerException
- when given memory container is null
InvalidValueException
- when given memory container contains no attributes or no examplespublic int getQuantityOfConditions()
public int getQuantityOfDecisions()
public java.lang.String toShortString()
ruleStarter
,andConjunction
,conditionsAndDecisionsDelimiter
,orConjunction
.public java.lang.String toString()
ruleStarter
,andConjunction
,conditionsAndDecisionsDelimiter
,orConjunction
.toString
in class java.lang.Object
public java.lang.String toJAMMString()
ruleStarter
andConjunction
conditionsAndDecisionsDelimiter
orConjunction
public static java.lang.String getTypeAsText(int type)
String
.
If type is incorrect returns empty string.type
- rule's type to convertString
public static java.lang.String getCharacteristicDecisionClassUsageTipAsText(int characteristicDecisionClassUsageTip)
String
.
If characteristic decision class usage tip is incorrect returns empty string.characteristicDecisionClassUsageTip
- characteristic decision class usage tip to convertString
public Rule[] decomposePairConditionsToSingleConditionsForPairOfValues()
PairCondition
present in this rule into set of SingleConditionForPairOfValues
objects
by means of PairCondition.decomposeToSingleConditionsForPairOfValues()
method.
Takes into account value of PairField.getDominanceCheckMethod()
method.
If PairField.STRICT_ORDINAL_DOMINANCE_CHECK_METHOD
is used, then returned array may potentially include more than one rule.
If PairField.CLASSIC_ORDINAL_DOMINANCE_CHECK_METHOD
is used, then returned array will include only one rule.
In both cases each returned rule includes only single conditions and single conditions for pair of values,
connected by means of 'and' conjunction.PairField.getDominanceCheckMethod()
value),
including only single conditions and single conditions for pair of values,
connected by means of 'and' conjunctionpublic int getApproximatedEntitySize()
java.lang.NullPointerException
- when size of approximated entity for which this rule has been created
is not already stored in this rule (so it needs to be calculated)
and rule's learning memory container is null
InvalidValueException
- when size of approximated entity for which this rule has been created
is not already stored in this rule (so it needs to be calculated)
and rule's learning memory container does not contain exactly one active decision attributepublic boolean isInRuleGenerationMode()
isInRuleGenerationMode
in interface RuleGenerationMode
true
if rule is in generation process,
i.e. it can still be extended by new conditions, false
otherwisepublic void enterRuleGenerationMode()
enterRuleGenerationMode
in interface RuleGenerationMode
public void leaveRuleGenerationMode()
leaveRuleGenerationMode
in interface RuleGenerationMode