blog
Class NumberVar

java.lang.Object
  extended by blog.BasicVar
      extended by blog.VarWithDistrib
          extended by blog.NumberVar
All Implemented Interfaces:
BayesNetVar, java.lang.Cloneable, java.lang.Comparable

public class NumberVar
extends VarWithDistrib

A number random variable. It consists of a potential object pattern (POP) and a tuple of generating objects. Its value in a given world is the number of objects generated by that POP and those generating objects.


Field Summary
 
Fields inherited from class blog.BasicVar
args
 
Constructor Summary
NumberVar(POP pop, java.util.List args)
          Creates a new NumberVar for the given POP and given tuple of generating objects.
NumberVar(POP pop, java.lang.Object[] args)
          Creates a new NumberVar for the given POP and given tuple of generating objects.
NumberVar(POP pop, java.lang.Object[] args, boolean stable)
          Creates a new NumberVar for the given POP and given tuple of generating objects.
 
Method Summary
 java.lang.Object clone()
           
 boolean equals(java.lang.Object obj)
          Two NumberVar objects are equal if they have the same POP and their argument lists are equal (recall that list equality is checked by calling the equals method on each corresponding pair of objects in the two lists).
 DependencyModel getDepModel()
          Returns the dependency model for this variable.
 DependencyModel.Distrib getDistrib(EvalContext context)
          Returns the CPD and argument values in the first satisfied clause of this variable's dependency statement in the given context.
 int getOrderingIndex()
          Returns an index to be used for comparing this variable to others.
 java.lang.Object getOriginFuncValue(OriginFunction g)
          Returns the value that the given origin function yields on all objects that satisfy this number variable.
 Type getType()
          Returns the integer type.
 int hashCode()
           
 int numGenerated(PartialWorld w)
          Returns the number of objects generated by this POP on this tuple of generating objects in the given world.
 POP pop()
          Returns the potential object pattern associated with this number variable.
 java.lang.String toString()
          Returns a string of the form #Type(f1 = o1, ..., fK = oK) where f1, ..., fK are the origin functions and o1, ..., oK are the generating objects.
 
Methods inherited from class blog.VarWithDistrib
ensureDetAndSupported, getFirstUninstParent, getParents
 
Methods inherited from class blog.BasicVar
args, compareTo, ensureStable, getCanonicalTerm, getCanonicalTerm, getValue, isDetermined, timestep
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberVar

public NumberVar(POP pop,
                 java.util.List args)
Creates a new NumberVar for the given POP and given tuple of generating objects.


NumberVar

public NumberVar(POP pop,
                 java.lang.Object[] args)
Creates a new NumberVar for the given POP and given tuple of generating objects.


NumberVar

public NumberVar(POP pop,
                 java.lang.Object[] args,
                 boolean stable)
Creates a new NumberVar for the given POP and given tuple of generating objects. If stable is true, then the caller guarantees that the given args array will not be modified externally.

Method Detail

pop

public final POP pop()
Returns the potential object pattern associated with this number variable.


getDistrib

public DependencyModel.Distrib getDistrib(EvalContext context)
Description copied from class: VarWithDistrib
Returns the CPD and argument values in the first satisfied clause of this variable's dependency statement in the given context. Returns null if the partial world in this context is not complete enough to determine the first satisfied clause and its CPD arguments.

Specified by:
getDistrib in class VarWithDistrib

getType

public Type getType()
Returns the integer type.

Specified by:
getType in class BasicVar

getOrderingIndex

public int getOrderingIndex()
Description copied from class: BasicVar
Returns an index to be used for comparing this variable to others. Variables for which this method returns the same index value will be compared based on their arguments.

Specified by:
getOrderingIndex in class BasicVar

getDepModel

public DependencyModel getDepModel()
Description copied from class: VarWithDistrib
Returns the dependency model for this variable.

Specified by:
getDepModel in class VarWithDistrib

getOriginFuncValue

public java.lang.Object getOriginFuncValue(OriginFunction g)
Returns the value that the given origin function yields on all objects that satisfy this number variable. This is either one of this variable's arguments or Model.NULL.

Throws:
java.lang.IllegalArgumentException - if the argument type of the given origin function is not the type of objects that satisfy this variable

numGenerated

public int numGenerated(PartialWorld w)
Returns the number of objects generated by this POP on this tuple of generating objects in the given world.


clone

public java.lang.Object clone()
Specified by:
clone in class BasicVar

equals

public boolean equals(java.lang.Object obj)
Two NumberVar objects are equal if they have the same POP and their argument lists are equal (recall that list equality is checked by calling the equals method on each corresponding pair of objects in the two lists).

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string of the form #Type(f1 = o1, ..., fK = oK) where f1, ..., fK are the origin functions and o1, ..., oK are the generating objects.

Overrides:
toString in class java.lang.Object