I. Description of the program hopc: The program is used for training a neural network according to the continuous hopfield network algorithm. It receives its inputs either in input files, or interactively, from the user. The outputs (the weights and classes) are written to an output file. Parameter under user control is the dimensionality of the inputs, i.e. the size of the network, and for output generation, the convergence rate. The details are given with the description of the file formats. usage: a) hopc or b) hopc -l input_file data_file weight_file or c) hopc -o weight_file data_file output_file When format a) is used, the program prompts the user for the names of the data and weights file, and then proceeds to prompt the user on the structural parameters of the continuous hopfield network. If output generation is performed, the program also queries about the name of the output data file. Format b) is used for learning. In learning, the parameters for the network are placed in the input_file, the training data are placed in the output_file, and after the training the weights will be output in the weight_file. Format c) is used for output generation. In output generation the program gets the parameters for the network, along with the nodes' weighs from the weight_file, the test data and the convergence rate from the data_file, and writes the outputs (test data and the resultant network state) in the output_file. The file formats are specified below. II. File formats 1. input_file The input file is in a fixed format, i.e. all the parameters I will present below must be present in the file. The format for the file will be given by an example. 4 | Dimension of input space (& number of nodes in the net) is 4 3 | 3 training samples will be given to the network In the input file, all values that are shown in one line in the example, must remain in the same line. Preferred values: The dimension of the input space is problem-dependent. The number of dimensions is not limited in any way. The number of training samples is also problem-dependent. It is not limited in any way, except for the inherent limitations of hopfield networks. 2. data_file The datafile is in a fixed format. It specifies all the training samples Its format is different in the learning and output generation modes. In the learning mode, the format is as follows (it will be given by an example): 1 -1 1 1 | sample 1 -1 -1 -1 1 | sample 2 1 1 1 -1 | sample 3 The important thing to notice is that one input pattern is placed in one line, all of the values being intersperced with exactly one space. In output generation the data file is the file of test samples. The format of the file is the same to the format for the data file in learning, with the following exceptions: The first line in the data_file gives the convergence rate, while the second line gives the number of test input samples. For example, a output generation data file would be as follows: 0.1 | Convergence rate set at 0.1 4 | 4 test samples 1 -1 1 1 | sample 1 -1 -1 -1 1 | sample 2 1 1 1 -1 | sample 3 -1 -1 1 1 | sample 4 3. weight_file The weight_file contains the most basic structural parameter - the number of nodes, as well as data on the weights of the nodes. An example of such a file (for the input file example above) is: 4 | 4 nodes 0.000000 | weight from node 0 to node 0 -0.333333 | weight from node 0 to node 1 1.000000 | weight from node 0 to node 2 0.333333 | weight from node 0 to node 3 -0.333333 | weight from node 1 to node 0 0.000000 | weight from node 1 to node 1 -0.333333 | etc. -1.000000 | 1.000000 | -0.333333 | 0.000000 | 0.333333 | 0.333333 | -1.000000 | 0.333333 | 0.000000 | weight from node 3 to node 3 4. output_file The output file contains the outputs generated by the continuous hopfield network when running output generation. An example for such a file (for the test data example above) is: 1 -1 1 1 | test sample 1 1.00 -1.00 1.00 1.00 | test result 1 | -1 -1 -1 1 | test sample 2 -1.00 -1.00 -1.00 1.00 | test result 2 | 1 1 1 -1 | etc. 1.00 1.00 1.00 -1.00 -1 -1 1 1 1.00 -1.00 1.00 1.00 III. Program organization The programs is organized in one module - hopc. Description of the module: The program parses the input arguments (main()), and supplies them to the training function (hopc()). It also determines which of the usage formats have been used, and calls the hopc() function accordingly. The hopc() function in turn opens the relevant files (openfile()), reads the input (readinput()), and initializes the random number generator (initrandom()). If the network is performing learning, the hopc() function trains the network (hebbian_learning()), and outputs the results (writeoutputweight()). If the network is performing output generation, the hopc() function calculates the outputs for the test data (get_outputs()), and outputs the data (writeoutputdata()). The function readinput() also generates the main control structure (called the 'network' structure), depending on the input parameters. If no arguments are supplied at run-time, the user is interactively queryed whether the network is to be trained, or output is to be generated, and depending on the choice, the user is queried for the input parameters, and for the names of data, weight, and possibly output files. The hebbian_learning() function generates the weights between all pairs of nodes. The weight between nodes i and j depends in how many of the input samples have their i-th and j-th bit with the same value, and in how many of the input samples the i-th and the j-th bit differ. The get_outputs() function presents each test sample to the already trained hopfield network. For each sample the network is initialized to the value of the input (initstate()), then the network is allowed to iterate until it stabilizes (iterate_network()), and finally the network state is recorded as the output of the current test sample (move_to_output()). The iterate_network() continuously selects a node (select_node()), finds the change that would be made to that node (get_change()) and attempts to make the change (make_change()). This continues until no changes have been made for a long series of trials (a constant). IV. Data structure The most important data structure in the program is the "network" structure. A pointer to this structure is passed to all functions that need to read/modify parts/all of the network. Description of the parts of the structure network: The structure has 3 distinct parts: 1. Structural data; 2. Training parameters; and 3. Input storage. 1. Structural data This part contains data relevant to the 'physical' structure of the network: the dimensionality of the input space (i.e. the number of nodes), and the data for nodes themselves - their state and the weights between them. a) num_nodes - an integer which gives the number of nodes in the network, which is the same as the number of input dimensions. Each node will have exactly num_nodes weights, connecting it to its neighbors. b) w - a two-dimensional array of doubles, used to store the weights between the nodes. w[i][j] stores the weight between node i and node j. Note that the matrix is symmetric at all times, so it makes no difference whether w[i][j] or w[j][i] is used. c) state - an array of doubles used to store the state of the network. state[i] gives the current state of node i. All states are in the range [-1,1]. 2. Training parameters This part contains all the 'training parameters'. a) learning - an integer specifying whether the network is used for learning or output generation. When set to 1 the network is used for learning. When set to 0, the network is used for output generation. b) eta - a double that gives the convergence rate. It is used only for output generation. 3. Input storage This part contains all the input data: the number of inputs and the training (or testing) patterns. a) num_inputs - an integer stating the number of inputs the machine will receive. b) inputs - a 1-dimensional array giving the values of all training inputs. inputs[input#] gives the input numbered 'input#'. All the inputs are stored in the 'input_s' structure. The input_s structure contains two arrays. The array 'input', an array of num_nodes integers - gives the actual input values. The array 'output', an array of num_nodes doubles - gives the network state after it has converged for the test sample 'input'. It is used only for output generation. Its values for network training are undefined.