public class DiscretizingHashableStateFactory extends SimpleHashableStateFactory
HashableState
objects that computes hash codes
and test for state equality after discretizing any real values (Float or Double). 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.
The multiple used can be specified for individual variables so that different variables have different degrees of discretization. To set
the multiple used for a specific attribute, use the addFloorDiscretizingMultipleFor(Object, double)
method. When a real value is to be
hashed or compared, it is first checked if there has been a variable-specific discretization set for it. If not,
the default multiple is used. The default multiple may be set
through the constructors or by
using the setDefaultFloorDiscretizingMultiple(double)
method.
This class extends SimpleHashableStateFactory
, which means it can be toggled to
to be object identifier independent or dependent for OOState
s.
Modifier and Type | Field and Description |
---|---|
protected DiscConfig |
config
The discretization config
|
identifierIndependent
Constructor and Description |
---|
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.Object key,
double nearestMultipleValue)
Sets the multiple to use for discretization for the given key.
|
HashableState |
hashState(State s)
Turns
State s into a HashableState |
void |
setDefaultFloorDiscretizingMultiple(double defaultMultiple)
Sets the default multiple to use for continuous values that do not have specific multiples set
for them.
|
objectIdentifierIndependent
protected DiscConfig config
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 void addFloorDiscretizingMultipleFor(java.lang.Object key, double nearestMultipleValue)
key
- the name of the state variable key 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 flooredpublic HashableState hashState(State s)
HashableStateFactory
State
s into a HashableState
hashState
in interface HashableStateFactory
hashState
in class SimpleHashableStateFactory
s
- the input State
to transform.HashableState
.