Simulated Annealing2

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.1pre1 • Viewed 146 times • Downloaded 19 times • Run 0 times
Download the 'Simulated Annealing2' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


VERSION

$Id: Simulated Annealing2.nlogo 39709 2008-05-01 17:53:24Z tisue $

WHAT IS IT?

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

HOW IT WORKS

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

HOW TO USE IT

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

THINGS TO NOTICE

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

THINGS TO TRY

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

EXTENDING THE MODEL

This section could 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 could 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 could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

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

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

patches-own [ brightness ]

to setup
  ca
  ask patches [
    set brightness random-float 10 ;5 + 10 * random 14 ;random-float 1.0
    update-visual
  ]
end 

to go
  ask patches
  [
    try-change self
  ]
  set temperature temperature * temperature-drop-ratio
  tick
end 

to update-visual
  set pcolor brightness ;  scale-color gray brightness 0 1
end 

to-report accept-change? [ old-fitness new-fitness ]
  report (random-float 100) < temperature or new-fitness > old-fitness
end 

to try-change [ p1 ]
  let p2 one-of ( [neighbors] of p1 )
  let affected-patches (patch-set ([neighbors] of p1) ([neighbors] of p2))
  let old-fitness sum [get-fitness] of affected-patches
  swap-values p1 p2
  let new-fitness sum [get-fitness] of affected-patches
  ifelse (accept-change? old-fitness new-fitness)
  [
    ask p1 [ update-visual ]
    ask p2 [ update-visual ]
  ]
  [
    swap-values p1 p2
  ]
end 

to swap-values [ p1 p2 ]
  let temp [ brightness ] of p1
  ask p1 [ set brightness [brightness] of p2 ]
  ask p2 [ set brightness temp ]    
end 

to-report get-fitness  ; patch-procedure
  let unhappiness 0.0
  ask neighbors [ 
    set unhappiness unhappiness + (brightness - [brightness] of myself) ^ 2
  ]
  report 8 - unhappiness
end 

There is only one version of this model, created almost 14 years ago by Uri Wilensky.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.