Machine Problem 3, due Mar 9

Part of the homework for CS:2820, Fall 2015
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Write a Java program, in file NeuronNetwork.java that can be run as follows to read data from a file called f (presuming that this file exists):

[HawkID@serv15 project]$ java NeuronNetwork f

When your program is run, it should read a description of a network of neurons, here is an example description (an extended version of the format used for MP2):

neuron A 1.0 0.95
neuron B 1.0 0.0
synapse X A B 1.2  0.5
synapse - B A 0.3 -0.5
synapse - B X 0.3  0.5

Syntactically, there are two types of synapse, unnamed synapses and named ones. Synapse X above is a named synapse connecting neurons A and B. Unnamed synapses have a single dash in the name field. Neuron and synapse names be non-numeric.

Any synapse that is named may be the target of a secondary synapse. The synapse B X above is a secondary synapse that connects neuron B to (primary) synapse X. Logically, primary and secondary synapses are two distinct subclasses of synapse.

As before, the first number in the description of a synapse is the delay, the second number is the strength. Delays may not be negative. Strengths are of either sign.

Having created a data structure to describe this kind of circuit this data structure, the program should print out a description of the circuit it created, in exactly the same notation as is used in the input file, but to the standard output stream.

Error messages: As before, your program should report any errors it detects: If it can't open the input file, lines that don't start with neuron or synapse, missing fields on a line, negative time delays, synapses that reference non-existant neurons or synapses, etc. As before, your error messages should be helpful, but need not be elaborate.

Output: After reporting any errors, your program should traverse the data structures it has built to produce an output file describing the neuron network. This file should conform to the same rules as the input file.

Note that the default behavior of the scanner was to skip as many blanks as needed to get to the next item, but the output only put one blank. Note that the output prints floating-point values in a standard compact form, without excessive leading or trailing zeros that might have been used in the input.

Grading criteria: No credit will be given to programs that do not represent a substantial attempt at meeting the requirements of this assignment. Your program must:

Note that the requirements for header comments in the file header are absolute. Your name must appear in the form that it appears on your ID card. The TAs will not waste their time doing detective work to attempt to figure out who submitted what code.

Submission: Your solution should consist of a single file, with one public method, main. (Later, we will chop the file into smaller more managable pieces, as it grows.)

To submit your solution, make sure it is in a file called NeuronNetwork.java (this requires that the main method be in a class called NeuronNetwork. This must be in the current directory. Then, follow the following dialogue with the Linux shell (what you type is given in boldface):

[HawkID@serv16 ~/project]$ submit NeuronNetwork.java
Course (22C:016 would be c_016): CS2820
Possible submit directories for /group/submit/CS2820 are:

The dialogue continues as in MP1, except that the submit directory for this assignment will be named mp3 instead of mp1