CS30 -- Introduction to Computer Science II
Fall, 2006
Homework 4
(updated 9/20/2006)

Exercises:
From the text (Budd's Classic Data Structures in Java), Chapter 4, pg 91 (and 92):
Do number 1, parts a, b, and c.

Programming Projects:
1. Purpose: experience using other classes and exposure to graphics elements.  (from the Budd text) Programming project 8.  (GraphMaker)

2.
Purpose:  use the code you wrote for 1 (#8) and learn about random walks.  (from the Budd text) Programming project 9.  (random walk)

3.  Purpose: More arrays, more interfaces, and introduction to Neural Networks.

You will write the first part of a neural network.  A linear threshold unit (LTU) is the fundamental building block of a neural network.  This week, you will write a class that implements the functionality of a LTU.  These units compute a single output value based a number of inputs.  The output of a unit is determined by computing a linear weighted sum of its inputs and using this sum as the input to an activation function.  You might think of the activation function as using a threshold; if the activation is below the threshold, the output is 0, and if it is above the threshold the output is 1.  In other words, the weighted sum is the input to the activation function, which is usually either a threshold function (as just described) or a sigmoid function (which we'll talk about later).

A single LTU can implement the boolean operators, AND, OR and NOT.  For example, a unit with two inputs (x1 and x2 with weights w1=1 and w2=1) and threshold of 1.5 will compute the logical conjunction (AND) of its two inputs (with input values either 1 or 0).

For this part of the assignment, you should write a class, MyLTU.  Your class should implement the NeuralNetUnit interface that I provide.  There are currently eleven public methods prescribed by the interface.  At this stage, there are eight (two of which are deprecated) public methods that you should implement.  (For now, you should throw UnsupportedOperationException for the last three methods in the interface.  Later, we will implement those as well.)  Your inputs should be Integer wrapper objects containing 0/1 values for input to the LTU.

For reasons that will become clear later, it is convenient to think of the threshold as just another weight and store it in the zero-indexed location for the LTU.

Your class should include a constructor that takes a single int value indicating how many inputs the unit combines.  For example, you might want to create an instance with two inputs and then set the weights and threshold according to the example above.  Or you can experiment with other boolean functions on two or more inputs of your own choosing.

Submission Instructions:
On your machine where you are doing your homework, create a folder called <your email name> followed by "A4".  For example, someone with email address "cjones" would create a folder called "cjonesA4".  Inside that folder, place plain text file(s) containing your answers to any exercises.  Also, place whatever Java files are necessary for your Programming Projects, together with html files generated by the javadoc tool in the same folder.  Finally, either tar or zip the folder so that when I extract it, the folder "<emailname>A4" will be created.  Submit your file via Eureka.