FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper Class Reference

The IntArrayWrapper is used as a key for (partial) assignments. More...

Inheritance diagram for frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper:

Public Member Functions

 IntArrayWrapper (int[] array)
 Constructor.
 IntArrayWrapper (int[] array, byte[] byteArray)
 Constructor.
 IntArrayWrapper (int size)
 Constructor Constructs a new array of size size.
void setValue (int index, int value)
 Sets the value in the array.
int getValue (int index)
String toString ()
void extendArray (int newSize)
 Given a new set of variables and values, this array is to be extended.
IntArrayWrapper addValues (int[] newValues, boolean[] changable, int newSize)
 Given a set of new values, a new IntArrayWrapper is created.
IntArrayWrapper getPartialAssignment (boolean[] neededVariables, int size)
 Returns the partial assignment of the assignment stored in array.
boolean equals (Object o)
int hashCode ()
 Uses the superFastHash() function to compute the hash.
byte[] intArrayToByteArray (int[] intArray)
 Transforms an array of int into an array of byte.
int get16bits (byte[] d, int index)
 Returns 16 bits stored in an int.

Protected Attributes

int[] array
 the array representing the variable assignment
byte[] byteArray
 the byte representation of array
final boolean change
 true when the array is to be changed, false otherwise

Private Member Functions

int superFastHash (byte[] data, int len)
 Implementation of the Hsieh hash function, based on the following c-code by Paul Hsieh.

Detailed Description

The IntArrayWrapper is used as a key for (partial) assignments.

The hash function used is a java implementation of the Hsieh hash function

Author
Brammert Ottens, 26 jun 2009

Constructor & Destructor Documentation

◆ IntArrayWrapper() [1/3]

frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.IntArrayWrapper ( int[] array)

Constructor.

Parameters
arraythe array to be stored. This array should be immutable

Reimplemented in frodo2.algorithms.odpop.goodsTree.InnerNodeTree.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.

References array, change, and intArrayToByteArray().

Referenced by addValues(), equals(), and getPartialAssignment().

Here is the call graph for this function:

◆ IntArrayWrapper() [2/3]

frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.IntArrayWrapper ( int[] array,
byte[] byteArray )

Constructor.

Parameters
arraythe array to be stored. This array should be immutable
byteArraythe byte representation of array

Reimplemented in frodo2.algorithms.odpop.goodsTree.InnerNodeTree.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.

References array, byteArray, and change.

◆ IntArrayWrapper() [3/3]

frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.IntArrayWrapper ( int size)

Constructor Constructs a new array of size size.

Parameters
sizethe size of the new array

Reimplemented in frodo2.algorithms.odpop.goodsTree.InnerNodeTree.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.

References change.

Member Function Documentation

◆ addValues()

IntArrayWrapper frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.addValues ( int[] newValues,
boolean[] changable,
int newSize )

Given a set of new values, a new IntArrayWrapper is created.

Note that there can be less new values than there are positions in the original array

Author
Brammert Ottens, 4 okt 2009
Parameters
newValuesan array of new values
changablearray that stores which values can be changed
newSizethe size of the required array
Returns
a new IntArrayWrapper with the new values placed in the appropriate positions

Reimplemented in frodo2.algorithms.odpop.goodsTree.InnerNodeTree.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.

References array, byteArray, and IntArrayWrapper().

Here is the call graph for this function:

◆ equals()

boolean frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.equals ( Object o)
See also
java.lang.Object#equals(java.lang.Object)

References array, and IntArrayWrapper().

Here is the call graph for this function:

◆ extendArray()

void frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.extendArray ( int newSize)

Given a new set of variables and values, this array is to be extended.

If it already is of the correct size, the values are simply updated

Author
Brammert Ottens, 30 jun 2009
Parameters
newSizethe size of the new array

References array, and byteArray.

◆ get16bits()

int frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.get16bits ( byte[] d,
int index )

Returns 16 bits stored in an int.

Author
Brammert Ottens, 26 jun 2009
Parameters
dthe data
indexthe index from which 16 bits must be got
Returns
16 bits of d starting at index

Referenced by superFastHash().

◆ getPartialAssignment()

IntArrayWrapper frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.getPartialAssignment ( boolean[] neededVariables,
int size )

Returns the partial assignment of the assignment stored in array.

Only the positions that are true in neededVariables are used

Author
Brammert Ottens, 26 jun 2009
Parameters
neededVariablesthe variables in the partial assignment
sizethe number of variables in the partial assignment
Returns
an array of int

Reimplemented in frodo2.algorithms.odpop.goodsTree.InnerNodeTree.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.

References array, byteArray, IntArrayWrapper(), and frodo2.algorithms.odpop.goodsTree.GoodsTree< Val extends Addable< Val >, U extends Addable< U >, L extends Node< U > >.numberOfVariables.

Referenced by frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.add(), frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.checkLeaf(), frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.createLeaf(), frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.createLeaf(), and frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.hasSupport().

Here is the call graph for this function:

◆ getValue()

int frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.getValue ( int index)
Author
Brammert Ottens, 1 jul 2009
Parameters
indexthe position in the array whose value we want to know
Returns
returns the value of the array at index

References array.

Referenced by frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.addVariableToTree().

◆ hashCode()

int frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.hashCode ( )

Uses the superFastHash() function to compute the hash.

See also
java.lang.Object#hashCode()

References byteArray, and superFastHash().

Here is the call graph for this function:

◆ intArrayToByteArray()

byte[] frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.intArrayToByteArray ( int[] intArray)

Transforms an array of int into an array of byte.

Author
Brammert Ottens, 26 jun 2009
Parameters
intArraythe array of int
Returns
the byte representation of the input array

References byteArray.

Referenced by IntArrayWrapper().

◆ setValue()

◆ superFastHash()

int frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.superFastHash ( byte[] data,
int len )
private

Implementation of the Hsieh hash function, based on the following c-code by Paul Hsieh.

    unsigned int get16bits (unsigned char *d) {
       return ((unsigned int) d[1] @iliteral < @endiliteral @iliteral < @endiliteral  8) + ((unsigned int) d[0]);
    }

    unsigned int SuperFastHash (char * data, int len) {
       unsigned int hash = len, tmp;
       int rem;

         if (len @iliteral < @endiliteral = 0 || data == NULL) return 0;

         rem = len @iliteral & @endiliteral  3;
         len @iliteral > @endiliteral @iliteral > @endiliteral = 2;

         // Main loop 
         for (;len @iliteral > @endiliteral  0; len--) {
             hash  += get16bits (data);
             tmp    = (get16bits (data+2) @iliteral < @endiliteral @iliteral < @endiliteral  11) ^ hash;
             hash   = (hash @iliteral < @endiliteral @iliteral < @endiliteral  16) ^ tmp;
             data  += 2*2;
             hash  += hash @iliteral > @endiliteral @iliteral > @endiliteral  11;
         }

         // Handle end cases 
         switch (rem) {
             case 3: hash += get16bits (data);
                     hash ^= hash @iliteral < @endiliteral @iliteral < @endiliteral  16;
                     hash ^= data[2] @iliteral < @endiliteral @iliteral < @endiliteral  18;
                     hash += hash @iliteral > @endiliteral @iliteral > @endiliteral  11;
                     break;
             case 2: hash += get16bits (data);
                     hash ^= hash @iliteral < @endiliteral @iliteral < @endiliteral  11;
                     hash += hash @iliteral > @endiliteral @iliteral > @endiliteral  17;
                     break;
             case 1: hash += *data;
                     hash ^= hash @iliteral < @endiliteral @iliteral < @endiliteral  10;
                     hash += hash @iliteral > @endiliteral @iliteral > @endiliteral  1;
         }

         // Force "avalanching" of final 127 bits
         hash ^= hash @iliteral < @endiliteral @iliteral < @endiliteral  3;
         hash += hash @iliteral > @endiliteral @iliteral > @endiliteral  5;
         hash ^= hash @iliteral < @endiliteral @iliteral < @endiliteral  4;
         hash += hash @iliteral > @endiliteral @iliteral > @endiliteral  17;
         hash ^= hash @iliteral < @endiliteral @iliteral < @endiliteral  25;
         hash += hash @iliteral > @endiliteral @iliteral > @endiliteral  6;

         return hash;
    }
Author
Brammert Ottens, 26 jun 2009
Parameters
datathe data to be hashed
lenthe length of the array
Returns
the hashcode belonging to data

References get16bits().

Referenced by hashCode().

Here is the call graph for this function:

◆ toString()

String frodo2.algorithms.odpop.goodsTree.InnerNodeTreeFullDomain.InnerNodeTree< Val extends Addable< Val >, U extends Addable< U >, L extends LeafNode< U > >.IntArrayWrapper.toString ( )
See also
java.lang.Object#toString()

References array.

Member Data Documentation

◆ array

◆ byteArray

◆ change


The documentation for this class was generated from the following file: