All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sim.funApp.FunApp

java.lang.Object
   |
   +----sim.funApp.FunApp

public abstract class FunApp
extends Object
implements Parsable, Watchable
All function approximators should inherit from FunApp. A function approximator should store its parameters in the array weights[]. The gradient functions are used for various gradient-descent algorithms. The store functions are used for various memory-based learning algorithms.

This code is (c) 1996 Leemon Baird <leemon@cs.cmu.edu>, http://www.cs.cmu.edu/~baird
The source and object code may be redistributed freely. If the code is modified, please state so in the comments.

Version:
1.01, 31 October 96
Author:
Leemon Baird

Variable Index

 o dEdIn
a vector for the gradient of error with respect to the inputs
 o dEdOut
a vector for the gradient of error with respect to the output
 o dEdWeights
a vector for the gradient of error with respect to the weights
 o inVect
clone of the input, should be a vector with first element 1.0
 o outVect
clone of the output, should be a vector
 o pInput
 o pOutput
 o pWeights
 o watchManager
the WatchManager that variables here may be registered with
 o weights
clone of a vector for the adjustable parameters of the function approximator
 o wmName
the prefix string for the name of every watched variable (passed in to setWatchManager)

Constructor Index

 o FunApp()

Method Index

 o BNF(int)
 o clone()
Make an exact duplicate of this class.
 o cloneVars(FunApp)
After making a copy of self during a clone(), call cloneVars() to copy variables into the copy, then return super.cloneVars(copy).
 o destroy()
This is called when the object is destroyed.
 o evaluate()
Calculate the output for the given input
 o findGradients()
Calculate the output and gradient for a given input.
 o findHessian()
Calculate the output, gradient, and Hessian for a given input.
 o getInput()
return the input vector (including one element that's always 1.0) that was set by setIO.
 o getName()
Return the variable "name" that was passed into setWatchManager.
 o getOutput()
return the output vector that was set by setIO
 o getParameters(int)
Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
 o getWatchManager()
Return the WatchManager set by setWatchManager().
 o getWeights()
return the weight vector that was set by setIO
 o initialize(int)
Initialize, either partially or completely.
 o learn(double[], double[])
store this new input/output pair as a data point for memory-based learning
 o nWeights(int, int)
Return # weights needed for nIn inputs (including the first one which is always 1.0), and nOut outputs.
 o parse(Parser, int)
Parse the input file to get the parameters for this object.
 o setIO(MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD, MatrixD)
Define the MatrixD objects that will be used by evaluate(), findGradients(), and findHessian().
 o setWatchManager(WatchManager, String)
Register all variables with this WatchManager.
 o unparse(Unparser, int)
Output a description of this object that can be parsed with parse().

Variables

 o inVect
 protected MatrixD inVect
clone of the input, should be a vector with first element 1.0

 o outVect
 protected MatrixD outVect
clone of the output, should be a vector

 o weights
 protected MatrixD weights
clone of a vector for the adjustable parameters of the function approximator

 o dEdOut
 protected MatrixD dEdOut
a vector for the gradient of error with respect to the output

 o dEdWeights
 protected MatrixD dEdWeights
a vector for the gradient of error with respect to the weights

 o dEdIn
 protected MatrixD dEdIn
a vector for the gradient of error with respect to the inputs

 o watchManager
 protected WatchManager watchManager
the WatchManager that variables here may be registered with

 o wmName
 protected String wmName
the prefix string for the name of every watched variable (passed in to setWatchManager)

 o pInput
 protected PMatrixD pInput
 o pOutput
 protected PMatrixD pOutput
 o pWeights
 protected PMatrixD pWeights

Constructors

 o FunApp
 public FunApp()

Methods

 o setWatchManager
 public void setWatchManager(WatchManager wm,
                             String name)
Register all variables with this WatchManager. Any function approximator overriding this should first call super.setWatchManager() for the important housekeeping done.

 o getName
 public String getName()
Return the variable "name" that was passed into setWatchManager. This name is the prefix of the names of all watchable variables within this object

 o getWatchManager
 public WatchManager getWatchManager()
Return the WatchManager set by setWatchManager().

 o setIO
 public void setIO(MatrixD inVect,
                   MatrixD outVect,
                   MatrixD weights,
                   MatrixD dEdIn,
                   MatrixD dEdOut,
                   MatrixD dEdWeights,
                   MatrixD dEdIndIn,
                   MatrixD dEdOutdOut,
                   MatrixD dEdWeightsdWeights) throws MatrixException
Define the MatrixD objects that will be used by evaluate(), findGradients(), and findHessian(). First 6 should be column vectors (n by 1 matrices). The last 3 parameters can be null if the Hessian is never to be calculated. If a function approximator overrides this, it should first call super.setIO() for important housekeeping.

Throws: MatrixException
if inputs are vectors with nonmatching sizes
 o getInput
 public final MatrixD getInput()
return the input vector (including one element that's always 1.0) that was set by setIO.

 o getOutput
 public final MatrixD getOutput()
return the output vector that was set by setIO

 o getWeights
 public final MatrixD getWeights()
return the weight vector that was set by setIO

 o learn
 public void learn(double in[],
                   double out[])
store this new input/output pair as a data point for memory-based learning

 o evaluate
 public abstract void evaluate()
Calculate the output for the given input

 o findGradients
 public abstract void findGradients()
Calculate the output and gradient for a given input. This does everything evaluate() does, plus it calculates the gradient of the error with respect to the inputs and weights, dEdx and dEdw, User must set dEdOut before calling.

 o findHessian
 public abstract void findHessian()
Calculate the output, gradient, and Hessian for a given input. This does everything evaluate() and findGradients() do, plus it calculates the Hessian of the error with resepect to the the weights and inputs, dEdxdx, dEdwdx, and dEdwdw. User User must set dEdOut and dEdOutdOut before calling.

 o nWeights
 public abstract int nWeights(int nIn,
                              int nOut)
Return # weights needed for nIn inputs (including the first one which is always 1.0), and nOut outputs.

 o getParameters
 public Object[][] getParameters(int lang)
Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.

See Also:
getParameters
 o BNF
 public abstract String BNF(int lang)
 o unparse
 public abstract void unparse(Unparser u,
                              int lang)
Output a description of this object that can be parsed with parse().

See Also:
Parsable
 o parse
 public abstract Object parse(Parser p,
                              int lang) throws ParserException
Parse the input file to get the parameters for this object.

Throws: ParserException
parser didn't find the required token
 o destroy
 public void destroy()
This is called when the object is destroyed. Override it to react to that event (e.g. kill threads, dispose of Graphics)

 o clone
 public abstract Object clone()
Make an exact duplicate of this class. For objects it contains, it only duplicates the pointers, not the objects they point to. For a new FunApp called MyFunApp, the code in this method should be the single line: return cloneVars(new MyFunApp());

Overrides:
clone in class Object
 o cloneVars
 public Object cloneVars(FunApp copy)
After making a copy of self during a clone(), call cloneVars() to copy variables into the copy, then return super.cloneVars(copy). The variables copied are just those set in parse() and setWatchManager(). The caller will be required to call setIO to set up the rest of the variables.

 o initialize
 public void initialize(int level)
Initialize, either partially or completely.

See Also:
initialize

All Packages  Class Hierarchy  This Package  Previous  Next  Index