ro.mosc.reco.algebra
Class Algebra

java.lang.Object
  extended by ro.mosc.reco.algebra.Algebra
Direct Known Subclasses:
GlyphDescriptionAlgebra

public class Algebra
extends java.lang.Object

Universal algebra class.


Field Summary
protected  java.util.List<Relation> relatios
           
protected  Signature signature
           
protected  java.util.Map<java.lang.Class,java.util.List> supportSets
           
 
Constructor Summary
Algebra(Signature signature)
           
 
Method Summary
 void addElementsInRelation(java.lang.String relationName, java.lang.Object[] elements, double relationValue)
          Add elements to algebra.
 void addElementToAlgebra(java.lang.Object element)
          Algebra signature should contain element's type .

If there is no RelationResolver associated to all relation containing element's type in signature, use another method to add elements to algebra.

the RelationResolver will be used to compute relation's confidence factor for each relation containing element's type in it's signature.
private  void addRelation(Relation relation)
           
private  double getCharacteristicPredicateValue(RelationSignature signature, java.lang.Object[] elements)
          Get characteristicPredicateValue for a given relation signature and some elements
 java.lang.Object[] getMappedElements(Relation relation, java.util.Map mapping)
          Return a list of elements coresponding to a list of given elements, translated by given mapping.
 double isIsomorphism(Algebra algebra, java.util.Map mapping, double threshold)
           
 Isomorphism isomorphism(Algebra algebra)
           
private  java.lang.Object[] recursievlyCreateMapping(int k, int[][] positions, Algebra algebra)
          Recursivelty generates all possible mappings.
private  void recursievlyEnumerateAllElements(RelationSignature relationSignature, java.lang.Object element, int[] positions, int k, int fitPosition)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

supportSets

protected java.util.Map<java.lang.Class,java.util.List> supportSets

relatios

protected java.util.List<Relation> relatios

signature

protected Signature signature
Constructor Detail

Algebra

public Algebra(Signature signature)
Method Detail

addElementToAlgebra

public void addElementToAlgebra(java.lang.Object element)
                         throws RelationResolverException,
                                SortNotSupported
Algebra signature should contain element's type .

If there is no RelationResolver associated to all relation containing element's type in signature, use another method to add elements to algebra.

the RelationResolver will be used to compute relation's confidence factor for each relation containing element's type in it's signature.

Parameters:
element - the element to add to the algebra.
Throws:
RelationResolverException - if can not find a resolver for each relation heaving element's class in it's signature.
SortNotSupported

recursievlyEnumerateAllElements

private void recursievlyEnumerateAllElements(RelationSignature relationSignature,
                                             java.lang.Object element,
                                             int[] positions,
                                             int k,
                                             int fitPosition)

addRelation

private void addRelation(Relation relation)

addElementsInRelation

public void addElementsInRelation(java.lang.String relationName,
                                  java.lang.Object[] elements,
                                  double relationValue)
Add elements to algebra. Those elements are in relation identified by relationName, with a confidence factor: relationValue.

Parameters:
relationName - name of the relation.
elements - a list of elements.
relationValue - confidence factor.

isomorphism

public Isomorphism isomorphism(Algebra algebra)
                        throws NoIsomorphismsException
Throws:
NoIsomorphismsException

recursievlyCreateMapping

private java.lang.Object[] recursievlyCreateMapping(int k,
                                                    int[][] positions,
                                                    Algebra algebra)
Recursivelty generates all possible mappings.

Parameters:
k - the index of the currently permutated sort.
positions - and array of permutation indices (the isomorphism mapping as an array of ints)
algebra - the target (isomorphic) algebra.
Returns:
an object array containing two elements:
[0] -> the isomorphism mapping as a java.util.Map,and
[1] -> the isomorphism value as a java.lang.Double.

isIsomorphism

public double isIsomorphism(Algebra algebra,
                            java.util.Map mapping,
                            double threshold)
Parameters:
algebra - an algebra
mapping - a mapping
threshold - 0 means exact isomorphism, 1 means any mapping.
Returns:
true iff mapping is an isomorphism between this and given algebra

getCharacteristicPredicateValue

private double getCharacteristicPredicateValue(RelationSignature signature,
                                               java.lang.Object[] elements)
Get characteristicPredicateValue for a given relation signature and some elements

Parameters:
signature -
elements -
Returns:
value of the characteristic predicate, or 0 is elements are not related.

getMappedElements

public java.lang.Object[] getMappedElements(Relation relation,
                                            java.util.Map mapping)
Return a list of elements coresponding to a list of given elements, translated by given mapping.

Parameters:
relation -
mapping - a mapping from source objects (hashCode) - to destination objects
Returns:
a list of elements transformed through given mapping.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object