CS 420/527 — Biologically Inspired Computation
NetLogo Simulation

Hopfield Network Simulator


This page was automatically generated by NetLogo 4.1. Questions, problems? Contact feedback@ccl.northwestern.edu.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Sun's Java site. If the display appear cut off with Firefox, then try another browser (Safari works).



powered by NetLogo

view/download model file: Hopfield.nlogo

WHAT IS IT?

This model demonstrates a Hopfield network. Unfortunately, no further documentation is available at this time.

This section will give a general understanding of what the model is trying to show or explain.


HOW IT WORKS

This section will explain what rules the agents use to create the overall behavior of the model.


HOW TO USE IT

This section will explain how to use the model, including a description of each of the items in the interface tab.


THINGS TO NOTICE

This section will give some ideas of things for the user to notice while running the model.


THINGS TO TRY

This section will give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.


EXTENDING THE MODEL

This section will give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.


NETLOGO FEATURES

This section will point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.


RELATED MODELS

This section will give the names of models in the NetLogo Models Library or elsewhere which are of related interest.


CREDITS AND REFERENCES

This section will contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

To refer to this model in academic publications, please use: MacLennan, B.J. (2008). NetLogo Hopfield model. http://www.cs.utk.edu/~mclennan. Dept. of Electrical Engineering & Computer Science, Univ. of Tennessee, Knoxville.

In other publications, please use: Copyright 2008 Bruce MacLennan. All rights reserved. See http://www.cs.utk.edu/~mclennan/420/NetLogo/Hopfield.html for terms of use.


PROCEDURES

globals [
width
height
num-cells
weight-array
]

patches-own [
state
local-field
]

to setup
set width world-width
set height world-height
set num-cells width * height
set weight-array n-values num-cells [ n-values num-cells [0] ]
ask patches [
set state 1
set pcolor black
]
set-current-plot "Average Cell Energy"
end
to go
ask patches [ update-patch-state ]
plot-energy
end
to update-patch-state
let index pxcor * height + pycor
set local-field sum map [ (weight-value index ?) * cell ? ] n-values num-cells [?]
ifelse local-field >= 0
[
set state 1
set pcolor black ]
[
set state -1
set pcolor white ]
end
to-report cell [p]
report [state] of patch (floor (p / height)) (p mod height)
end
to-report weight-value [p q]
report item q (item p weight-array)
end
to plot-energy
plot (- sum [ state * local-field ] of patches / (num-cells ^ 2))
end
to load-image
let filename user-input "Enter image file name"
import-pcolors filename
ask patches [
ifelse pcolor = black
[
set state 1 ]
[
set state -1
set pcolor white ]
]
end
to imprint
set weight-array map [ new-column ? ] n-values num-cells [?]
end
to-report new-column [p]
report map [ update-weight p ? ] n-values num-cells [?]
end
to-report update-weight [p q]
ifelse p = q
[
report 0 ]
[
report (weight-value p q) + (cell p) * (cell q) ]
end
to degrade
ask patches [
if random 100 < degree [
set state (- state)
ifelse state > 0
[
set pcolor black ]
[
set pcolor white ]
]
]
end
to start-test
clear-all-plots
end
to draw-black
if mouse-down?
[
ask patches
[
if ((abs (pxcor - mouse-xcor)) < 1) and ((abs (pycor - mouse-ycor)) < 1)
[
set pcolor black set state 1]
]]
end
to draw-white
if mouse-down?
[
ask patches
[
if ((abs (pxcor - mouse-xcor)) < 1) and ((abs (pycor - mouse-ycor)) < 1)
[
set pcolor white set state -1]
]]
end

Return to CS 420/527 home page

Return to MacLennan's home page

Send mail to Bruce MacLennan / MacLennan@utk.edu

Valid HTML 4.01!This page is web.eecs.utk.edu/~mclennan/Classes/420/NetLogo/Hopfield.html
Last updated: 2010-09-22.