MatrixD native code loaded MatrixF native code loaded BNF for WebSim code embedded in Web Pages

BNF for WebSim (short Comments)

WebSim parses a string embedded in a Web page. This string uses the language given 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".

Credits                   ::=                        // print the credits.
Credits2                  ::=                        // print the credits.
DisplayList               ::= '{' ( ['embed'] ['('   // List of displays.
                              IntExp [','] IntExp   
                              [','] IntExp [',']    
                              IntExp ')'] <Display> 
                              )* '}'                
FindBNF                   ::= ['html'] ['summary']   // Find BNF for all objects.
                              'codebase' <string>   
                              'widths' IntExp       
                              IntExp IntExp         
ProjWin                   ::= ['embed'] ['('IntExp   // Window for a single Project.
                              [','] IntExp [',']    
                              IntExp [',']          
                              IntExp')'] <Project>  
ShowEdit                  ::= '{' (('trigger'        // Show variables.
                              <string>) | ('freq'   
                              expression.IntExp) |  
                              ('all' <string>) |    
                              ('vars' '{'           
                              pointer.PString+      
                              '}'))* '}'            
ShowThreads               ::=                        // Show all threads in a 
                                                     // window.
TestMatrix                ::=                        // Test the MatrixD object.
Title                     ::= '{' (('title'          // Title on a Display.
                              <string>) |           
                              ('display'            
                              <Display>))* '}'      
WebSim                    ::= ['unparse'] ProjWin *  // Parse and run a 
                                                     // WebSim program.
expression.IntExp         ::= NumVarExp              // A constant integer 
                                                     // expression.
expression.IntVarExp      ::= NumVarExp              // An integer expression.
expression.NumExp         ::= NumVarExp              // A constant numeric 
                                                     // expression.
expression.NumVarExp      ::= NumVarTerm (('+' |     // A numeric expression.
                              '-') NumVarTerm )*    
expression.NumVarFact     ::= <integer> | <double>   // A factor used by NumVarExp.
                              | '-' 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 
                              ')') |                
expression.NumVarTerm     ::= NumVarFactor (('*' |   // A product or ratio 
                              '/') NumVarTerm )*     // used by NumVarExp.
matrix.MatrixD            ::= ( ('[' [(NumExp        // A matrix or vector.
                              [','])* NumExp] ']')  
                              | ('[' ('[' [(NumExp  
                              [','])* NumExp] ']'   
                              [','])* ('[' [(NumExp 
                              [','])* NumExp] ']')  
                              ']' )) ['transpose']  
matrix.MatrixF            ::= ( ('[' [(NumExp        // A matrix or vector.
                              [','])* NumExp] ']')  
                              | ('[' ('[' [(NumExp  
                              [','])* NumExp] ']'   
                              [','])* ('[' [(NumExp 
                              [','])* NumExp] ']')  
                              ']' )) ['transpose']  
picture.Animation         ::= ( ('first' NumExp) |   // The frames of an Animation.
                              ('last' NumExp) |     
                              ('frames' IntExp) )*  
                              <picture.PicPipe>     
picture.Antialias         ::= 'jitter' ('true' |     // Antialias each pixel.
                              'false') 'raysX'      
                              IntExp 'raysY' IntExp 
                              'raysZ' IntExp        
                              'raysT' IntExp        
picture.ColorMap          ::= picture.ColorMapEntry  // linearly-interpolated 
                              +                      // mapping from double 
                                                     // to color.
picture.ColorMapEntry     ::= '[' NumExp [',']       // one line of a color map.
                              picture.ColorVector   
                              ']'                   
picture.ColorVector       ::= '<' NumExp [',']       // A single color.
                              NumExp [','] NumExp [ 
                              [','] NumExp [',']    
                              NumExp ] '>'          
picture.Description       ::= <string>               // A string describing 
                                                     // the picture being drawn.
picture.Edges             ::= IntExp                 // Trace figure edges.
picture.Gallery           ::= '{'                    // A list of pictures to tile.
                              picture.PicPipePipelin
                              e * '}'               
picture.PicPipePipeline   ::= '{' picture.PicPipe *  // A Picture pipeline.
                              '}'                   
picture.Picture           ::= '{'['bar' IntExp]      // Picture to fade in.
                              'pass1'               
                              picture.picPipePipelin
                              e 'pass2'             
                              picture.picPipePipelin
                              e 'bothPasses'        
                              picture.picPipePipelin
                               '}'                  
picture.Region            ::= '(' NumExp [',']       // A region to zoom into.
                              NumExp ')' [','] '('  
                              NumExp [','] NumExp   
                              ')'                   
picture.RndColor          ::= [ picture.ColorVector  // Random colors.
                              ]                     
picture.ValueMap          ::= picture.ValueMapEntry  // Piecewise linear function.
                              +                     
picture.ValueMapEntry     ::= '[' NumExp [',']       // One line of a value map.
                              NumExp ']'            
picture.directFractal     ::=                        // fractal circles
   .Fract1                                          
picture.directFractal     ::=                        // a fractal maze (CS110 cover)
   .Maze                                            
pointer.PDouble           ::=                       
pointer.PInt              ::=                       
pointer.PObject           ::=                       
pointer.PString           ::= <string>               // a string in single quotes
sim.ForExperiment         ::= '{' ('variable'        // Repeats an Experiment.
                              <string> | 'initVal'  
                              <double> | 'finalVal' 
                              <double> 'increment'  
                              <double>)*            
                              'experiment'          
                              <sim.Experiment> '}'  
sim.Simulator             ::= '{' (('experiment'     // run a simulation.
                              <sim.Experiment>) |   
                              ('displays'           
                              DisplayList))* '}'    
sim.TDLambda              ::= '{' (('mdp'            // TD(lambda).
                              <sim.mdp.MDP>) |      
                              ('funApp'             
                              <sim.funApp.FunApp>)  
                              | ('dt' NumExp)  |    
                              ('incremental'        
                              <boolean>) | ('seed'  
                              IntExp) | ('lambda'   
                              NumExp) | ('gamma'    
                              NumExp) | ('explore'  
                              NumExp) |('rate'      
                              NumExp) | ('smooth'   
                              NumExp) |             
                              ('tolerance' NumExp)  
                              | ('expDecay'         
                              NumExp))* '}'         
sim.data.Dot              ::=                        // Always generates the 
                                                     // vector (.
sim.data.OnesRnd          ::= '{' 'numOutputs'       // Random vector of ones 
                              IntExp'}'              // and random numbers.
sim.data.RemoteTable      ::= '{' 'download'         // downloads a remote 
                              <boolean> 'location'   // table of records and 
                              <string> 'filename'    // converts to 
                              <string> 'inputs'      // input/output vectors 
                              (IntExp [','])+        // for training.
                              'outputs' (IntExp     
                              [','])+ ( ('savefile' 
                              <boolean>) |          
                              ('username' <string>) 
                              | ('password'         
                              <string>) |           
                              ('normalize' IntExp   
                              IntExp) |             
                              ('nullAttribute'      
                              IntExp) |             
                              ('unparseTable'       
                              <boolean>)* '}'       
sim.data.RndCircle        ::=                        // Points on a circle.
sim.data.RndDisk          ::=                        // Points in a circle.
sim.data.RndOnes          ::= IntExp                 // Create random vectors 
                                                     // with this many elements.
sim.data.RndUniformLine   ::=                        // random numbers on a line.
sim.data.RndUniformSquare ::=                        // Points in a square.
sim.data.SpiralData       ::= '{' 'numSpirals'       // Random points around 
                              NumExp'}'              // a spiral within the 
                                                     // [-1,1] square.
sim.data.Table            ::= '{' ( MatrixD MatrixD  // table of input/output 
                              )* '}'                 // vectors for training.
sim.data.XOR              ::=                        // 2 input 1 output XOR 
                                                     // data with bias.
sim.display.Contour       ::= '{' (('function'       // Contour plot.
                              <sim.funApp.FunApp>)  
                              | ('contours'         
                              expression.IntExp) |  
                              ('spectrum'           
                              <boolean>) | ('color' 
                              pointer.PMatrixD) |   
                              ('xElement'           
                              expression.IntExp) |  
                              ('xSamples'           
                              expression.IntExp) |  
                              ('yElement'           
                              expression.IntExp) |  
                              ('ySamples'           
                              expression.IntExp) |  
                              ('zElement'           
                              expression.IntExp) |  
                              ('zMin'               
                              expression.NumExp) |  
                              ('zMax'               
                              expression.NumExp))*  
                              '}'                   
sim.display.Graph2D       ::= '{' (('trigger'        // 2D plot.
                              <string>) | ('freq'   
                              expression.IntExp) |  
                              ('xMin'               
                              expression.NumExp) |  
                              ('xMax'               
                              expression.NumExp) |  
                              ('yMin'               
                              expression.NumExp) |  
                              ('yMax'               
                              expression.NumExp) |  
                              ('color'              
                              pointer.PMatrixD) |   
                              ('flicker' <boolean>) 
                              | ('showNumbers'      
                              <boolean>) |          
                              ('propZoom'           
                              <boolean>) |          
                              ('squareView'         
                              <boolean>) | ('plots' 
                              '{'                   
                              <sim.display.Plot>+   
                              '}'))* '}'            
sim.display.Graph3D       ::= '{' (('flicker'        // 3D surface plot.
                              <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) |  
                              ('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.PMatrixD) |   
                              ('topColor'           
                              pointer.PMatrixD) |   
                              ('bottomColor'        
                              pointer.PMatrixD) |   
                              ('plots' '{'          
                              <sim.display.Plot>+   
                              '}') | ('inputs'      
                              pointer.PMatrixD))*   
                              '}'                   
sim.display.Grid          ::= '{' (('size'           // Regular grid.
                              expression.NumExp) |  
                              ('type'               
                              expression.IntExp))*  
                              '}'                   
sim.display.PlotXY        ::= '{' (('freq'           // //Autoscaling 2D plot.
                              expression.IntExp) |  
                              ('size'               
                              expression.IntExp) |  
                              ('symbolType'         
                              expression.IntExp) |  
                              ('symbolSize'         
                              expression.IntExp) |  
                              ('ring' <boolean>) |  
                              ('drawLines'          
                              <boolean>) |          
                              ('noMerge' <boolean>) 
                              | ('lineColor'        
                              pointer.PMatrixD) |   
                              ('symbolColor'        
                              pointer.PMatrixD) |   
                              ('x' <string>) | ('y' 
                              <string>) |           
                              ('trigger' <string>)  
                              | ('snapshotData'     
                              <sim.data.Data>) |    
                              ('snapshotFunApp'     
                              <sim.funApp.FunApp>)  
                              | ('snapshotXElement' 
                              expression.IntExp) |  
                              ('snapshotYElement'   
                              expression.IntExp) |  
                              ('snapshotSamples'    
                              expression.IntExp))*  
                              '}'                   
sim.display.SaveDisplay   ::= '{' (('animate'        // Save GIFs periodically.
                              <boolean>) |          
                              ('filename' <string>) 
                              | ('trigger'          
                              <string>) | ('freq'   
                              expression.IntExp) |  
                              ('maxFrames'          
                              expression.IntExp) |  
                              ('display'            
                              <Display>))* '}'      
sim.errFun                ::= '{' 'k' NumExp '}'     // Advantage Learning.
   .AdvantageLearning                               
sim.errFun.Batch          ::= '{' 'batchSize'        // Call the ErrFun this 
                              IntExp                 // many times and 
                              <sim.errFun.ErrFun>    // averages the errors 
                              '}'                    // into a single error.
sim.errFun.ErrAvg         ::= '{'                    // Call all these error 
                              <sim.errFun.ErrFun> *  // functions and average 
                              '}'                    // their errors.
sim.errFun.LocalLearning  ::= '{' 'incremental'      // learn a input/output 
                              <boolean> 'data'       // mapping.
                              <sim.data.Data>       
                              'funApp'              
                              <sim.funApp.FunApp>   
                              '}'                   
sim.errFun.PDFE           ::= '{['c' NumExp]         // emulate a target PDF.
                              'input'               
                              <sim.data.Data>       
                              'target'              
                              <sim.data.Data>       
                              'funApp'              
                              <sim.funApp.FunApp>   
                              '}'                   
sim.errFun.QLearning      ::=                        // Q Learning.
sim.errFun                ::= '{' ('MDP'             // Reinforcement 
   .ReinforcementLearning     <sim.mdp.MDP> |        // Learning Experiment Wrapper.
                              '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*))))*  
                              '}'                   
sim.errFun                ::= '{' 'incremental'      // learn a input/output 
   .SupervisedLearning        <boolean> 'data'       // mapping.
                              <sim.data.Data>       
                              'funApp'              
                              <sim.funApp.FunApp>   
                              '}'                   
sim.errFun.ValueIteration ::=                        // Value Iteration.
sim.funApp                ::= '{'                   
   .InterferenceFunction                            
sim.funApp.LookupTable    ::= ('{' NumExp NumExp     // Lookup Table.
                              IntExp '}')+          
sim.funApp.Net            ::= '{' ('Identity' |      // Neural network which 
                              'HardlimitingSquashing // computes the first 
                              ' | 'Bipolar' |        // and second 
                              'Monopolar' |          // derivitives wrt the 
                              'ExponentialInverted'  // weights and inputs.
                              | 'HyperbolicTan' |   
                              'Sin' | 'Gaussian')   
                              ('Linear' |           
                              'Quadratic1'|         
                              'Quadratic2')         
                              (('Identity' |        
                              'HardlimitingSquashing
                              ' | 'Bipolar' |       
                              'Monopolar' |         
                              'ExponentialInverted' 
                              | 'HyperbolicTan' |   
                              'Sin' | 'Gaussian')   
                              '(' IntExp ')'        
                              ('Linear' |           
                              'Quadratic1'|         
                              'Quadratic2') ) *     
                              (('Identity' |        
                              'HardlimitingSquashing
                              ' | 'Bipolar' |       
                              'Monopolar' |         
                              'ExponentialInverted' 
                              | 'HyperbolicTan' |   
                              'Sin' | 'Gaussian')   
sim.funApp.SpiralFunction ::=                        // spiral function.
sim.funApp.ValuePolicy    ::= '{' (('statesOnly'     // A function that takes 
                              <boolean>) | ('dt'     // a state and returns 
                              expression.NumExp) |   // the value of the 
                              ('gamma'               // state with the 
                              expression.NumExp) |   // optimal action.
                              ('mdp' <sim.mdp.MDP>) 
                              | ('funApp'           
                              <sim.funApp.FunApp>))*
                               '}'                  
sim.gradDesc.Backprop     ::= '{' (('learningRate'   // backprop with momentum.
                              expression.NumExp) |  
                              ('momentum'           
                              expression.NumExp) |  
                              ('smooth'             
                              expression.NumExp) |  
                              ('tolerance'          
                              expression.NumExp) |  
                              ('minInitWeight'      
                              expression.NumExp) |  
                              ('maxInitWeight'      
                              expression.NumExp) |  
                              ('error'              
                              <sim.errFun.ErrFun>))*
                               '}'                  
sim.gradDesc.ConjGrad     ::= '{' ( 'tolerance'      // Conjugate Gradient.
                              NumExp | 'step'       
                              NumExp |              
                              'initWeights' NumExp  
                              [','] NumExp)*        
                              'error'               
                              <sim.errFun.ErrFun> | 
                              'mode' NumExp '}'     
sim.gradDesc.IDD          ::= '{' ('theta' NumExp |  // Incremental Delta Delta.
                              'smooth' NumExp |     
                              'tolerance' NumExp |  
                              'initWeights' NumExp  
                              [','] NumExp)*        
                              'error'               
                              <sim.errFun.ErrFun>'}'
sim.mdp.GridWorld         ::= ('granularity' IntExp) // 2D Continuous Grid World.
sim.mdp.HC                ::= ('epochSize' IntExp)*  // Linear-Quadratic Regulator.
sim.mdp.HCDemo            ::= ('epochSize' IntExp)*  // Linear-Quadratic Regulator.
sim.mdp.Hall              ::=                        // A Hall Markov chain.
sim.mdp.LQR               ::= ('discrete' <boolean>  // Linear-Quadratic Regulator.
                              'epochSize' IntExp)*  
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 |
                              'Credits2'              Credits2 |
                              'FindBNF'               FindBNF |
                              'ShowThreads'           ShowThreads |
                              'TestMatrix'            TestMatrix |
                              'Picture'               picture.Picture |
                              '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 |
                              '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>        ::= '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 |
                              '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'
WebSim quitting