edu.stanford.multiagent.gamer
Class ParameterizedObject

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
Direct Known Subclasses:
Function, Game, Graph, VectorFunction

public abstract class ParameterizedObject
extends java.lang.Object

Abstract class that can be extended by any class which needs to use the parameter set-up.


Field Summary
protected  edu.stanford.multiagent.gamer.Parameters parameters
           
 
Constructor Summary
protected ParameterizedObject()
          The consctructor.
 
Method Summary
protected abstract  void checkParameters()
          Checks if Parameter values are consistent.
abstract  void doGenerate()
          Generate a (random) instance of the subclass based on input parameters.
 boolean getBooleanParameter(java.lang.String name)
          Returns the value of the parameter with the given name as a boolean (assuming the parameter is of type boolean).
 java.lang.String getDescription()
          Returns description of the class.
 double getDoubleParameter(java.lang.String name)
          Returns the value of the parameter with the given name as a double (assuming the parameter is of type double).
abstract  java.lang.String getHelp()
          Return the help screen
 long getLongParameter(java.lang.String name)
          Returns the value of the parameter with the given name as a long (assuming the parameter is of type long).
 java.lang.String getParamDescription(java.lang.String sep)
          Constructs a string with all parameter values.
 java.lang.Object getParameter(java.lang.String name)
          Returns the value of the parameter with the given name as an Object.
 edu.stanford.multiagent.gamer.Parameters getParameters()
          Returns the Parameters object of the class.
 java.lang.String getStringParameter(java.lang.String name)
          Returns the value of the parameter with the given name as a String (assuming the parameter is of type String).
 void initialize()
          Initializes using preset parameter values.
 void randomizeParameters()
          Sets values of any unset parameters randomly.
 void setParameter(java.lang.String name, java.lang.Object val)
          Sets the value of a parameter.
 void setParameter(java.lang.String name, java.lang.Object val, boolean byUser)
          Sets the value of a parameter.
 void setParameters(edu.stanford.multiagent.gamer.Parameters p, boolean randomize)
          Sets multiple parameters at once using a Parameters variable.
 void setParameters(edu.stanford.multiagent.gamer.ParamParser p, boolean randomize)
          Sets multiple parameters at once using a ParamParser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

protected edu.stanford.multiagent.gamer.Parameters parameters
Constructor Detail

ParameterizedObject

protected ParameterizedObject()
                       throws java.lang.Exception
The consctructor. Must be called by all subclasses It sets all parameter names/types and parses the parameter values passed to it

Method Detail

getParameters

public edu.stanford.multiagent.gamer.Parameters getParameters()
Returns the Parameters object of the class.


getParameter

public java.lang.Object getParameter(java.lang.String name)
Returns the value of the parameter with the given name as an Object.

Parameters:
name - parameter to return

getLongParameter

public long getLongParameter(java.lang.String name)
Returns the value of the parameter with the given name as a long (assuming the parameter is of type long).

Parameters:
name - parameter to return

getBooleanParameter

public boolean getBooleanParameter(java.lang.String name)
Returns the value of the parameter with the given name as a boolean (assuming the parameter is of type boolean).

Parameters:
name - parameter to return

getDoubleParameter

public double getDoubleParameter(java.lang.String name)
Returns the value of the parameter with the given name as a double (assuming the parameter is of type double).

Parameters:
name - parameter to return

getStringParameter

public java.lang.String getStringParameter(java.lang.String name)
Returns the value of the parameter with the given name as a String (assuming the parameter is of type String).

Parameters:
name - parameter to return

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object val)
                  throws java.lang.Exception
Sets the value of a parameter.

Parameters:
name - parameter to set the value of
val - value to set
Throws:
java.lang.Exception

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object val,
                         boolean byUser)
                  throws java.lang.Exception
Sets the value of a parameter.

Parameters:
name - parameter to set the value of
val - value to set
byUser - should be true if the parameter was set by the user on the command line
Throws:
java.lang.Exception

setParameters

public void setParameters(edu.stanford.multiagent.gamer.ParamParser p,
                          boolean randomize)
                   throws java.lang.Exception
Sets multiple parameters at once using a ParamParser.

Parameters:
p - the ParamParser containing the parameters and their values
randomize - should be set to true if it is desired that any unset parameters be randomized
Throws:
java.lang.Exception

setParameters

public void setParameters(edu.stanford.multiagent.gamer.Parameters p,
                          boolean randomize)
                   throws java.lang.Exception
Sets multiple parameters at once using a Parameters variable.

Parameters:
p - the Parameters variable containing the parameters and their values
randomize - should be set to true if it is desired that any unset parameters be randomized
Throws:
java.lang.Exception

initialize

public void initialize()
                throws java.lang.Exception
Initializes using preset parameter values.

Throws:
java.lang.Exception

randomizeParameters

public void randomizeParameters()
Sets values of any unset parameters randomly. Can and should be overridden in subclasses to handle a non-uniform distribution and for constraints on parameters.


getParamDescription

public java.lang.String getParamDescription(java.lang.String sep)
Constructs a string with all parameter values.

Parameters:
sep - seperator to be placed between parameter values

getDescription

public java.lang.String getDescription()
Returns description of the class. Subclasses should override.


checkParameters

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

Throws:
java.lang.Exception - if anything is wrong with the parameter values

doGenerate

public abstract void doGenerate()
Generate a (random) instance of the subclass based on input parameters.


getHelp

public abstract java.lang.String getHelp()
Return the help screen