org.knowceans.topics.cgen
Class MixNet

java.lang.Object
  extended by org.knowceans.topics.cgen.MixNet

public class MixNet
extends java.lang.Object

represents a mixture network, a bipartite BN with variable nodes turned into edges and parameters and priors turned into nodes.

Author:
gregor

Nested Class Summary
 class MixNet.Traversal
          traverses the mixnet, calling delegates for each element type
 
Field Summary
(package private)  java.util.Map<java.lang.String,java.lang.String> constants
           
(package private)  java.util.List<MixEdge> edges
           
(package private)  java.util.List<MixNode> nodes
           
(package private)  java.util.List<MixSequence> sequences
           
static boolean verbose
           
 
Constructor Summary
MixNet(java.lang.String name)
           
 
Method Summary
 void addItem(MixItem item)
          add a node or edge
 boolean compile(java.io.PrintStream out)
          compile the node indicators
 void coupleNodes(java.lang.String nodes)
          couples the parameters of the nodes together in a C5 structure.
 java.lang.String getDescription()
           
 MixEdge getEdge(java.lang.String query)
          get edge by name or variable name
 java.util.List<MixEdge> getHiddenEdges()
           
 java.util.List<MixNode> getHiddenNodes()
           
 java.lang.String getName()
           
 MixNode getNode(java.lang.String query)
          get node by name or parameter name
 MixEdge getParentEdge(MixNode n, java.lang.String ename)
          get the parent edge for this ename (variable) or null
 java.util.List<MixEdge> getTypedEdges(int type)
          get the edges matching ANY of the type's bits
 java.util.List<MixNode> getTypedNodes(int type)
          get the nodes matching ANY of the bits in the type mask
 void linkItems(MixNode parent, MixEdge edge, MixNode child)
          Add the node to
 void linkItems(java.lang.String parent, java.lang.String child)
          Link two mixnet items, assuming they are already added.
 void linkItems(java.lang.String parent, java.lang.String edge, java.lang.String child)
          Add the node to
 java.util.List<java.lang.String> listInternalVars()
           
 java.lang.String printSpecification()
          print the specification of this network, as it may be parsed by MixNetParser.
 void setDescription(java.lang.String description)
           
 java.lang.String toString()
           
 java.util.List<MixItem> traverse()
           
 java.util.List<MixItem> traverseForest(java.util.List<? extends MixItem> roots)
          traverse mixture network = non-recursive forest depth-first search
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

verbose

public static boolean verbose

nodes

java.util.List<MixNode> nodes

edges

java.util.List<MixEdge> edges

sequences

java.util.List<MixSequence> sequences

constants

java.util.Map<java.lang.String,java.lang.String> constants
Constructor Detail

MixNet

public MixNet(java.lang.String name)
Method Detail

getTypedEdges

public java.util.List<MixEdge> getTypedEdges(int type)
get the edges matching ANY of the type's bits

Parameters:
type -
Returns:

getTypedNodes

public java.util.List<MixNode> getTypedNodes(int type)
get the nodes matching ANY of the bits in the type mask

Parameters:
type -
Returns:

getHiddenEdges

public java.util.List<MixEdge> getHiddenEdges()

getHiddenNodes

public java.util.List<MixNode> getHiddenNodes()

addItem

public void addItem(MixItem item)
add a node or edge

Parameters:
item -

linkItems

public void linkItems(java.lang.String parent,
                      java.lang.String child)
Link two mixnet items, assuming they are already added.

Parameters:
parent -
child -

linkItems

public void linkItems(MixNode parent,
                      MixEdge edge,
                      MixNode child)
Add the node to

Parameters:
parent - (null for root)
edge - variable (added repeatedly for coupled or merged edges in E3 and C3 structures)
child - (null for visible)

linkItems

public void linkItems(java.lang.String parent,
                      java.lang.String edge,
                      java.lang.String child)
Add the node to

Parameters:
parent - (null for root)
edge - variable (added repeatedly for coupled or merged edges in E3 and C3 structures)
child - (null for visible)

coupleNodes

public void coupleNodes(java.lang.String nodes)
couples the parameters of the nodes together in a C5 structure. Hyperparameters of the first node are used;

Parameters:
nodes - comma-separated list of node parameter names

getNode

public MixNode getNode(java.lang.String query)
get node by name or parameter name

Parameters:
query -
Returns:

getEdge

public MixEdge getEdge(java.lang.String query)
get edge by name or variable name

Parameters:
query -
Returns:

getParentEdge

public MixEdge getParentEdge(MixNode n,
                             java.lang.String ename)
get the parent edge for this ename (variable) or null

Parameters:
n -
ename -
Returns:

toString

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

printSpecification

public java.lang.String printSpecification()
print the specification of this network, as it may be parsed by MixNetParser.

TODO: add preferences.

Returns:

listInternalVars

public java.util.List<java.lang.String> listInternalVars()

traverse

public java.util.List<MixItem> traverse()

traverseForest

public java.util.List<MixItem> traverseForest(java.util.List<? extends MixItem> roots)
traverse mixture network = non-recursive forest depth-first search

Returns:

compile

public boolean compile(java.io.PrintStream out)
compile the node indicators

Returns:
true if the model is consistent

getName

public java.lang.String getName()

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String description)