edu.stanford.multiagent.gamer.functions
Class PolyFunction

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
        |
        +--edu.stanford.multiagent.gamer.functions.Function
              |
              +--edu.stanford.multiagent.gamer.functions.PolyFunction
Direct Known Subclasses:
IncreasingPoly

public class PolyFunction
extends Function

Class implements a polynomial function of a single argument


Field Summary
protected  double[] coefs
           
protected static double EPSILON
           
protected static int MAX_ITER
           
protected static int N_RESTARTS
           
protected static Parameters.ParamInfo[] pfParam
           
 
Fields inherited from class edu.stanford.multiagent.gamer.functions.Function
dMax, dMin
 
Fields inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
parameters
 
Constructor Summary
PolyFunction()
           
PolyFunction(double[] coefs, double dMin, double dMax)
           
 
Method Summary
protected  void checkParameters()
          Checks if Parameter values are consistent.
 void doGenerate()
          The only thing involved in generating the polynomial is storing the coefficients in a more easily accessable variable.
 double eval(double x)
          Evaluate the polynomial
 edu.stanford.multiagent.gamer.functions.PolyFunction getDerivative()
          Returns a derivative polynomial.
protected  java.lang.String getFunctionHelp()
          Returns a help string describing the function and the parameters taken by the function
 void getMinima(double a, double b, edu.stanford.multiagent.gamer.functions.PolyFunction deriv, java.util.Vector v)
          Appends all local minima in the specified interval to v.
 double getMinimum()
          Finds the minimum value of the function.
 double getMinimum(double a, double b, edu.stanford.multiagent.gamer.functions.PolyFunction deriv)
          Does gradient descent to get a local minimum in an interval a,b.
 void initialize()
          Calls initialize in the super class ParemeterizedObject which checks parameters
 edu.stanford.multiagent.gamer.functions.PolyFunction integrate()
          Integrates a polynomial and adds random constant term.
static void main(java.lang.String[] args)
          Used only for testing.
 void randomizeParameters()
          Randomize things
 
Methods inherited from class edu.stanford.multiagent.gamer.functions.Function
getDMax, getDMin, getHelp, setDomain
 
Methods inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
getBooleanParameter, getDescription, getDoubleParameter, getLongParameter, getParamDescription, getParameter, getParameters, getStringParameter, setParameter, setParameter, setParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPSILON

protected static final double EPSILON
See Also:
Constant Field Values

MAX_ITER

protected static final int MAX_ITER
See Also:
Constant Field Values

N_RESTARTS

protected static final int N_RESTARTS
See Also:
Constant Field Values

pfParam

protected static Parameters.ParamInfo[] pfParam

coefs

protected double[] coefs
Constructor Detail

PolyFunction

public PolyFunction()
             throws java.lang.Exception

PolyFunction

public PolyFunction(double[] coefs,
                    double dMin,
                    double dMax)
             throws java.lang.Exception
Method Detail

getFunctionHelp

protected java.lang.String getFunctionHelp()
Description copied from class: Function
Returns a help string describing the function and the parameters taken by the function

Specified by:
getFunctionHelp in class Function

initialize

public void initialize()
                throws java.lang.Exception
Description copied from class: Function
Calls initialize in the super class ParemeterizedObject which checks parameters

Overrides:
initialize in class Function
Throws:
java.lang.Exception - if there is a problem with the parameters

checkParameters

protected void checkParameters()
                        throws java.lang.Exception
Description copied from class: ParameterizedObject
Checks if Parameter values are consistent. Must be implemented by every non-abstract subclass of ParameterizedObject.

Specified by:
checkParameters in class ParameterizedObject
Throws:
java.lang.Exception - if anything is wrong with the parameter values

doGenerate

public void doGenerate()
The only thing involved in generating the polynomial is storing the coefficients in a more easily accessable variable.

Specified by:
doGenerate in class ParameterizedObject

eval

public double eval(double x)
Evaluate the polynomial

Specified by:
eval in class Function
Parameters:
x - the point at which to evaluate the function

randomizeParameters

public void randomizeParameters()
Randomize things

Overrides:
randomizeParameters in class ParameterizedObject

getMinimum

public double getMinimum()
Finds the minimum value of the function. Note that this is probably not the best way to go about it. Ideally, should be changed to a better algorithm later.


getMinima

public void getMinima(double a,
                      double b,
                      edu.stanford.multiagent.gamer.functions.PolyFunction deriv,
                      java.util.Vector v)
Appends all local minima in the specified interval to v.


getMinimum

public double getMinimum(double a,
                         double b,
                         edu.stanford.multiagent.gamer.functions.PolyFunction deriv)
Does gradient descent to get a local minimum in an interval a,b.


getDerivative

public edu.stanford.multiagent.gamer.functions.PolyFunction getDerivative()
                                                                   throws java.lang.Exception
Returns a derivative polynomial.

java.lang.Exception

integrate

public edu.stanford.multiagent.gamer.functions.PolyFunction integrate()
                                                               throws java.lang.Exception
Integrates a polynomial and adds random constant term.

java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Used only for testing.

java.lang.Exception