NNCalc

NNMODEL Excel 5 & Excel 95 Add-In (version 1.3)

INTRODUCTION

NNCalc is an Excel 5 & Excel 95 Add-In that allows you to test or use
your neural models from with-in an Excel spreadsheet.  You can now
build complex systems of standard mathematical equations and neural
models then execute them at "Excel" speeds.

INSTALLATION

If you have received the professional edition of NNCalc copy it from the supplied 
floppy into the C:\NNCALC sub-directory. IMPORTANT: NNCALC must reside 
on the C: drive.

To create the nncalc sub-directory on the C: drive and copy all the files to it use:

	MKDIR C:\NNCALC
	COPY A:*.* C:\NNCALC

To install the NNCalc Add-In open an Excel spreadsheet and:

1. Select "Add-Ins" from the "Tools" menu.
2. Press the "Browse" button and navigate to the NNCALC sub-directory.
3. Select the file "NNCALC.XLL". Note: for Excel 95 select NNCALC32.XLL

From now on NNCalc will be available every time Excel is started. If you wish to 
remove NNCalc from Excel select the "Add-Ins" command and "un-check" the 
Add-In labeled "NNCalc Neural Network Function".

USAGE

To build a model that NNCalc can load; first build the model as usual using 
NNMODEL. Then export the model as a feed-forward ENN file and copy it into 
the "c:\nncalc" sub-directory. Note: The current version of NNCalc only looks in 
the "c:\nncalc" sub-directory even if you have installed NNMODEL on the another 
hard disk.

NNCalc Functional Description:

When the NNCalc function is called the neural model named ModelName is 
looked up and it is loaded into memory (if not already present). It then parses the 
rest of the passed parameters and returns an error if the number of passed 
parameters doesn't match the number of inputs to the model. If all parameters 
are correct then NNCalc returns the predicted value of the network,. Otherwise, it 
will return an error code indicating a reason for failure. 
The parameters passed to NNCalc are in the following form:

	=NNCalc ("ModelName", FirstInput, SecondInput, ..., LastInput) 

where:

ModelName         This is the file name of the neural network. No file 
                  extension or sub-directory should be specified. 
                  NNCalc assumes "C:\NNCALC" as the sub-
                  directory and ENN as the extension. For example: 
                  the ModelName "XOR" is translated into 
                  "C:\NNCALC\XOR.ENN".

FirstInput        This is the first input included into the network. 
                  The sequence order can easily be determined by 
                  viewing the input list in the "Interrogate Model" 
                  dialog.

SecondInput       The second input to the network.

LastInput         The final input to the network.


NNCalcM Functional Description:

Because NNCalc only returns the first output of a neural model (a limitation 
of Excel) a function is needed to get additional model outputs. NNCalcM 
returns the predicted values for models that have more than one output. 
NNCalcM does not evaluate the model (that's NNCalcs job). It simply returns
the network's output value.

	=NNCalcM ("ModelName", NeuralOutput, RefToNNCalc) 

where:

ModelName         This is the file name of the neural network. 

NeuralOutput      The index to the neural output to be returned. The first
                  neural output (the one returned by NNCalc) can be selected
                  by passing a 1. The second output can be selected by a value
                  of 2 etc.

RefToNNCalc       This is the cell reference to where NNCalc is used for the
                  selected. For example if =NNCalc("xor2",b1,b2) is in cell G2 
                  then to return the second output of model "xor2" add
                  =NNCalcM("xor2",2,G2) to the cell where you want to display
                  the second output. This "cell reference" is needed so that
                  Excel knows to call NNCalc before calling NNCalcM. 

NNCalcSet Functional Description:

NNCalcSet is used to turn on and off diagnostic functions. Currently there is
only one diagnostic - Logging. To turn on logging call NNCalcSet with the 
following parameters.

	=NNCalcSet("LogOnOff") 

where:

LogOnOff         This is a 1 to turn of logging and a 0 to turn off logging.


A note about input scaling of the passed variables. The input variables are 
linearly scaled according to the minimum and maximum values of the initial 
training set. For example, the XOR models used in the demonstration 
spreadsheet had minimum and maximum values of 0.0 and 1.0 respectively. 
When the user passes values outside the range of 0.0 and 1.0 NNCalc scales 
them to fit within the neural operating range. In this example the XOR's 0.0 
becomes 0.2 and the XOR's 1.0 becomes 0.8. This serves two functions: (1) the 
neural inputs are balanced around the neuron's neural position (0.5) and (2) it 
scales all input to the same range, thus, input with large numbers don't 
overburden inputs with small numbers.

If you pass parameters that are outside of the normal operating range then these 
values may overwhelm the other inputs to the neural network. 
Error Codes:

There are five errors that can be generated by NNCalc. These errors are listed 
below:

Error codes

ErrPE      Bad parameter form. First parameter is not a string 
           ("ModelName") or any of the `neural inputs' parameters 
           aren't real numbers or references to real numbers.

ErrNF      Model not found. The ENN file wasn't found in c:\nncalc 
           sub-directory

ErrIM      Too many inputs in model. 

ErrBN      Bad file name. Only 1-8 alpha-numeric characters are allow 
           in the file name. The extension ".ENN" is automatically 
           appended by NNCalc.

ErrPI      Number of inputs passed doesn't match model. If the 
           neural model calls for 3 inputs then you must pass 3 inputs.

ErrSW      Function not supported in shareware edition of NNCalc

Examples:

The following are examples of how to use NNCalc in an Excel spreadsheet.

=NNCalc ("XOR",1,0)
                                  This example fires the XOR model 
                                  with the a 1.0 loaded into input1 and a 
                                  0.0 loaded into input2.

=NNCalc("XOR",A2,A3)
                                  This example executes the XOR 
                                  model loading input1 with the value 
                                  found in cell A2 and input2 with the 
                                  value in cell A3.

=NNCalc ("COATING", B3, B4, D6, E6, 50)
                                  This example predicts coating from the 
                                  values contained in cells B3, B4, D6, 
                                  E6 and 50.0 is loaded into the last 
                                  input.

=NNCALC ("COATING", B3:B7)
                                  This example is the same as the previous 
                                  except the inputs are passed in cells 
                                  B3,B4,B5,B6 and B7. Where B3 is the first 
                                  input and B7 is the last input.

=NNCALC("X",B1:C4)	
                                  This example predicts X from the eight 
                                  inputs passed. Inputs are B1,C1,B2,C2,
                                  B3,C3,B4,C4 in column  / row order.


EXAMPLE EXCEL SPREADSHEET 

The example included with NNCalc exercises the neural equivalent of six simple 
Boolean logical functions (OR, AND, NAND, NOR, XOR and NOT) and 
demonstrates how neural networks can be used within a spreadsheet. These 
models where constructed using NNMODEL and then exported as feed forward 
models. To run this example load the file named C:\NNCALC\NNCALC.XLS into 
Excel. After loading the following spreadsheet should be displayed.

                    <Spreadsheet Graphic Not Shown>

The inputs (B4 and B5) are used in the NNCalc functions stored in cells E4 
through E8 and E10 through E12. By changing the input cells (B4 and B5) you 
can see the results of the neural models. Enter 1's or 0's into the input cells and 
compare the results to the following truth table.


              Boolean Logic Truth Table

-- Inputs --   --------- Model Outputs ------------
IN1   IN2       OR  AND  NAND NOR  XOR
 0     0        0    0    1    1    0
 0     1        1    0    1    0    1
 1     0        1    0    1    0    1
 1     1        1    1    0    0    0
 1     1        1    1    0    0    0

Each logical function was modeled as separate networks then exported as a 
"Feed Forward Neural Model". Although NNCalc can load the "Full Neural Model" 
version of the network (in ENN format) there is no reason to load the training and 
test matrices carried with the full network.
One additional Boolean function was modeled with a neural network. A NOT 
function which simply logically inverts the input. 
This example not only demonstrates loading and executing 6 neural model within 
a spreadsheet, but also it shows how many neural models can be cascaded to 
form a new function. The "Excel Built XOR" function is built from the logical 
equation:

       XOR = (IN1 .and. .not. IN2) .or. (.not. IN1 .and. IN2)

But, instead of using standard Boolean functions to calculate the XOR function, 
the neural modeled logical functions were used. The table that follows shows the 
Excel syntax used to generate the "Calculated Values" column in the 
spreadsheet. 

OR
                                  =NNCalc("or",B4,B5)

AND
                                  =NNCalc("and",B4,B5)

NAND
                                  =NNCalc("nand",B4,B5)

NOR
                                  =NNCalc("nor",B4,B5)

XOR
                                  =NNCalc("xor",B4,B5)

NOT Input 1
                                  =NNCalc("not",B4)

NOT Input 2
                                  =NNCalc("not",B5)

Excel Build XOR
                                  =NNCalc("or",NNCalc("and",B4,NNCalc("not",B5)),
                                    NNCalc("and",B5,NNCalc("not",B4)) )

VERSION AND PRICING INFORMATION

NNCalc is available in two versions. The shareware version is distributed with 
NNMODEL and has limited functionality. The profession edition has enhanced 
memory caching and extended parameter passing. In either case, NNCalc can 
be distributed (free of charge) with your spreadsheets.

Differences between the shareware and professional edition of NNCalc.

Features                                  Shareware Professional 
                                          Edition   Edition

Maximum number of input parameters that      6      Unlimited
can be passed to a model:                   

Number of neural models that can be          1         32
loaded into cache: (see Note 1)


Note 1: NNCalc loads the neural model into cache memory for execution. Models 
will remain in cache until either Excel has exited or until the model is purged to 
make room for another neural model. 

Version                               Prices

Shareware           Included with NNMODEL registration
Professional        $79.  (shipping included)
Source (Note 2)     $250. (shipping included)

Note 2: NNCalc was written in Microsoft Visual `C' version 1.52
        NNCalc32 was written in Microsoft Visual `C' version 4.0
