com.cra.bnet.engine
Class PotentialMappings

java.lang.Object
  |
  +--com.cra.bnet.engine.PotentialMappings

public class PotentialMappings
extends Object

A cache of mappings between potentials. When performing operations on potentials, such as marginalization, multiplication, division, etc., corresponding elements of the two potentials' arrays must be computed. This computation is expensive and is performed very often during inferencing. Luckily, these mappings are repetitive and reusable so caching them once they are computed offers great performance benefits.

This class does just that: it computes the mapping between two potentials and caches the result for reuse later. Typically the getMapping method is all you will need to use this class effectively.


Constructor Summary
PotentialMappings()
          Creates a new empty PotentialMappings object.
 
Method Summary
 void clear()
          Removes all mappings from this potential mappings object.
 int[] getMapping(List variables1, List variables2)
          Returns the mapping from a potential over the first list of nodes to a potential over the second list of nodes.
 boolean isCaching()
          Returns true if mappings are to be cached and false otherwise.
 void setCache(boolean cache)
          If the specified boolean argument is true, this object will cache its mappings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PotentialMappings

public PotentialMappings()
Creates a new empty PotentialMappings object.

Method Detail

clear

public void clear()
Removes all mappings from this potential mappings object.


getMapping

public int[] getMapping(List variables1,
                        List variables2)
Returns the mapping from a potential over the first list of nodes to a potential over the second list of nodes. If this object does not already have a mapping between the two potentials it is computed and stored. Otherwise, the precomputed mapping is returned. Note that the second list of nodes must be a subset of the first list of nodes.

Parameters:
variables1 - first list of nodes.
variables2 - second list of nodes.
Returns:
the mapping from a potential over the first list of nodes to a potential over the second list of nodes.

isCaching

public boolean isCaching()
Returns true if mappings are to be cached and false otherwise.

Returns:
true if mappings are to be cached and false otherwise.

setCache

public void setCache(boolean cache)
If the specified boolean argument is true, this object will cache its mappings. If false, it will not cache those mappings.

Parameters:
cache - caching state for this object.