Grammar for WebSim
WebSim parses a string embedded in a Web page. This string uses
the grammar below to describe the program to run. This BNF listing
was automatically generated from the BNF() methods in each class. The
start symbol is WebSim. Terminals are red,
boldfaced characters. Nonterminals are words including dots, and
clicking on a nonterminal jumps to its definition. Some nonterminals
include angled brackets like <this> and some don't. The ones with
brackets always have a very
simple format, and can be extended just by writing a new WebSim object
and placing it in the appropriate directory. So the WebSim language
can be extended without changing any code in the parser, but simply by
placing a new compiled .class file in a directory.
Credits ::= { }
// print the credits..
DisplayList ::= { ( [ embed ] [ ( IntExp [ , ] IntExp [ , ]
IntExp [ , ] IntExp ) ] <Display> )* }
// List of displays. Gives the (x,y,width,height) for
// each display window.
FindBNF ::= { (( filename <string>) |
( classes <string>) |
( html <boolean>) |
( summary <boolean>) |
( width1 expression.IntExp) |
( width2 expression.IntExp) |
( width3 expression.IntExp) |
( width4 expression.IntExp))* }
// Create a file summarizing the grammar of WebSim.
// This calls the BNF() methodon every object, and
// creates either a text file, or a hyperlinked Web
// page..
// ===> filename: filename to create including
// directory path
// ===> classes: directory holding all the WebSim
// .CLASS files
// ===> html: output html rather than text? DEFAULT:
// true
// ===> summary: abbreviate the comments? DEFAULT:
// false
// ===> width1: # characters wide for first column.
// DEFAULT: 25
// ===> width2: # characters wide for second column.
// DEFAULT: 51
// ===> width3: # characters wide for third column.
// DEFAULT: 51
// ===> width4: # characters wide for middle column
// in the last section. DEFAULT: 22
ProjWin ::= [ embed ] [ ( IntExp [ , ] IntExp [ , ] IntExp
[ , ] ) IntExp] <Project>
// Window for a single Project. (x,y,width,height)
// for the Project's window (-1=default). 'embed'
// means embed in the Web page instead of making it a
// separate window
Random ::= { }
// A random number generator. The state can be saved
// with unparse() and then read in again with
// parse(), but these parameters shouldn't be
// modified by hand.
ShowEdit ::= { (( trigger <string>) |
( freq expression.IntExp) |
( all <string>) |
( vars { pointer.PString+ } ))* }
// Show variables. Shows either all variables with a
// given prefix, or just the named variables. The
// user can edit whatever is shown. If a trigger is
// given, the window will update itself every time
// the given variable changes the given number of
// times..
// ===> trigger: update all the values every freq
// times that this variable changes
// ===> freq: updates every freq times (-1=never)
// ===> all: if not null, will show/edit all variable
// names starting with this string
// ===> vars: list of variables to show and edit in
// the window
ShowThreads ::=
// Show all threads in a window.
TestMatrix ::=
// Test the Matrix object. Useful for debugging
// native-code implementations.
Title ::= { (( title <string>) |
( display <Display>))* }
// Title on a Display. Show the given Display with
// the given title at the top.
// ===> title: string to use as the title
// ===> display: the display to show below the title
WebSim ::= { (( showUnparse <boolean>) |
( autosave <boolean>) |
( autosaveTime expression.NumExp) |
( autosaveFilename <string>) |
( makeBackup <boolean>) |
( appendTime <boolean>) |
( projects { ProjWin+ } ))* }
// WebSim. Parses a string from the Web page or a
// separate file, creating all the projects that are
// to run. Can also automatically save all the
// projects to disk periodically..
// ===> showUnparse: after loading in everything,
// should it then be written to standard out?
// DEFAULT: false
// ===> autosave: should WebSim automatically save
// everything periodically? DEFAULT: false
// ===> autosaveTime: autosave every X minutes.
// DEFAULT: 30
// ===> autosaveFilename: filename to autosave to
// DEFAULT: 'c:\WebSimSave'
// ===> makeBackup: if autosave is about to overwrite
// a file, make a .BAK backup of it? DEFAULT: true
// ===> appendTime: add the time and '.html' to the
// end of the autosave filename? DEFAULT: true
// ===> projects: list of projects, each running in a
// separate thread.
expression.IntExp ::= NumVarExp
// A constant integer expression. The expression must
// not have a noninteger value or contain variables.
// Expressions like 3/floor(2.7) are integer
// expressions because floor() and ceil() always
// return integers, and division of two integers
// returns an integer.
expression.IntVarExp ::= NumVarExp
// An integer expression. The expression must not
// have a noninteger value. Expressions like
// 3/floor(2.7) are integer expressions because
// floor() and ceil() always return integers, and
// division of two integers returns an integer.
expression.NumExp ::= NumVarExp
// A constant numeric expression. The expression must
// not contain any variables. Division is as in C, so
// 5.0/2 is 2.5 but 5/2 is 2
expression.NumVarExp ::= NumVarTerm (( + | - ) NumVarTerm )*
// A numeric expression. Can contain variables and
// combinations of the operators +-*/% and 14
// predefined functions, So it might be
// 3.0/sin(1+'time') if 'time' is a watchable
// variable name. The functions sin(x), cos(x),
// tan(x), asin(x), acos(x), atan(x) are all in
// radians. The functions floor(x), ceil(x),
// mod(n,m), and n%m return ints. The functions
// sqrt(x), ln(x), log10(x), exp(x), and power(x,y)
// return doubles.
expression.NumVarFact ::= <integer> |
<double> |
- NumVarFact |
( ( NumVarExp ) ) |
( floor ( NumVarExp ) ) |
( ceil ( NumVarExp ) ) |
( mod ( NumVarExp ) ) |
( power ( NumVarExp ) ) |
( sqrt ( NumVarExp ) ) |
( ln ( NumVarExp ) ) |
( log10 ( NumVarExp ) ) |
( exp ( NumVarExp ) ) |
( sin ( NumVarExp ) ) |
( cos ( NumVarExp ) ) |
( tan ( NumVarExp ) ) |
( asin ( NumVarExp ) ) |
( acos ( NumVarExp ) ) |
( atan ( NumVarExp ) ))
// A factor used by NumVarExp.
expression.NumVarTerm ::= NumVarFact (( * | / ) NumVarTerm )*
// A product or ratio used by NumVarExp.
matrix.Matrix ::= ( ( [ [(NumExp [ , ])* NumExp] ] ) |
( [ ( [ [(NumExp [ , ])* NumExp] ] [ , ])*
( [ [(NumExp [ , ])* NumExp] ] ) ] ))
[ transpose ]
// A matrix or vector. Could be transposed. Can
// either be a list of vectors [[1 2][3 4]] or a
// single vector [5 6]. Commas are optional
// throughout.
picture.Animation ::= ( ( first NumExp) |
( last NumExp) |
( frames IntExp) )* <picture.PicPipe>
// The frames of an Animation. Each frame differs
// only in the time, and they are all laid out like
// the frames in a gallery.
picture.Antialias ::= jitter ( true |
false ) raysX IntExp raysY IntExp raysZ
IntExp raysT IntExp
// Antialias each pixel. Breaks the pixel into raysX
// * raysY * raysZ * raysT boxes, sends one ray
// through each box, and averages the results. if
// 'jitter' is true, then shoots each ray at a random
// spot within the box. Antialiasing in the T
// direction can be useful for animations (gives
// motion blurring). Antialiasing in the Z direction
// generally isn't useful.
picture.ColorMap ::= picture.ColorMapEntry +
// linearly-interpolated mapping from double to color.
picture.ColorMapEntry ::= [ NumExp [ , ] picture.ColorVector ]
// one line of a color map. In the linear map, the
// given number maps to the given color. values in
// between given colors map to linearly-interpolated
// colors.
picture.ColorVector ::= < NumExp [ , ] NumExp [ , ] NumExp [ [ , ]
NumExp [ , ] NumExp ] >
// A single color. Elements are red, green, blue,
// filter, transparency, each of which range from 0
// to 1.
picture.Description ::= <string>
// A string describing the picture being drawn.
picture.Edges ::= IntExp
// Trace figure edges. Each edge becomes a line
// IntExp pixels thick.
picture.Gallery ::= { picture.PicPipePipeline * }
// A list of pictures to tile.
picture.PicPipePipeline ::= { picture.PicPipe * }
// A Picture pipeline. The first Picture is the
// source for the second, which is the source for the
// third, etc. If you ask a Picture for a pixel's
// color, it either replies immediately, or asks it's
// source (1 or more times) and returns some function
// of the answer (or answers). Sources can
// take/return scalars (doubles) instead of colors.
// This allows a fractal object to be a scalar-valued
// function that is then fed in to another function
// that remaps the scalars (e.g. to do edge
// detection), which then feeds in to a third PicPipe
// that maps the resulting numbers to colors, which
// then feeds into a fourth PicPipe that does
// antialiasing by asking the third PicPipe for many
// colors then averaging them.
picture.Picture ::= { (( bar expression.IntExp) |
( pass1 picture.PicPipePipeline) |
( pass2 picture.PicPipePipeline) |
( bothPasses picture.PicPipePipeline))* }
// Draw a bitmapped, antialiased image..
// ===> bar: # pixels high for progress bar
// ===> pass1: filter for first pass (draws all
// pixels)
// ===> pass2: filter for 2nd pass (draws pixels much
// different from neighbors
// ===> bothPasses: defines color of each pixel
picture.Region ::= ( NumExp [ , ] NumExp ) [ , ] ( NumExp [ , ]
NumExp )
// A region to zoom into. Zoom into a region from
// (minX,minY) to (maxX,maxY)
picture.RndColor ::= [ picture.ColorVector ]
// Random colors. A picture with 3 regions, one
// random black/white, one random colors, one a solid
// color (default green).
picture.TimebombFractal ::=
// Timebomb fractal. This PicPipe takes no inputs,
// and outputs a timebomb fractal.
picture.ValueMap ::= picture.ValueMapEntry +
// Piecewise linear function. A piecewise linear
// mapping from doubles to doubles. Function is
// defined at a list of points, and linearly
// interpolated in between.
picture.ValueMapEntry ::= [ NumExp [ , ] NumExp ]
// One line of a value map.The first number maps to
// the second. Numbers not on the list are linearly
// interpolated.
picture.directFractal ::=
// fractal circles
.Fract1
picture.directFractal ::=
// a fractal maze (CS110 cover)
.Maze
pointer.PDouble ::= <double>
pointer.PInt ::= <integer>
pointer.PObject ::= { }
pointer.PString ::= <string>
// a string in single quotes
sim.ForExperiment ::= { (( initVal expression.NumExp) |
( finalVal expression.NumExp) |
( increment expression.NumExp) |
( variable <string>) |
( experiment <sim.Experiment>))* }
// Repeats an Experiment like a FOR loop. On each
// repetition, the watchable variable is set to
// values from 'initVal' to 'finalVal', incremented
// by 'increment' each time (defaults all 0). This
// can be used, for example, to rerun a neural net
// experiment multiple times with different learning
// rates each time. To also vary the momentum, there
// would be a ForExperiment inside another
// ForExperiment (note that a ForExperiment is itself
// an Experiment, and so can be nested)..
// ===> initVal: starting value for the index
// ===> finalVal: final value for the index (loops
// through initVal to finalVal, inclusive
// ===> increment: amount to increment index by on
// each iteration
// ===> variable: name of the index variable
// ===> experiment: experiment to run multiple times
sim.Simulator ::= { (( experiment <sim.Experiment>) |
( displays DisplayList))* }
// run a simulation. As the given experiment runs,
// the given displays show how the variables change.
// ===> experiment: runs the top-level, main loop of
// a simulation
// ===> displays: list of windows and embedded frames
sim.TDLambda ::= { (( mdp <sim.mdp.MDP>) |
( funApp <sim.funApp.FunApp>) |
( incremental <boolean>) |
( rate expression.NumExp) |
( smooth expression.NumExp) |
( tolerance expression.NumExp) |
( gamma expression.NumExp) |
( explore expression.NumExp) |
( expDecay expression.NumExp) |
( lambda expression.NumExp) |
( dt expression.NumExp) |
( seed expression.IntExp))* }
// TD(lambda). .
// ===> mdp: the process being controlled
// ===> funApp: the function approximator
// ===> incremental: true=incremental training,
// false=epoch-wise(default=true)
// ===> rate: learning rate (default=0.1)
// ===> smooth: 0=don't smooth out the error, 1=avg
// error over an infinite period (default=0.9)
// ===> tolerance: stop learning when smoothed error
// falls below this (default=1)
// ===> gamma: discount factor, 1=no discounting
// (default=0.9)
// ===> explore: percentage of time that the agent
// performs an action other than the action thought
// optimal. (default=0.3)
// ===> expDecay: decay rate of the exploration rate.
// On each step, the learning rate is multiplied by
// expDecay. If expDecay=0.9 then explore has a
// half-life of 6.57 iterations (expDecay=0.99 =>
// explore half-life of 65.7 iterations).
// (default=0.99)
// ===> lambda: (default=0.5)
// ===> dt: (default=1)
// ===> seed: seed for the random number generator
// (default=0)
sim.data.Dot ::=
// Always generates the vector (.3,.6).
sim.data.OnesRnd ::= { numOutputs IntExp }
// Random vector of ones and random numbers. The
// output vector has the given number of elements,
// the first K of which are 1.0, and the rest are
// random in the range [0,1]. K is random in the
// range [0,N], where N is the number of elements in
// the output vector.
sim.data.RemoteTable ::= { download <boolean> location <string>
filename <string> inputs (IntExp [ , ])+
outputs (IntExp [ , ])+ ( ( savefile <boolean>)
| ( cacheFilename <string>) | ( username
<string>) |
( password <string>) |
( normalize IntExp IntExp) |
( nullAttribute IntExp) |
( unparseTable <boolean>) )* }
// downloads a remote table of records and converts
// to input/output vectors for training. 'download'
// specifies whether to actually download the file.
// This is included because it is possible to
// download once and then use in multiple times by
// not deleting from the local drive. 'location' is
// the ftp site from which to download the file.
// 'filename' includes the path on the remote host.
// 'inputs' is a list of integers that represent the
// attribute fields in the record that are to be used
// as the inputs to the function approximator (Ex.
// 1,3,7: Data from columns 1, 3 and 7 of the table
// are to be used as inputs. 'outputs' - works the
// same as inputs. 'savefile' tells the system
// whether or not to save the file for future use.
// 'username' - The username for the ftp account.
// 'password' - for ftp account. 'normalize' Will
// normalize the data to a range specified by the
// integers following 'normalize' (Ex. normalize -1 1
// normlizes the training data to range from [-1,1]).
// If max>min, then will not normalize at all.
// 'nullAttribute' - Specifies the value of null
// fields in incomplete records. If 'unparseTable' is
// set to true, then the unparse method will create
// the resulting table from the datafile rather than
// simply returning the standard information. In
// this case, the data object name remoteTable should
// be changed to table in the unparsed file, if the
// user wants to use the unparsed file as the
// definition of a new experiment.DEFAULTS: download
// - false; savefile - true; username - anonymous;
// password - WebSim; normalize - 0 1; nullAttribute
// 0; unparseTable - fales. All other parameters are
// required.
sim.data.RndCircle ::=
// Points on a circle. Random 2D vectors around
// perimeter of a .5-radius circle centered at (.5,.5)
sim.data.RndDisk ::=
// Points in a circle. Random 2D vectors inside of a
// .5-radius circle at (.5,.5)
sim.data.RndOnes ::= IntExp
// Create random vectors with this many elements.
// Uniformly chooses N, then fills in first N
// elements with ones, the rest with uniform real
// numbers in [0,1].
sim.data.RndUniformLine ::=
// random numbers on a line. They are in the range
// [0.0,1.0]
sim.data.RndUniformSquare ::=
// Points in a square. Random 2D vectors uniformly in
// the unit square (0,0)-(1,1).
sim.data.SpiralData ::= { numSpirals NumExp }
// Random points around a spiral within the [-1,1]
// square.
sim.data.Table ::= { ( Matrix Matrix )* }
// table of input/output vectors for training. Each
// Matrix is a row vector representing one input or
// output.
sim.data.XOR ::=
// 2 input 1 output XOR data
sim.display.Contour ::= { (( function <sim.funApp.FunApp>) |
( contours expression.IntExp) |
( spectrum <boolean>) |
( color pointer.PMatrix) |
( trigger <string>) |
( freq expression.IntExp) |
( xElement expression.IntExp) |
( xSamples expression.IntExp) |
( yElement expression.IntExp) |
( ySamples expression.IntExp) |
( zElement expression.IntExp) |
( zMin expression.NumExp) |
( zMax expression.NumExp))* }
// Contour plot. Given a function approximator, plot
// z vs. x and y.
// ===> function: the function to plot
// ===> contours: # contour levels
// ===> spectrum: use rainbow colors for curves?
// ===> color: color for curves if not spectrum
// ===> trigger: recalculate contours every freq time
// that trigger signal changes
// ===> freq: recalculate every freq times
// ===> xElement: which element of input vector is X
// ===> xSamples: # samples along x axis
// ===> yElement: which element of input vector is Y
// ===> ySamples: # samples along y axis
// ===> zElement: which element of output vector to
// plot
// ===> zMin: Z value of lowest contour level, if
// zMin<zMax
// ===> zMax: (autoscales if zMax<zMin)
sim.display.Graph2D ::= { (( trigger <string>) |
( freq expression.IntExp) |
( xMin expression.NumExp) |
( xMax expression.NumExp) |
( yMin expression.NumExp) |
( yMax expression.NumExp) |
( color pointer.PMatrix) |
( flicker <boolean>) |
( showNumbers <boolean>) |
( propZoom <boolean>) |
( squareView <boolean>) |
( plots { <sim.display.Plot>+ } ))* }
// 2D plot. Plot each of the plots on top of each
// other (first one on the bottom)..
// ===> trigger: redraw when this variable changes
// ===> freq: redraw every freq times trigger changes
// ===> xMin: min x value to plot (automatically
// scales if xMin>xMax)
// ===> xMax: max x
// ===> yMin: min y
// ===> yMax: max y
// ===> color: [red,green,blue] for background
// ===> flicker: true=no double buffering, so it's
// faster, uses less memory, but flickers
// ===> showNumbers: true=show numbers on X and Y axes
// ===> propZoom: true=the user can only zoom in on
// proportional regions (no distortions)
// ===> squareView: true=always show a square (not
// rectangular) region
// ===> plots: list of PlotXY, last one plotted on top
sim.display.Graph3D ::= { (( flicker <boolean>) |
( rotateX expression.NumExp) |
( rotateY expression.NumExp) |
( rotateZ expression.NumExp) |
( trigger <string>) |
( freq expression.IntExp) |
( xSamples expression.IntExp) |
( ySamples expression.IntExp) |
( xMin expression.NumExp) |
( xMax expression.NumExp) |
( yMin expression.NumExp) |
( yMax expression.NumExp) |
( xMinNow expression.NumExp) |
( xMaxNow expression.NumExp) |
( yMinNow expression.NumExp) |
( yMaxNow expression.NumExp) |
( zMin expression.NumExp) |
( zMax expression.NumExp) |
( xElement expression.IntExp) |
( yElement expression.IntExp) |
( zElement expression.IntExp) |
( function <sim.funApp.FunApp>) |
( plotFloor <boolean>) |
( plotTop <boolean>) |
( floorColor pointer.PMatrix) |
( topColor pointer.PMatrix) |
( bottomColor pointer.PMatrix) |
( plots { <sim.display.Plot>+ } ) |
( inputs pointer.PMatrix) |
( heightRatio expression.NumExp))* }
// 3D surface plot. Given a function approximator,
// plot z vs. x and y every freq steps on a 3D graph
// with the given rotation.DEFAULTS: rotate 10,30,0,
// z autoscales, no flicker .
// ===> flicker: true=no double buffering, so it's
// faster, uses less memory, but flickers
// ===> rotateX: rotate viewing angle about x axis
// (in degrees)
// ===> rotateY: rotate about x, then y, then z
// ===> rotateZ: rotate about x, then y, then z
// ===> trigger: recalculate contours every freq time
// that trigger signal changes
// ===> freq: recalculate every freq times
// ===> xSamples: # samples along x axis (2 or more)
// ===> ySamples: # samples along y axis (2 or more)
// ===> xMin: original min x in region to plot
// ===> xMax: original max x in region to plot
// ===> yMin: original min y in region to plot
// ===> yMax: original max y in region to plot
// ===> xMinNow: current min x in region to plot
// ===> xMaxNow: current max x in region to plot
// ===> yMinNow: current min y in region to plot
// ===> yMaxNow: current max y in region to plot
// ===> zMin: min z to plot (or automatically scale
// if zMin>zMax)
// ===> zMax: max z to plot
// ===> xElement: which element of input vector is x
// (0 or more)
// ===> yElement: which element of input vector is y
// (0 or more)
// ===> zElement: which element of output vector is z
// (0 or more)
// ===> function: function to plot z vs. x and y
// ===> plotFloor: true=draw the plots on the floor
// of the cube
// ===> plotTop: true=draw the plots on the top of
// the cube
// ===> floorColor: [red,green,blue] of floor of the
// cube
// ===> topColor: [red,green,blue] of surface top
// ===> bottomColor: [red,green,blue] of surface
// underside
// ===> plots: list of PlotXY to draw on sube
// bottom/top
// ===> inputs: values for all input elements, since
// only 2 change with x and y
// ===> heightRatio: height of the box divided by its
// width
sim.display.Grid ::= { (( size expression.NumExp) |
( type expression.IntExp))* }
// Regular grid. Useful as a background for other
// plots.
// ===> size: size of one line segment (in graphing
// units, not pixels)
// ===> type: 0=squares, 1=horiztal lines, 2=vertical
// lines, 3=hexagons, 4=triangles, 5=Penrose,
// 6=Penrose triangles, 7=Penrose dots
sim.display.PlotXY ::= { (( freq expression.IntExp) |
( size expression.IntExp) |
( ring <boolean>) |
( logX <boolean>) |
( logY <boolean>) |
( drawLines <boolean>) |
( drawBoxes <boolean>) |
( drawSymbols <boolean>) |
( symbolType expression.IntExp) |
( symbolSize expression.IntExp) |
( avg2 expression.IntExp) |
( boxColor pointer.PMatrix) |
( lineColor pointer.PMatrix) |
( symbolColor pointer.PMatrix) |
( x <string>) |
( y <string>) |
( trigger <string>) |
( snapshotData <sim.data.Data>) |
( snapshotFunApp <sim.funApp.FunApp>) |
( snapshotXElement expression.IntExp) |
( snapshotYElement expression.IntExp) |
( snapshotSamples expression.IntExp))* }
// //Autoscaling 2D plot. Plots one variable vs.
// another.
// ===> freq: how often to capture new data
// ===> size: # points in buffer
// ===> ring: use ring buffer (forget points in order
// seen)
// ===> logX: plot the log base 10 of X coordinates
// ===> logY: plot the log base 10 of Y coordinates
// ===> drawLines: draw lines connecting average of
// each group?
// ===> drawBoxes: draw bounding rectangles around
// forgotten points?
// ===> drawSymbols: draw a symbol around each data
// point?
// ===> symbolType: symbol on the data
// points,0=dot,1=circle, 2=square, 3=triangle, 4=+,
// 5=X, 6=*
// ===> symbolSize: in pixels
// ===> avg2: average groups of size at least 2 to
// this power
// ===> boxColor: RGB (each 0.0-1.0) for boxes
// ===> lineColor: RGB (each 0.0-1.0) for averaged
// lines
// ===> symbolColor: RGB (each 0.0-1.0) for filling
// in symbols (default is clear)
// ===> x: variable to use for x coord
// ===> y: variable to use for y coord
// ===> trigger: take snapshot when this variable
// changes
// ===> snapshotData: Data output goes through FunApp
// ===> snapshotFunApp: applied to output of Data
// ===> snapshotXElement: which FunApp output for X
// axis
// ===> snapshotYElement: which FunApp output for Y
// axis
// ===> snapshotSamples: how many samples in one
// snapshot
sim.display.SaveDisplay ::= { (( animate <boolean>) |
( filename <string>) |
( trigger <string>) |
( freq expression.IntExp) |
( maxFrames expression.IntExp) |
( display <Display>))* }
// Save GIFs periodically. The image of the given
// display is saved to disk periodically.If the given
// directory doesn't exist, it will not be created,
// and no files will be written.WARNING: SaveDisplay
// will automatically overwrite any files with the
// same names. .
// ===> animate: true=save in one big animated GIF
// file,false=save in separate files, appending
// '0001.gif' to the first filename, then
// incrementing for the rest
// ===> filename: filename to save to
// ===> trigger: save a frame every freq times
// trigger changes
// ===> freq: save every freq times
// ===> maxFrames: maximum # of frames to be saved
// ===> display: the Display whose image will be saved
sim.errFun ::= { k NumExp }
// Advantage Learning.k is the scaling factor is
.AdvantageLearning // normally proportional in size to dt. DEFAULTS: k=1
sim.errFun.Batch ::= { batchSize IntExp <sim.errFun.ErrFun> }
// Call the ErrFun this many times and averages the
// errors into a single error. This allows
// approximate epoch-wise batch learning on an
// infinite data set.
sim.errFun.ErrAvg ::= { <sim.errFun.ErrFun> * }
// Call all these error functions and average their
// errors.This allows gradient descent to satisfy
// several error functions simultaneously.
sim.errFun.LocalLearning ::= { incremental <boolean> data <sim.data.Data>
funApp <sim.funApp.FunApp> }
// learn a input/output mapping. If
// incremental=false, then it does epochwise
// training. The 'data' object may represent a finite
// or infinite training set. If infinite, then
// 'epochwise' will be a pseudoepoch, where a large
// set of points are grouped together and treated as
// if they were a full epoch.
sim.errFun.PDFE ::= { [ c NumExp] input <sim.data.Data> target
<sim.data.Data> funApp <sim.funApp.FunApp> }
// emulate a target PDF. After learning by observing
// iid vectors from the PDF, this can emulate it by
// sending uniform iid vectors into the function
// approximator, and the resulting vectors will be
// distributed correctly.
sim.errFun.QLearning ::=
// Q Learning.
sim.errFun ::= { ( MDP <sim.mdp.MDP> |
.ReinforcementLearning funApp <sim.funApp.FunApp> dt NumExp |
gamma NumExp |
incremental <boolean> |
trajectories <boolean> exploration NumExp |
algorithm <sim.errFun.RLErrFun> |
method ( resGrad |
direct |
( residual (NumExp | adapt NumExp*))))* }
// Reinforcement Learning Experiment Wrapper.With tag
// 'method direct', this is the direct method. With
// 'method resGrad', this is the residual gradient
// method (the default). With 'method residual .7'
// this is the residual method with phi=.7
// (0=direct,1=residual gradient,between=residual).
// With 'method adapt 0.99' phi is adaptive and
// calculated autmatically. The NumExp after 'adapt'
// is the decay factor for the update traces used in
// calculating phi. If incremental=false and
// trajectories=false then the NumExp after 'adapt'
// is ignored and the proper phi is calculated
// exactly. If incremental=false and
// trajectories=true, or incremental=true then the
// NumExp after 'adapt' is used for an approximate
// solution to phi. If 'trajectories' is true, then
// it does training on a trajectory through state
// space, as opposed to randomly choosing a state on
// which to train. 'incremental' determines if the
// parameters of the function approximator will be
// updated after every transition in state space or
// after a sequence of transitions. If
// incrementa=false and trajectories=true the
// parameters of the function approximator will be
// updated when an absorbing state is entered. This
// is an analog to epochwise training in supervised
// learning. 'exploration' is the percentage of time
// a random action is chosen rather than the action
// considered best. 'gamma' is the discount factor.
// 'dt' is the time step size. 'algorithm' is the
// reinforcement learning algorithm to be used.
// DEFAULTS: method=resGrad, gamma=0.9,
// exploration=1, dt=1, incremental=true,
// trajectories=false.
sim.errFun ::= { incremental <boolean> data <sim.data.Data>
.SupervisedLearning funApp <sim.funApp.FunApp> }
// learn a input/output mapping. If
// incremental=false, then it does epochwise
// training. The 'data' object may represent a finite
// or infinite training set. If infinite, then
// 'epochwise' will be a pseudoepoch, where a large
// set of points are grouped together and treated as
// if they were a full epoch.
sim.errFun.ValueIteration ::=
// Value Iteration.
sim.funApp ::= { }
.InterferenceFunction
sim.funApp.LookupTable ::= ( { NumExp NumExp IntExp } )+
// Lookup Table. The triplets are ordered {min max
// levels} where min and max refer to the variable,
// and levels is the number of discretizations in
// that dimension. The min and max can be real
// valued.
sim.funApp.Net ::= { ( Identity |
HardlimitingSquashing |
Bipolar |
Monopolar |
ExponentialInverted |
HyperbolicTan |
Sin |
Gaussian ) ( Linear |
Quadratic1 |
Quadratic2 ) ( NumExp ) (( Identity |
HardlimitingSquashing |
Bipolar |
Monopolar |
ExponentialInverted |
HyperbolicTan |
Sin |
Gaussian ) ( IntExp ) ( Linear |
Quadratic1 |
Quadratic2 ) ( NumExp ) ) * (( Identity |
HardlimitingSquashing |
Bipolar |
Monopolar |
ExponentialInverted |
HyperbolicTan | Sin | Gaussian )
// Neural network which computes the first and second
// derivitives wrt the weights and inputs. It's of
// the form Net {a w a(#) w a(#) w a(#) w a} where a
// is an activation function, w is a type of weights,
// and # is the number of nodes in a layer. The
// layers are listed in order from input to output.
// A layer of 10 sigmoids would be 'Linear(1)
// Sigmoid(10)'. A layer of 5 Radial Basis Functions
// (RBFs) would be 'Quadratic(1) Gaussian(5)'. Note
// that activation functions must be in the first and
// last positions and these two activation functions
// should not specifiy a number of nodes, because
// that information is given in the Data object.
sim.funApp.Recurrent ::=
// Recurrent network.
sim.funApp.SpiralFunction ::=
// spiral function. Maps a single input in the range
// [0,1] into 2D vectors in the [-1,1], [-1,1] square
// lying on a spiral. The weight W makes the spiral
// circle W times within the square.
sim.funApp.ValuePolicy ::= { (( statesOnly <boolean>) |
( dt expression.NumExp) |
( gamma expression.NumExp) |
( mdp <sim.mdp.MDP>) |
( funApp <sim.funApp.FunApp>))* }
// A function that takes a state and returns the
// value of the state with the optimal action. This
// is generally used with Graph3D. When used as the
// FunApp this object can be used to display the
// policy and the value function learned by a machine
// learning algorithm. The keyword 'statesOnly'
// refers to finding values of states (as opposed to
// Q-values). For example, if the learning algorithm
// is Value Iteration or TD(lambda) then 'statesOnly'
// should be true. If statesOnly=true, then gamma
// and dt should be specified as well. .
// ===> statesOnly: find values of states (as opposed
// to Q-values). DEFAULT: false
// ===> dt: duration of a time step. DEFAULT: 0.1
// ===> gamma: discount factor. DEFAULT: 0.9
// ===> mdp:
// ===> funApp:
sim.gradDesc.Backprop ::= { (( learningRate expression.NumExp) |
( momentum expression.NumExp) |
( smooth expression.NumExp) |
( tolerance expression.NumExp) |
( minInitWeight expression.NumExp) |
( maxInitWeight expression.NumExp) |
( error <sim.errFun.ErrFun>))* }
// backprop with momentum..
// ===> learningRate: learning rate, 0=don't learn,
// 1000=change weights fast
// ===> momentum: 0=no momentum, .9999=lots of
// momentum
// ===> smooth: exponential smoothing factor for 'avg
// error', 0=raw error, no smoothing. .9999=very
// smooth, averaged error
// ===> tolerance: learning stops when smoothed error
// below this
// ===> minInitWeight: min value for random initial
// weights
// ===> maxInitWeight: max value for random initial
// weights
// ===> error: the error function to be minimized
sim.gradDesc.ConjGrad ::= { (( step expression.NumExp) |
( mode expression.NumExp) |
( tolerance expression.NumExp) |
( error <sim.errFun.ErrFun>) |
( minInitWeight expression.NumExp) |
( maxInitWeight expression.NumExp))* }
// Conjugate Gradient. minimizes error in ErrFun..
// ===> step: used when initially guessing points
// that bracket a minimum for the line
// search.(default=1)
// ===> mode: the method used to calculate the
// conjugate direction: 0=Polak-Ribiere,
// 1=Fletcher-Reeves.
// ===> tolerance: Learning stops when the smoothed
// error drops below tolerance (default=0).
// ===> error: The ErrFun on which to do gradient
// descent.
// ===> minInitWeight: The minimum value possible
// when initializing the weights (default=-1).
// ===> maxInitWeight: The maximum value possible
// when initializing the weights (default=1).
sim.gradDesc.IDD ::= { (( theta expression.NumExp) |
( smooth expression.NumExp) |
( tolerance expression.NumExp) |
( error <sim.errFun.ErrFun>) |
( minInitWeight expression.NumExp) |
( maxInitWeight expression.NumExp) |
( initBetas expression.NumExp) |
( maxBeta expression.NumExp) |
( seed expression.NumExp))* }
// Incremental Delta Delta. An approximate second
// order method that minimizes error in ErrFun. Each
// funApp parameter has an associated learning rate.
// IDD does gradient descent in the learning rate
// space as well as doing gradient descent on the
// ErrFun..
// ===> theta: The meta learning rate that determines
// the step size in learning rate space.
// ===> smooth: Determines how fast the smoothed
// error reacts.
// ===> tolerance: Learning stops when the smoothed
// error drops below tolerance.
// ===> error: The ErrFun on which to do gradient
// descent.
// ===> minInitWeight: The minimum value possible
// when initializing the weights.
// ===> maxInitWeight: The maximum value possible
// when initializing the weights.
// ===> initBetas: The initial value for the betas.
// ===> maxBeta: The largest value of beta allowed.
// ===> seed: The seed for the random number
// generator. This should be an integer.
sim.mdp.GridWorld ::= { (( granularity expression.IntExp))* }
// 2D Continuous Grid World. World is a square array
// of cells with 4 legal directions to move.
// ===> granularity: grid is (granularity+1) by
// (granularity+1) cells
sim.mdp.HC ::= { (( epochSize expression.IntExp))* }
// Homocidal chauffeur problem, with a bike instead
// of a pedestrian.The car is faster than the bike,
// but the bike has a smaller turn radius..
// ===> epochSize: number of steps to treat as an
// epoch. Only needed when doing epochwise training
// on continuous state space
sim.mdp.HCDemo ::= { (( epochSize expression.IntExp))* }
// Homocidal chauffeur problem, with a bike instead
// of a pedestrian.The car is faster than the bike,
// but the bike has a smaller turn radius..
// ===> epochSize: number of steps to treat as an
// epoch. Only needed when doing epochwise training
// on continuous state space
sim.mdp.Hall ::= { }
// A Hall Markov chain. Starts in state -1 and
// deterministically transitions from x to x+dt.
// Final state 1 and higher are absorbing.
// Reinforcement is always 0..
sim.mdp.LQR ::= { (( discrete <boolean>) |
( epochSize expression.IntExp))* }
// Linear-Quadratic Regulator. .
// ===> discrete: is state space discrete (as opposed
// to continuous)?
// ===> epochSize: number of steps in a pseudo epoch.
// Only needed when doing epoch-wise training on a
// continuous state space
sim.mdp.XORmdp ::= { }
// XOR Markov Decision Process. .
<Display> ::= ShowEdit ShowEdit |
Title Title |
Graph2D sim.display.Graph2D |
Graph3D sim.display.Graph3D |
SaveDisplay sim.display.SaveDisplay
<Project> ::= Credits Credits |
FindBNF FindBNF |
ShowThreads ShowThreads |
TestMatrix TestMatrix |
Simulator sim.Simulator
<picture.PicPipe> ::= Animation picture.Animation |
Antialias picture.Antialias |
ColorMap picture.ColorMap |
Description picture.Description |
Edges picture.Edges |
Gallery picture.Gallery |
PicPipePipeline picture.PicPipePipeline |
Region picture.Region |
RndColor picture.RndColor |
TimebombFractal picture.TimebombFractal |
ValueMap picture.ValueMap |
Fract1 picture.directFractal.Fract1 |
Maze picture.directFractal.Maze
<sim.Experiment> ::= ForExperiment sim.ForExperiment |
TDLambda sim.TDLambda |
Backprop sim.gradDesc.Backprop |
ConjGrad sim.gradDesc.ConjGrad |
IDD sim.gradDesc.IDD
<sim.data.Data> ::= Dot sim.data.Dot |
OnesRnd sim.data.OnesRnd |
RemoteTable sim.data.RemoteTable |
RndCircle sim.data.RndCircle |
RndDisk sim.data.RndDisk |
RndOnes sim.data.RndOnes |
RndUniformLine sim.data.RndUniformLine |
RndUniformSquare sim.data.RndUniformSquare |
SpiralData sim.data.SpiralData |
Table sim.data.Table |
XOR sim.data.XOR
<sim.display.Plot> ::= Picture picture.Picture |
Contour sim.display.Contour |
Grid sim.display.Grid |
PlotXY sim.display.PlotXY
<sim.errFun.ErrFun> ::= AdvantageLearning sim.errFun.AdvantageLearning |
Batch sim.errFun.Batch |
ErrAvg sim.errFun.ErrAvg |
LocalLearning sim.errFun.LocalLearning |
PDFE sim.errFun.PDFE |
QLearning sim.errFun.QLearning |
ReinforcementLearning sim.errFun.ReinforcementLearning |
SupervisedLearning sim.errFun.SupervisedLearning |
ValueIteration sim.errFun.ValueIteration
<sim.errFun.RLErrFun> ::= AdvantageLearning sim.errFun.AdvantageLearning |
QLearning sim.errFun.QLearning |
ReinforcementLearning sim.errFun.ReinforcementLearning |
ValueIteration sim.errFun.ValueIteration
<sim.funApp.FunApp> ::= InterferenceFunction sim.funApp.InterferenceFunction |
LookupTable sim.funApp.LookupTable |
Net sim.funApp.Net |
Recurrent sim.funApp.Recurrent |
SpiralFunction sim.funApp.SpiralFunction |
ValuePolicy sim.funApp.ValuePolicy
<sim.mdp.MDP> ::= GridWorld sim.mdp.GridWorld |
HC sim.mdp.HC |
HCDemo sim.mdp.HCDemo |
Hall sim.mdp.Hall |
LQR sim.mdp.LQR |
XORmdp sim.mdp.XORmdp
<string> ::= a string in single or double quotes
<integer> ::= an integer (no decimal point)
<double> ::= a floating point number with a decimal point
<boolean> ::= true | false