Assignment 3

Description: In this assignment you will apply the hillclimber you
developed in assignment 1 to the artiﬁcial neural networks (ANNs) you
developed in assignment 2. The program you develop in this assignment
works as follows:

1. Create a (numNeurons=)10  10 (numNeurons=)matrix, parent, to hold
the synapse values for an ANN with numNeurons=10 neurons.

2. Randomize the parent synapse matrix.

3. Create a (numUpdates=)10  (numNeurons=)10 matrix neuronValues to
hold the values of the neurons as the network is updated. The ﬁrst row
stores the initial values of the neurons, which for this assignment
will all initially be set to 0.5. The second row will store the new
values of each neuron, and so on.

4. Create a vector of length 10, desiredNeuronValues, that holds the
output that we want the ANN to create. We’ll compare the ﬁnal values of
the neurons—the last row of neuronValues—to this vector. The closer the
match, the higher the ﬁtness of parent synapse matrix.

5. Update neuronValues nine times (thus ﬁlling in rows two through 10)
using the parent synapse values.

6. The program will then loop through 1000 generations. For each loop:
. Create the child synapse matrix by copying and perturbing the parent
synapse matrix.
. Set each element in the ﬁrst row of neuronValues to 0.5.
. Update the neuronValues of the ANN nine times using the child synapse
values.
. Calculate and save the ﬁtness of the child synapses as childFitness.
. If the childFitness is better than parentFitness, replace the parent
synapse matrix with the child synapse matrix and set parentFitness to
the childFitness value.