The Computational Beauty of Nature
Source code

hopfield

solve a task assignment problem via a Hopfield network

hopfield -help
  or
hopfield
       [-specs  string]  [-dt double] [-tau double] [-gain
       double] [-scale  double]  [-seed  integer]  [-steps
       integer]  [-gray  integer]  [-inv]  [-mag  integer]
       [-term string]

Solves a task assignment problem via a Hopfield neural network while plotting the activations of the neurons over time. The program uses the k-out-of-n rule for setting the external inputs and synapse strength of the neurons.

Solve a task assignment problem via a Hopfield neural network while plotting the activations of the neurons over time. The program uses the K-out-of-N rule for setting the external inputs and synapse strength of the neurons.

Miscellany

As mentioned before, the weights and external inputs are

set according to the K-out-of-N rule which states that if we have N neurons in a mutually connected sub-network and that we wish this subset to converge with exactly K neurons activated, then each neuron should be connected to every other neuron with a weights of -2 and receive an external input of (2K - 1). Since we must produce solutions that look like permutation matrices, each neuron is in 2 K-out-of-N subsets, one for the column and one for the row. Thus, all neurons inhibit all other neurons in the same column or row with -2 and must (on average) receive a net input of 2 since they are all in two sets. The external inputs are slightly adjusted to favor neurons that represent more productive task performers. See the source code for more details.

Bugs

No sanity checks are performed to make sure that any of the options make sense.

The final cost of the solution is printed at the end of the simulation; however, no check is done to insure that the system has actually converged. Hence, it may print out nonsense results.

Options

-specsProblem specification file.data/hop1.dat
-dtTime step increment.0.1
-tauDecay term.10.0
-gainSigmoidal gain.0.5
-scaleScaling for inputs.0.5
-seedRandom seed for initial state.0
-stepsNumber of time steps.1000
-grayNumber of gray levels.256
-invInvert all colors?False
-magMagnification factor.10
-termHow to plot points.None

hopfield.c on GitHub