All Packages Class Hierarchy This Package Previous Next Index
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.
public static final String symbol
public abstract String BNF(int lang)
public abstract Object parse(Parser p,
int lang) throws ParserException
public abstract void unparse(Unparser u,
int lang)
public abstract Object[][] getParameters(int lang)
The array is of type Object[][], and should be of the form:
{{String}, //a short comment, period, then longer comment for BNF documentation for this Class
{String, var, String, //the name of a parameter in the BNF, and the Pointer to hold the parsed value
String, var, String, //another parameter
String, var, String}, //another parameter, etc. (zero or more pairs in all)
{var, //a Pointer holding a value to parse and unparse only during "save-all" experiment saves
var, //another such parameter
var}} //another such parameter (zero or more in all)
In the above description, a Pointer such as a PInt means that an integer expression will
be parsed and placed into the existing PInt. The PInt itself should already exist before
returning this array. At any point in the array where a Pointer is legal, it is also legal
to put a single-element Parsable[] array. So, if Foo implements Parsable,
then it is legal to put a variable there that contains a Foo[1] array. So, for example:
IntExp numCopies=new IntExp(0);
PictureDrawer[] pic={null};
Object[][] parameters=
{{"Draw N copies of a picture. The PictureDrawer must be given."},
{"N", numCopies,"the number of copies",
"picture",pic, "the picture"},
{}};
This works if IntExp is a Pointer and PictureDrawer is a Parsable. After parsing,
the number of copies will be an integer stored in numCopies.val and the PictureDrawer
will be stored in pic[0].
The kind of parsing that is done depends on how the variable is defined.
Assuming that MyClass extends Pointer, and MyType implements Parsable,
the four types of parameters can be declared this way:
MyClass a=new MyClass(); //will parse the parameters for Parsable class MyClass
MyType[] b={null}; //will parse the name of a class of type MyType, then its parameters
Parsable[][] c={new MyType[0]}; //will parse a list of objects of type MyParsable, parsing the class name and parameters for each one. Answer is in c[0][0], c[0][1], c[0][2], ...
Parsable[][] d={new MyClass[0],null}; //will parse a list of objects of class MyClass, parsing the parameters for each one. Answer is in d[0][0], d[0][1], d[0][2], ...
MyClass e=new MyClass(); //a variable that is saved but not parsed
MyClass f=new MyClass(); //a variable that is saved but not parsed
Object[][] parameters=
{{"A short description. The longer description of this class comes after the period"},
{"par1", a, "comment on this parameter",
"par2", b, "another comment",
"par3", c, "comment",
"par4", d, "comment"},
{e,f}} //list of all the variables to save, with no strings
The parameters array contains 3 subarrays. Optionally, a fourth array can be added.
If this array is {"{","}"} then it has no effect, and the parameters for this
object will still be in curly brackets. If the fourth array is {"[","]"} or
{"<",">"} or {"(",")"} or any other pair of single-character strings other
than letters and digits and "#", then the parameters will have to be enclosed
within those characters rather than within curly brackets. If the empty strings
{"",""} are used, then no characters surround the parameters at all. It is
HIGHLY encouraged that his feature NEVER be used except when ABSOLUTELY necessary!
public abstract void initialize(int level)
-1 new object: initialize everything, allocate new arrays
(this is only called once, after a saved experiment has been loaded back in)
0 new object: initialize everything, allocate new arrays
(this is only called once, after reading in an experiment description that
wasn't created by saving an experiment. Either 0 or -1, but not both,
are called for any given execution of the program.)
1 new experiment: initialize everything, don't reallocate arrays,
set the random number seed to some standard value
2 new run initialize weights, but don't reset the seed,
don't forget results of previous runs
3 new trial initialize state, but don't reset the seed or
weights or previous results
All Packages Class Hierarchy This Package Previous Next Index