public class DiscretizingHashableStateFactory extends SimpleHashableStateFactory
HashableState
objects that computes hash codes
and test for state equality after discretizing any real values. Discretizing is performed by flooring
real values to the nearest user-defined multiple. For example, if the multiple is set to 0.5, then 9.73
would become 9.5, and 102.3 would become 102. Note using a
multiple value of 1.0 is equivalent to floor values to their corresponding int value.
Large multiple values result in course discretization and small
multiple values result in a fine discretization.
addFloorDiscretizingMultipleFor(String, double)
method. When a continuous attribute is to be
hashed or compared, it is first checked if there has been a specific multiple value set for it. If so, that multiple is used for discretization. If not,
the default multiple is used. The default multiple may be set
though the constructors or by
using the setDefaultFloorDiscretizingMultiple(double)
method.
SimpleHashableStateFactory
, which means it can be toggled to
to be object identifier/name independent or dependent and can be set to use HashableState
instances that hash their hash code or not. See the SimpleHashableStateFactory
class documentation for more information on those features.SimpleHashableStateFactory.AttClass, SimpleHashableStateFactory.SimpleCachedHashableState, SimpleHashableStateFactory.SimpleHashableState, SimpleHashableStateFactory.SimpleHashableStateInterface
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.Double> |
attributeWiseMultiples
The multiples to use for specific attributes
|
protected double |
defaultMultiple
The default multiple to use for any continuous attributes that have not been specifically set.
|
identifierIndependent, useCached
Constructor and Description |
---|
DiscretizingHashableStateFactory(boolean identifierIndependent,
boolean useCached,
double defaultMultiple)
Initializes.
|
DiscretizingHashableStateFactory(boolean identifierIndependent,
double defaultMultiple)
Initializes with non hash code caching
|
DiscretizingHashableStateFactory(double defaultMultiple)
Initializes with object identifier independence and no hash code caching.
|
Modifier and Type | Method and Description |
---|---|
void |
addFloorDiscretizingMultipleFor(java.lang.String attributeName,
double nearestMultipleValue)
Sets the multiple to use for discretization for the attribute with the specified name.
|
protected void |
appendHashcodeForValue(org.apache.commons.lang3.builder.HashCodeBuilder hashCodeBuilder,
Value v)
Appends the hash code for the given
Value to the HashCodeBuilder |
protected static int |
intMultiples(double mult,
double num)
Returns int result of num / mult; that is, (int)(num / mult).
|
void |
setDefaultFloorDiscretizingMultiple(double defaultMultiple)
Sets the default multiple to use for continuous attributes that do not have specific multiples set
for them.
|
protected boolean |
valuesEqual(Value v1,
Value v2)
Returns whether two values are equal.
|
computeHashCode, computeHashCode, getAttClass, hashState, identifierDependentEquals, identifierIndependentEquals, objectIdentifierIndependent, objectValuesEqual, statesEqual
protected java.util.Map<java.lang.String,java.lang.Double> attributeWiseMultiples
protected double defaultMultiple
public DiscretizingHashableStateFactory(double defaultMultiple)
defaultMultiple
- The default multiple to use for any continuous attributes that have not been specifically set.public DiscretizingHashableStateFactory(boolean identifierIndependent, double defaultMultiple)
identifierIndependent
- if true then state evaluations are object identifier independent; if false then dependent.defaultMultiple
- The default multiple to use for any continuous attributes that have not been specifically set.public DiscretizingHashableStateFactory(boolean identifierIndependent, boolean useCached, double defaultMultiple)
identifierIndependent
- if true then state evaluations are object identifier independent; if false then dependent.useCached
- if true then the hash code for each produced HashableState
will be cached; if false then they will not be cached.defaultMultiple
- The default multiple to use for any continuous attributes that have not been specifically set.public void addFloorDiscretizingMultipleFor(java.lang.String attributeName, double nearestMultipleValue)
attributeName
- the name of the attribute whose discretization multiple is being set.nearestMultipleValue
- the multiple to which values are floored.public void setDefaultFloorDiscretizingMultiple(double defaultMultiple)
defaultMultiple
- the default multiple to which values are flooredprotected void appendHashcodeForValue(org.apache.commons.lang3.builder.HashCodeBuilder hashCodeBuilder, Value v)
SimpleHashableStateFactory
Value
to the HashCodeBuilder
appendHashcodeForValue
in class SimpleHashableStateFactory
hashCodeBuilder
- the HashCodeBuilder
to which the value's hash code will be appendedv
- the Value
whose hash code should be appended.protected boolean valuesEqual(Value v1, Value v2)
valuesEqual
in class SimpleHashableStateFactory
v1
- the first value to comparev2
- the second value to compareprotected static int intMultiples(double mult, double num)
mult
- the multiplenum
- the number