CS 420/527 — Biologically Inspired Computation
NetLogo Simulation

Task Assignment


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: TaskAssignment.nlogo

WHAT IS IT?

This model demonstrates the use of a Hopfield network to perform the Task Assignment Problem. See Flake (1998, ch. 18). 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 model is a reimplementation of the Task Assignment Hopfield Network in Flake, G. (1998), The Computational Beauty of Nature. Implemented by B. J. MacLennan, Sept. 30, 2008.

To refer to this model in academic publications, please use: MacLennan, B.J. (2008). NetLogo TaskAssignment 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/TaskAssignment.html for terms of use.


PROCEDURES

globals [
width
height
num-cells
weight-array
bias-vector
test-data
est-cost
]

patches-own [
state
new-state
local-field
activity
]

to setup
set width world-width
set height world-height
set num-cells width * height
set weight-array n-values num-cells [ weight-row ? ]
randomize-state
set-defaults
end
to set-defaults
set gain 0.5
set scale 0.5
set test-data
[
10 5 4 6 5 1
6 4 9 7 3 2
1 8 3 6 4 6
5 3 7 2 1 4
3 2 5 6 8 7
7 6 4 1 3 2 ]
set-test-data
end
to set-test-data
set bias-vector compute-bias-vector test-data
ask patches [
set plabel-color green
set plabel item (cell-num pxcor pycor) test-data
]
end
to-report compute-bias-vector [data]
let min-cost min data
let max-cost max data
let avg-cost mean data
report map [ scale * (? - avg-cost) / (max-cost - min-cost) + 2 ] data
end
to-report weight-row [i]
report n-values num-cells [ ifelse-value (i = ?) [0] [ weight-val i ? ] ]
end
to-report weight-val [i j]
let ix floor (i / height)
let iy i mod height
let jx floor (j / height)
let jy j mod height
ifelse ix = jx or iy = jy
[
report -2 ]
[
report 0 ]
end
to randomize-state
ask patches [
set new-state -0.1 + random-float 0.2
update-patch-state
]
end
to start-test
randomize-state
clear-all-plots
end
to go
ask patches [ compute-patch-state ]
ask patches [ update-patch-state ]
plot-energy
end
to compute-patch-state
let index cell-num pxcor pycor
set local-field sum map [ (weight-value index ?) * cell ? ] n-values num-cells [?]
set new-state state + delta-t * (local-field + (item index bias-vector) - state / tau)
end
to update-patch-state
set state new-state
set activity sigmoid state
set pcolor scale-color red activity 1.0 0.0
end
to-report sigmoid [x]
report 1 / (1 + exp (- gain * x))
end
to-report cell [p]
report [activity] of patch (floor (p / height)) (p mod height)
end
to-report cell-num [x y]
report x * height + y
end
to-report weight-value [p q]
report item q (item p weight-array)
end
to plot-energy
set-current-plot "Average Cell Energy"
plot (- sum [ state * local-field ] of patches / (num-cells ^ 2))
let activities n-values num-cells [ cell ? ]
set est-cost sum (map [?1 * threshold 0.9 ?2] test-data activities) ; / (sum activities)
set-current-plot "Estimated Rate"
plot est-cost
end
to-report threshold [theta x]
report ifelse-value (x < theta) [0] [x]
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/TaskAssignment.html
Last updated: 2010-10-04.