com.cra.bnet.engine
Class VbnConverter

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

public final class VbnConverter
extends Object

This class represents the format of a number in which each digit has an arbitrary integer base. Its primary function is to convert numbers from decimal to its particular variable-base format and back again.

This class was originally designed for CPT generation, where each digit represents a parent of a node and its base represents the number of states of the parent.


Constructor Summary
VbnConverter(int[] bases)
          Creates a new vbn format with the specified bases, and caches the orders.
VbnConverter(List nodes)
          This is a convenience constructor that takes a list of nodes.
 
Method Summary
 int[] fromDecimal(int decimal)
           
 int[] getBases()
           
 int getMaxDecimal()
          This returns the largest decimal number expressible in this format, NOT the total number of expressible values (which of course includes 0).
 int getNumBases()
           
 int[] getOrders()
           
static int getSize(List nodes)
          Returns the size of a vbn over the specified list of nodes without actually creating one.
 boolean isValid(int[] vbn)
           
 int size()
          Returns the total number of values expressible in this format.
 int toDecimal(int[] vbn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VbnConverter

public VbnConverter(int[] bases)
Creates a new vbn format with the specified bases, and caches the orders. The first (index 0) entry in bases must be the ones digit.


VbnConverter

public VbnConverter(List nodes)
This is a convenience constructor that takes a list of nodes. It extracts the number of states of each node, and uses these as the bases for the vbn.

Method Detail

getMaxDecimal

public int getMaxDecimal()
This returns the largest decimal number expressible in this format, NOT the total number of expressible values (which of course includes 0).


size

public int size()
Returns the total number of values expressible in this format.


getSize

public static int getSize(List nodes)
Returns the size of a vbn over the specified list of nodes without actually creating one.

Parameters:
nodes - list of DiscreteNode objects.
Returns:
the size of a vbn over the specified list of nodes without actually creating one.

isValid

public boolean isValid(int[] vbn)

fromDecimal

public int[] fromDecimal(int decimal)

toDecimal

public int toDecimal(int[] vbn)

getBases

public int[] getBases()

getOrders

public int[] getOrders()

getNumBases

public int getNumBases()