parameters
Class ParameterSet

java.lang.Object
  extended byparameters.ParameterSet

public class ParameterSet
extends java.lang.Object

ParameterSet.java This class stores a set of Parameter objects, along with variables that might be associated with such a set. The associated variables, called value fields, often include a score, a number of function calls, a group number and tag for sets from an output file. They can also include other variables as output from an iterator, each with its own unique tag. See the ParameterSetArray and the Iterator classes for more information on including additional variables (called Value Fields).

You can use this class in two ways, with or without a prototype class. If you pass a prototype ParameterSet to the constructor, then only parameters which are in that prototype set will be added to this set. Others are ignored. Without a prototype set, any parameter sent to this set will be added (provided it exists in the model - see Parameter class). If a prototype is used, this class will look up the names for additional variables in that prototype class and will only store the values locally. Otherwise, this parameter set will ignore additional variables unless its load() or addOutputTag() functions are explicitly called.

See Also:
Parameter

Field Summary
 int numParams
          Note that not all params below numParams neccesarily exist.
 Parameter[] params
          Get the position of a parameter in this array using the getPosition function
protected  java.lang.String tag
           
 
Constructor Summary
ParameterSet()
           
ParameterSet(ParameterSet prototype)
           
ParameterSet(ParameterSet prototype, int group_num, java.lang.String tag)
           
ParameterSet(java.lang.String str)
          If you call a constructor with a prototype set, the only parameters that can be added to this set are those that are in the prototype.
 
Method Summary
 void addParameter(Parameter par)
          If there is a prototype, this function tries to find the new parameter's name in the prototype.
 void addParameter(java.lang.String name, float value, float min, float max, int type)
          If any of the passed in values are < 0, then the defaults are used (which come from the currently loaded model, via the Parameter constructor.
 void addValueField(java.lang.String name, java.lang.String type)
           
 boolean areParametersGood(float[] params, int mode)
           
 void arrangeParametersByModel()
          Rearranges the parameters in this set so that the position in set corresponds to the position of the parameter in Affector.
 ParameterSet copy()
           
 void copyValueFieldNames(ParameterSet ps)
           
 boolean didPass()
           
 void draw(java.awt.Graphics g, int xcen, int ycen, int rad, double[] cosThetas, double[] sinThetas)
          ParameterSet objects can draw themselves as cam's using this draw command.
 java.lang.String getFieldName(int pos)
           
 int getFieldPos(java.lang.String name)
           
 float getFieldValue(int pos)
           
 float getFieldValue(java.lang.String name)
           
 float getFuzzyParametersScore(float[] params)
           
 int getGroupNum()
           
 float getLowerBound(int i)
           
 float[] getLowerBounds()
           
 void getModel()
           
 java.lang.String getName(int pos)
           
 int getNumFuncCalls()
           
 int getNumParams()
           
 int getNumValueFields()
           
 Parameter getParameter(int i)
           
 float[] getParVals()
          This is for setting an Iterator's internal parameter vector p
 int getPosition(java.lang.String name)
          Gets the position of a parameter called "name" in this sets params array.
 ParameterSet getPrototype()
           
 float getScore()
           
 java.lang.String getTag()
           
 float getUpperBound(int i)
           
 float[] getUpperBounds()
           
 float getValue(int pos)
           
 int getVariationMode(int pos)
           
 void loadParameters(BetterTokenizer tokenizer)
          This function loads a parameter set from an output file, tagged with the FPARS tag.
 void loadParameterValues(BetterTokenizer tokenizer, boolean need_all)
          Loads a set of parameters from a stream.
 void loadValueFieldNames(BetterTokenizer tokenizer)
          Value Fields
 boolean makeNewPoint(int mode)
           
 boolean makeNewPoint(int mode, ParameterSet nochange)
           
 void removeParameter(java.lang.String name)
           
 void setArrangeByModel(boolean arrange)
          Set to true if parameters should be put into the same order in this parameter set as they are in the model.
 void setFieldValue(int pos, float value)
           
 void setFieldValue(java.lang.String name, float value)
           
 void setFrom(float[] vals)
          And this is for setting par values from the same vector.
 void setFrom(ParameterSet set)
          Sets parameters in this set from the set that's passed in, for all parameters that appear in both
 void setGroupNum(int num)
           
 void setLowerBound(int pos, float val)
           
 void setModel()
          Sets the currently loaded model according to the parameters in this parameter set.
 void setNumFuncCalls(int num)
           
 void setParameter(Parameter par, int pos)
           
 void setPass(boolean pass)
           
 void setScore(float score)
           
 void setTag(java.lang.String tag)
           
 void setUpperBound(int pos, float val)
           
 void setValue(int pos, float val)
           
 void setVariationMode(int pos, int mode)
           
 java.lang.String toString()
           
 void toString(java.io.PrintWriter ps, java.lang.String indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

params

public Parameter[] params
Get the position of a parameter in this array using the getPosition function


numParams

public int numParams
Note that not all params below numParams neccesarily exist. You have to check whether params[i] == null


tag

protected java.lang.String tag
Constructor Detail

ParameterSet

public ParameterSet()

ParameterSet

public ParameterSet(java.lang.String str)
If you call a constructor with a prototype set, the only parameters that can be added to this set are those that are in the prototype.


ParameterSet

public ParameterSet(ParameterSet prototype)

ParameterSet

public ParameterSet(ParameterSet prototype,
                    int group_num,
                    java.lang.String tag)
Method Detail

copy

public ParameterSet copy()

addParameter

public void addParameter(java.lang.String name,
                         float value,
                         float min,
                         float max,
                         int type)
                  throws java.lang.Exception
If any of the passed in values are < 0, then the defaults are used (which come from the currently loaded model, via the Parameter constructor. This version makes a Parameter object and passes it to the other AddParameter.

Throws:
java.lang.Exception

addParameter

public void addParameter(Parameter par)
If there is a prototype, this function tries to find the new parameter's name in the prototype. If it can't, then the new parameter is not added. If there is no prototype, checks whether there is already a parameter with this name in this set, and if so replaces it. Otherwise, the new parameter just gets added onto the end of the params array.


removeParameter

public void removeParameter(java.lang.String name)

getPosition

public int getPosition(java.lang.String name)
                throws java.lang.Exception
Gets the position of a parameter called "name" in this sets params array. If its not there, throws an exception

Throws:
java.lang.Exception

setFrom

public void setFrom(ParameterSet set)
Sets parameters in this set from the set that's passed in, for all parameters that appear in both


getParVals

public float[] getParVals()
This is for setting an Iterator's internal parameter vector p


setFrom

public void setFrom(float[] vals)
And this is for setting par values from the same vector. Note that these methods assume a fixed order and # of pars


areParametersGood

public boolean areParametersGood(float[] params,
                                 int mode)

getFuzzyParametersScore

public float getFuzzyParametersScore(float[] params)

getPrototype

public ParameterSet getPrototype()

getScore

public float getScore()

setScore

public void setScore(float score)

getGroupNum

public int getGroupNum()

setGroupNum

public void setGroupNum(int num)

getTag

public java.lang.String getTag()

setTag

public void setTag(java.lang.String tag)

getNumFuncCalls

public int getNumFuncCalls()

setNumFuncCalls

public void setNumFuncCalls(int num)

getVariationMode

public int getVariationMode(int pos)

setVariationMode

public void setVariationMode(int pos,
                             int mode)

didPass

public boolean didPass()

setPass

public void setPass(boolean pass)

getParameter

public Parameter getParameter(int i)

setParameter

public void setParameter(Parameter par,
                         int pos)

getName

public java.lang.String getName(int pos)

getValue

public float getValue(int pos)

setValue

public void setValue(int pos,
                     float val)

getUpperBound

public float getUpperBound(int i)

setUpperBound

public void setUpperBound(int pos,
                          float val)

getLowerBound

public float getLowerBound(int i)

setLowerBound

public void setLowerBound(int pos,
                          float val)

getUpperBounds

public float[] getUpperBounds()

getLowerBounds

public float[] getLowerBounds()

getNumParams

public int getNumParams()

getModel

public void getModel()

setModel

public void setModel()
Sets the currently loaded model according to the parameters in this parameter set. Any parameters not in this set are left alone.


makeNewPoint

public boolean makeNewPoint(int mode,
                            ParameterSet nochange)

makeNewPoint

public boolean makeNewPoint(int mode)

loadParameters

public void loadParameters(BetterTokenizer tokenizer)
                    throws java.lang.Exception
This function loads a parameter set from an output file, tagged with the FPARS tag. It will load not only the parameters, but also any associated score and numFunctionCalls. This function calls loadParameterValues with need_all = false to load the actual values.

To load from an input file, call loadParameterValues directly (with need_all = true for model files).

Throws:
java.lang.Exception

loadParameterValues

public void loadParameterValues(BetterTokenizer tokenizer,
                                boolean need_all)
                         throws java.lang.Exception
Loads a set of parameters from a stream. Will stop at either an endParamsToVary or an endFPARS tag. Any other tags it assumes are names of a parameter and it will try to load that parameter and then add it to this set using the addParameter function. If it encounters a ParameterRules tag it will make a ParameterRuleSet and call that objects load method.

Parameters:
need_all - Gets passed into the Parameter objects loadParameters function.
Throws:
java.lang.Exception

arrangeParametersByModel

public void arrangeParametersByModel()
Rearranges the parameters in this set so that the position in set corresponds to the position of the parameter in Affector. If any parameters are missing, those positions will be set to null. If there are extra parameters (not in Affector) they will be put at the end of set, after the last Affector parameter.


setArrangeByModel

public void setArrangeByModel(boolean arrange)
Set to true if parameters should be put into the same order in this parameter set as they are in the model. Note that this will only happen automatically when loading parameters from a file. If parameters are added using addParameter, you must call arrangeParametersByModel to arrange them.


loadValueFieldNames

public void loadValueFieldNames(BetterTokenizer tokenizer)
                         throws java.lang.Exception
Value Fields

Throws:
java.lang.Exception

copyValueFieldNames

public void copyValueFieldNames(ParameterSet ps)

addValueField

public void addValueField(java.lang.String name,
                          java.lang.String type)

getNumValueFields

public int getNumValueFields()

getFieldValue

public float getFieldValue(int pos)

getFieldValue

public float getFieldValue(java.lang.String name)

setFieldValue

public void setFieldValue(int pos,
                          float value)

setFieldValue

public void setFieldValue(java.lang.String name,
                          float value)

getFieldName

public java.lang.String getFieldName(int pos)

getFieldPos

public int getFieldPos(java.lang.String name)

draw

public void draw(java.awt.Graphics g,
                 int xcen,
                 int ycen,
                 int rad,
                 double[] cosThetas,
                 double[] sinThetas)
ParameterSet objects can draw themselves as cam's using this draw command. I should add in stuff to change what color they use, etc.. ¶m xcen The center x position of the cam ¶m ycen The center y position of the cam ¶m rad The length of each cam arm. ¶m cosThetas The cosine of the angle to draw each parameter at. ¶m sinThetas The sine of the angle to draw each parameter at.


toString

public java.lang.String toString()

toString

public void toString(java.io.PrintWriter ps,
                     java.lang.String indent)