unbbayes.prs.bn
Class PotentialTable

java.lang.Object
  extended by unbbayes.prs.bn.PotentialTable
All Implemented Interfaces:
Serializable, Cloneable, IProbabilityFunction
Direct Known Subclasses:
ProbabilisticTable, UtilityTable

public abstract class PotentialTable
extends Object
implements Cloneable, Serializable, IProbabilityFunction

Tabela de Potencial.

Version:
21 de Setembro de 2001
Author:
Michael e Rommel
See Also:
Serialized Form

Field Summary
protected  FloatCollection dataCopy
          Copy of the data from the data.
protected  FloatCollection dataMarginal
          The data from the table as a list of floats.
protected  FloatCollection dataPT
          The data from the table as a list of floats.
static int DIVISION_OPERATOR
           
protected  int[] factorsMarginal
          Factors used to convert linear coordinates in multidimensional ones.
protected  int[] factorsPT
          Factors used to convert linear coordinates in multidimensional ones.
static int MINUS_OPERATOR
           
static int PLUS_OPERATOR
           
static int PRODUCT_OPERATOR
           
protected  List<Node> variableList
          RVs that are in the table, including the variable that owns the table.
 
Constructor Summary
PotentialTable()
          Initialize data and variables.
 
Method Summary
 void addValueAt(int index, float value)
           
 void addVariable(INode variavel)
          Inserts a variable into function.
 Object clone()
          Returns a copy of the data from the table.
 Object clone(ProbabilisticNode newNode)
          Returns a copy of the data from the table associated with the new node, instead of the original node.
 List<Node> cloneVariables()
          Returns a copy of the variables in this table.
protected  void computeFactors()
          Calculate the factors necessary to transform the linear coordinate into a multidimensional one, which is a list containing the state of each variable in the table.
protected  void computeFactorsMarginal()
          Calculate the factors necessary to transform the linear coordinate into a multidimensional one, which is a list containing the state of each variable in the table.
 void copyData()
          Creates a copy of the data from the table.
 void directOpTab(PotentialTable tab, int operator)
          Operates with the argument table directly.
protected  void finding(int control, int index, int[] coord, int state)
           
 int getLinearCoord(int[] multidimensionalCoord)
          Get the linear coordinate from the multidimensional one.
 int getLinearCoordMarginal(int[] multidimensionalCoord)
          Get the linear coordinate from the multidimensional one.
 int[] getMultidimensionalCoord(int linearCoord)
          Get the multidimensional coordinate from the linear one.
 int[] getMultidimensionalCoordMarginal(int linearCoord)
          Get the multidimensional coordinate from the linear one.
 float getValue(int index)
          Retorna o valor da cÔøΩlula com o respectivo ÔøΩndice.
 float getValue(int[] coordenadas)
          Retorna o valor na tabela a partir do vetor de coordenadas
 INode getVariableAt(int index)
          Obtains a variable (node) associated with this function
 int getVariableIndex(Node variable)
           
 int getVariablesSize()
           
 int indexOfVariable(Node node)
           
 int indexOfVariable(String nodeName)
           
 void moveVariableWithoutMoveData(int initialPosition, int destinationPosition)
          Move a variable of position.
abstract  PotentialTable newInstance()
          Returns a new instance of a PotentialTable of the current implemented sub-class.
 void notifyModification()
          This method has to be called when there is a change in any of the variables in this function.
 void opTab(PotentialTable tab, int operator)
          Opera tabela do parametro com esta.
 void removeValueAt(int index)
           
abstract  void removeVariable(INode variable)
          Remove the variable from this function.
abstract  void removeVariable(INode variable, boolean normalize)
          Remove the variable of the table.
 void restoreData()
          Restores the data from the table using its stored copy.
 void setTableSize(int size)
           
 void setValue(int[] coord, float value)
          Set a value in the table using the multidimensional coordinate, which is a list containing the state of each variable in the table.
 void setValue(int index, float value)
          Set a value in the table using the linear coordinate, which corresponds to the state of each variable in the table.
 void setVariableAt(int index, INode node)
          Inserts a variable into position
protected  void sum(int index)
           
 int tableSize()
           
 int variableCount()
          Obtains the number of associated variables.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRODUCT_OPERATOR

public static final int PRODUCT_OPERATOR
See Also:
Constant Field Values

DIVISION_OPERATOR

public static final int DIVISION_OPERATOR
See Also:
Constant Field Values

PLUS_OPERATOR

public static final int PLUS_OPERATOR
See Also:
Constant Field Values

MINUS_OPERATOR

public static final int MINUS_OPERATOR
See Also:
Constant Field Values

variableList

protected List<Node> variableList
RVs that are in the table, including the variable that owns the table.


dataPT

protected FloatCollection dataPT
The data from the table as a list of floats. The use of this data is done by using coordinates and linear coordinates.


dataCopy

protected FloatCollection dataCopy
Copy of the data from the data.


dataMarginal

protected FloatCollection dataMarginal
The data from the table as a list of floats. Usually used to compute the marginal probabilities "manually", i.e. by removing each and every parent from the potential table. The use of this data is done by using coordinates and linear coordinates for the marginal data.


factorsPT

protected int[] factorsPT
Factors used to convert linear coordinates in multidimensional ones. It stores the position that starts the table of each variable, for the potential table data.


factorsMarginal

protected int[] factorsMarginal
Factors used to convert linear coordinates in multidimensional ones. It stores the position that starts the table of each variable, for the marginal data.

Constructor Detail

PotentialTable

public PotentialTable()
Initialize data and variables.

Method Detail

copyData

public void copyData()
Creates a copy of the data from the table.


restoreData

public void restoreData()
Restores the data from the table using its stored copy.


notifyModification

public void notifyModification()
Description copied from interface: IProbabilityFunction
This method has to be called when there is a change in any of the variables in this function.

Specified by:
notifyModification in interface IProbabilityFunction

cloneVariables

public List<Node> cloneVariables()
Returns a copy of the variables in this table.

Returns:
A copy of the variables in this table.

indexOfVariable

public final int indexOfVariable(Node node)

indexOfVariable

public final int indexOfVariable(String nodeName)

variableCount

public int variableCount()
Description copied from interface: IProbabilityFunction
Obtains the number of associated variables.

Specified by:
variableCount in interface IProbabilityFunction
Returns:
the quantity of variables inserted into this probability function

setVariableAt

public void setVariableAt(int index,
                          INode node)
Description copied from interface: IProbabilityFunction
Inserts a variable into position

Specified by:
setVariableAt in interface IProbabilityFunction
Parameters:
index - : position to insert variable
node - : variable to be inserted

getVariableAt

public INode getVariableAt(int index)
Description copied from interface: IProbabilityFunction
Obtains a variable (node) associated with this function

Specified by:
getVariableAt in interface IProbabilityFunction
Returns:
a node/variable identified by index

getVariableIndex

public final int getVariableIndex(Node variable)

addValueAt

public void addValueAt(int index,
                       float value)

removeValueAt

public final void removeValueAt(int index)

tableSize

public int tableSize()

setTableSize

public void setTableSize(int size)

clone

public Object clone()
Returns a copy of the data from the table.

Overrides:
clone in class Object
Returns:
A copy of the data from the table.

clone

public Object clone(ProbabilisticNode newNode)
Returns a copy of the data from the table associated with the new node, instead of the original node. Useful when cloning a node. This method assumes that: 1. The size of the new node table is the same as this node table being copied. 2. If you want an exact copy, the parents in the new node have to be in the same order they were in this node being copied, i.e., the variableList order is the same.

Returns:
A copy of the data from the table associated with the new node.

setValue

public void setValue(int[] coord,
                     float value)
Set a value in the table using the multidimensional coordinate, which is a list containing the state of each variable in the table.

Parameters:
coord - The multidimensional coordinate, which is a list containing the state of each variable in the table.
value - The value to be set in the table.

setValue

public final void setValue(int index,
                           float value)
Set a value in the table using the linear coordinate, which corresponds to the state of each variable in the table.

Parameters:
index - The linear coordinate, which corresponds to the state of each variable in the table.
value - The value to be set in the table.

getValue

public final float getValue(int index)
Retorna o valor da cÔøΩlula com o respectivo ÔøΩndice.

Parameters:
index - ÔøΩndice linear do valor na tabela a ser retornado.
Returns:
valor na tabela correspondente ao indice linear especificado.

getValue

public final float getValue(int[] coordenadas)
Retorna o valor na tabela a partir do vetor de coordenadas

Parameters:
coordenadas - coordenadas do valor a ser pego.
Returns:
valor na tabela especificada pelas coordenadas.

addVariable

public void addVariable(INode variavel)
Description copied from interface: IProbabilityFunction
Inserts a variable into function. This is usually called by the program when we insert an edge into a node. The first variable is usually the owner of the table

Specified by:
addVariable in interface IProbabilityFunction
Parameters:
variavel - : variable to be injected.

moveVariableWithoutMoveData

public void moveVariableWithoutMoveData(int initialPosition,
                                        int destinationPosition)
Move a variable of position. Only the variables are moved... the data of the table aren't changed. ATENTION: Use this method only if you need to fill the table manually and want choice the order of the variables. Use before to fill the data. Pre-requisites: - The table has size > initialPosition and size > destinationPosition

Parameters:
initialPosition -
destinationPosition -

getVariablesSize

public int getVariablesSize()

removeVariable

public abstract void removeVariable(INode variable,
                                    boolean normalize)
Remove the variable of the table. Note: Substitute the previous method removeVariable(Node variable)

Specified by:
removeVariable in interface IProbabilityFunction
Parameters:
variable - Variable to be removed
normalize - True if is to normalize the cpt after the node remotion

removeVariable

public abstract void removeVariable(INode variable)
Description copied from interface: IProbabilityFunction
Remove the variable from this function. You should implement general marginalization as well

Specified by:
removeVariable in interface IProbabilityFunction
Parameters:
variable - variable to be removed.

newInstance

public abstract PotentialTable newInstance()
Returns a new instance of a PotentialTable of the current implemented sub-class.

Returns:
a new instance of a PotentialTable of the current implemented sub-class.

sum

protected void sum(int index)

finding

protected void finding(int control,
                       int index,
                       int[] coord,
                       int state)

getLinearCoord

public final int getLinearCoord(int[] multidimensionalCoord)
Get the linear coordinate from the multidimensional one. LinearCoord = SumOf(StateOf[i] * FactorOf[i]), for all possible nodes (i), which are the nodes in the table.

Parameters:
multidimensionalCoord - Multidimensional coordinate (represented by the state for each node).
Returns:
The corresponding linear coordinate.

computeFactors

protected void computeFactors()
Calculate the factors necessary to transform the linear coordinate into a multidimensional one, which is a list containing the state of each variable in the table.


getMultidimensionalCoord

public final int[] getMultidimensionalCoord(int linearCoord)
Get the multidimensional coordinate from the linear one.

Parameters:
linearCoord - The linear coordinate.
Returns:
The corresponding multidimensional coordinate.

getLinearCoordMarginal

public final int getLinearCoordMarginal(int[] multidimensionalCoord)
Get the linear coordinate from the multidimensional one. LinearCoord = SumOf(StateOf[i] * FactorOf[i]), for all possible nodes (i), which are the nodes in the table.

Parameters:
multidimensionalCoord - Multidimensional coordinate (represented by the state for each node).
Returns:
The corresponding linear coordinate.

computeFactorsMarginal

protected void computeFactorsMarginal()
Calculate the factors necessary to transform the linear coordinate into a multidimensional one, which is a list containing the state of each variable in the table.


getMultidimensionalCoordMarginal

public final int[] getMultidimensionalCoordMarginal(int linearCoord)
Get the multidimensional coordinate from the linear one.

Parameters:
linearCoord - The linear coordinate.
Returns:
The corresponding multidimensional coordinate.

directOpTab

public final void directOpTab(PotentialTable tab,
                              int operator)
Operates with the argument table directly.

Parameters:
tab - table to operate.
operator - operator to use, defined in this class constants.

opTab

public final void opTab(PotentialTable tab,
                        int operator)
Opera tabela do parametro com esta.

Parameters:
tab - tabela a ser operada com esta.
operator - operador a ser utilizado, definido pelas constantes desta classe.


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.