├── .#index.html ├── .htaccess ├── ABTgc ├── ABTgc.nlogo ├── index.html ├── medium.png ├── table │ └── table.jar └── thumb.png ├── AWCgc ├── AWCgc.nlogo ├── index.html ├── medium.png └── thumb.png ├── AntSystem ├── AntSystem.nlogo ├── index.html ├── medium.png └── thumb.png ├── DBgc ├── DBgc.nlogo ├── index.html ├── medium.png └── thumb.png ├── NetLogoLite.jar ├── README.markdown ├── bayesball ├── bayesball.nlogo ├── index.html ├── medium.png └── thumb.png ├── beernet ├── beernet.nlogo ├── index.html ├── medium.png └── thumb.png ├── ca ├── ca.nlogo ├── index.html ├── medium.png └── thumb.png ├── circle ├── circle.nlogo ├── index.html ├── medium.png └── thumb.png ├── code.js ├── coin ├── coin.nlogo ├── index.html ├── medium.png └── thumb.png ├── congregating ├── congregating.nlogo ├── index.html ├── medium.png └── thumb.png ├── coordination ├── coordination.nlogo ├── index.html ├── medium.png └── thumb.png ├── distributedrec ├── distributedrec.nlogo ├── index.html ├── medium.png └── thumb.png ├── evolutionarygt ├── evolutionarygt.nlogo ├── index.html ├── medium.png └── thumb.png ├── find-coalition ├── find-coalition.nlogo ├── index.html ├── medium.png └── thumb.png ├── index.ftl ├── index.html ├── mailmen ├── index.html ├── mailmen.nlogo ├── medium.png └── thumb.png ├── marriage-problem ├── index.html ├── marriage-problem.nlogo ├── medium.png └── thumb.png ├── model.ftl ├── nqueens-adopt ├── index.html ├── medium.png ├── nqueens-adopt.nlogo └── thumb.png ├── nqueensawc ├── index.html ├── medium.png ├── nqueensawc.nlogo └── thumb.png ├── packages ├── index.html ├── medium.png ├── packages.nlogo └── thumb.png ├── paretolearn ├── index.html ├── medium.png ├── paretolearn.nlogo └── thumb.png ├── path-finding ├── index.html ├── medium.png ├── path-finding.nlogo └── thumb.png ├── port ├── NetLogoLite.jar ├── applet.html ├── index.html ├── medium.png ├── port.nlogo ├── port.png └── thumb.png ├── qlearning ├── index.html ├── medium.png ├── qlearning.nlogo └── thumb.png ├── replicator ├── index.html ├── medium.png ├── replicator.nlogo └── thumb.png ├── shapebugs ├── index.html ├── medium.png ├── shapebugs.nlogo └── thumb.png ├── sns ├── index.html ├── medium.png ├── sns.nlogo └── thumb.png ├── style.css ├── tileworld ├── index.html ├── medium.png ├── thumb.png └── tileworld.nlogo ├── top-trading-cycle ├── index.html ├── medium.png ├── thumb.png └── top-trading-cycle.nlogo └── valueiter ├── index.html ├── medium.png ├── thumb.png └── valueiter.nlogo /.#index.html: -------------------------------------------------------------------------------- 1 | jmvidal@jmvidal-macbook.local.30249 -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | Addtype application/octet-stream .nlogo 2 | -------------------------------------------------------------------------------- /ABTgc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |Gary Fredericks
Generates and solves graph coloring problems using ABT.
I used simple integers to represent node values, corresponding to the indexes in the built-in base-colors array. So in a 3-color graph, the values will be the numbers [0,1,2], and they will refer to the corresponding colors in the base-colors array.
Priorities are implemented by who number, with lower numbers having lower priorities.
The program as written always generates solvable graphs. It does this by
29 | 1) Generating the specified number of turtles
30 | 2) Assigning random colors to each turtle (from the specified number of colors)
31 | 3) Generating legal links until either the links-to-nodes ratio has been reached, or no legal links can be generated. In the latter case, a warning is written to the console.
I implemented two no-good generators. The first, which is used by default, is the naive generator which uses the local view. I also tried to create a hyperresolution generator, but my simple implementation would just concatenate all of the previously generated nogoods (filtering out the elements referring to self), which certainly isn't sufficient to solve the problem, and may also be worse than the local-view version (it also generates tautological nogoods most of the time, i.e. NOT(TURTLE1(A) ^ TURTLE1(B) ^ ...)). If I had time, I think I would enjoy trying to do hyperresolution properly.
1) I used the table extension for the local-view datastructure, with the who-numbers for keys.
32 | 2) A single nogood is represented as a list of pairs, where [[1 3] [2 4]] means that "turtle 1 having value 3 and turtle 2 having value 4" is no-good.
33 | 3) Despite using who-numbers for local-view and no-goods, I implemented "naybors" as a list of turtles. Could've gone either way I guess.
20100623
34 | 35 | 36 | -------------------------------------------------------------------------------- /ABTgc/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/ABTgc/medium.png -------------------------------------------------------------------------------- /ABTgc/table/table.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/ABTgc/table/table.jar -------------------------------------------------------------------------------- /ABTgc/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/ABTgc/thumb.png -------------------------------------------------------------------------------- /AWCgc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This is the implementation of the Asynchronous Weak-Commitment Search for the graph coloring problem. We solve the graph coloring problem using the AWCS algorithm from
29 |Ionel Muscalagiu, Jose M. Vidal
20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /AWCgc/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/AWCgc/medium.png -------------------------------------------------------------------------------- /AWCgc/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/AWCgc/thumb.png -------------------------------------------------------------------------------- /AntSystem/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Chistopher Roach and Benito Mendoza
This model is an implementation of the Ant System algorithm, as described in here, that is being used to solve the Traveling Salesman Problem.
The Ant System algorithm can be used to find the shortest path in a graph by employing the same decentralized mechanism exploited by ant colonies foraging for food. In the model, each agent (i.e., ant) constructs a tour in the graph by making a choice at each node as to which node will be visited next according to a probability associated with each node. The probability of an ant choosing a specific node at any time is determined by the amount of pheromone and the cost (i.e., the distance from the current node i to the next node j, where node j has not yet been visited) associated with each edge.
The attributes in this model that can be adjusted to change the behavior of the algorithm are alpha, beta, and rho. The alpha and beta values are used to determine the transition probability discussed above, where the values are used to adjust the relative influence of each edge's pheromone trail and path cost on the ant's decision. A rho value is also associated with the algorithm and is used as an evaporation rate which allows the algorithm to "forget" tours which have proven to be less valuable.
Choose the number of nodes and ants that you wish to have in the simulation (for best results set the number of ants equal to the number of nodes in the graph). Click the SETUP button to create a random graph, a new colony of ants, and draw an initial tour on the graph. Click the GO button to start the simulation. The RESET button keeps the same graph that was generated by the SETUP operation, but it resets everything else in the algorithm (i.e., it destroys all ants and edges in the graph and clears all of the plots). The RESET button allows the user to run several tests with the same graph for data gathering.
The alpha slider controls the propensity of the ants to exploit paths with high amounts of pheromone on them. The beta slider controls how greedy the ants are, i.e., the ant's to edges with the lowest cost. The delta slider controls the evaporation rate of the pheromone in the graph where the higher the delta, the faster the pheromone evaporates.
In the model, two plots are given to show how the algorithm is performing. The "Best Tour Cost" plot shows the cost of the best tour found so far over the life of the current run. The "Tour Cost Distribution" plot is a histrogram that shows how the ants are distributed throughout the solution space. In this plot, the vertical axis is the number of ants and the horizontal axis is tour cost, where each bar has a range of 10 units.
According to [1], emperical evidence shows that the optimal settings for the algorithm are: alpha = 1, beta = 5, rho = 0.5. Try adjusting each of these settings from the optimal and take notice of how they affect the performance of the algorithm. Watch the "Best Tour Cost" plot to see if adjustments lead to a steadier march towards the best tour or perhaps they add up to a good initial search that settles quickly into a local optimum. Study the "Tour Cost Distribution" plot to see if changes to the evaporation rate lead to stagnation? Can you find more optimal settings than those that have been found through previous experimentation?
This model is an implementation of the Ant System algorithm from:
29 |Roach, Christopher (2007). NetLogo Ant System model. Computer Vision and Bio-inspired Computing Laboratory, Florida Institute of Technology, Melbourne, FL.
33 |Dorigo, M., Maniezzo, V., and Colorni, A., The Ant System: Optimization by a colony of cooperating agents. IEEE Transactions on Systems, Man, and Cybernetics Part B: Cybernetics, Vol. 26, No. 1. (1996), pp. 29-41. http://citeseer.ist.psu.edu/dorigo96ant.html
36 |http://www.tsp.gatech.edu/
39 |20100428
41 | 42 | 43 | -------------------------------------------------------------------------------- /AntSystem/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/AntSystem/medium.png -------------------------------------------------------------------------------- /AntSystem/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/AntSystem/thumb.png -------------------------------------------------------------------------------- /DBgc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |An implementation of the distributed breakout algorithm from
29 |Makoto Yokoo and Katsutoshi Hirayama. Algorithms for Distributed Constraint Satisfaction: A Review<. Autonomous Agents and Multi-Agent Systems, 3(2):185--207, 2000.
33 |Makoto Yokoo and Katsutoshi Hirayama. Distributed Breakout Algorithm for Solving Distributed Constraint Satisfaction Problems. In Proceedings of the Second International Conference on Multiagent Systems, p. 401--408, 1996.
36 |Jose M Vidal
20100623
38 | 39 | 40 | -------------------------------------------------------------------------------- /DBgc/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/DBgc/medium.png -------------------------------------------------------------------------------- /DBgc/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/DBgc/thumb.png -------------------------------------------------------------------------------- /NetLogoLite.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/NetLogoLite.jar -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | 2 | These are the netlogo models published on the [Multiagent NetLogo models page](http://jmvidal.cse.sc.edu/netlogomas/). Most of them are described in my textbook [Fundamentals of Multiagent Systems](http://www.multiagent.com). 3 | 4 | Feel free to grab a copy and extend as you see fit. -------------------------------------------------------------------------------- /bayesball/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This model implements the Bayes-Ball algorithm. The purpose to this simulation is to provide a visualization that readers of Shachter's article can explore in order to better understand the process of the algorithm as well as the results it elicits.
29 |This model is an implementation of the algorithm described by Ross D. Shachter in his 1998 article "Bayes-Ball: The Rational Pastime (for Deteriming Irrelevance and Requisite Information in Belief Networks and Influence Diagrams)."
The algorithm describes a mechanism for identifing irrelevant nodes, requisite probability nodes, and requisite observation nodes when querying for a specified node given a set of evidence nodes. The input to the algorithm is a belief network, a node on which the query is oriented, and a set of nodes for which evidence is given.
Query nodes comprise the set of nodes J. These nodes are tinted light blue. Nodes that have evidence on them comprise the set of nodes K and have a red star in the middle. All other nodes are probabilistic nodes tinted yellow. This implementation disregards deterministic nodes.
The algorithm will start the "bouncind ball" at the query node(s) comprising the set of nodes J (tinted blue in the simulation), and then pass the ball around in the following manner:
32 |SETUP NETWORK - this sets up a network characterized by the following parameters configurable by the user via sliders: number-nodes and number-J-nodes
MANUAL - this allows the user to manually move the nodes around in order to arrange them in a more visually appealling or expressive manner
MAKE NODES - this will create the number of nodes specified by number-nodes with a subset of these nobes colored blue to identify them as J nodes. The number of J nodes is specified by number-J-nodes.
MAKE CONNECTIONS - After clicking on this button, click on the source node of a connection followed by a destination node. Once the destination node is clicked, a link from source to destination will be created.
RANDOMLY SET EVIDENCE - this button will randomly choose a subset of nodes to be considered evidence nodes. The number of nodes chosen is specified by number-K-nodes. Evidence nodes are designated by red stars on the yellow nodes.
MANUALLY SET OR REMOVE EVIDENCE - the user can set evidence nodes themselves, or remove evidence from a node that has been starred as an evidence node. To do this, click this button and then click a node. If the node is starred (has evidence), the star will be removed (no evidence). If the node is not starred, a star will be added to this node.
CLEAR - clears view of any existing network to reveal a clear white view; useful if user wants to create her/his own network
RESET - resets the execution while preserving the currently viewed network. This allows for repeating executions on the same network with different evidence specified.
NUMBER-NODES - the number of nodes in the network
NUMBER-J-NODES - the number of nodes in the network that are being queried upon
NUMBER-K-NODES - the number of nodes that have evidence on them. This is used by the "get evidence" button.
Alicia Ruvinsky
20100623
35 | 36 | 37 | -------------------------------------------------------------------------------- /bayesball/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/bayesball/medium.png -------------------------------------------------------------------------------- /bayesball/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/bayesball/thumb.png -------------------------------------------------------------------------------- /beernet/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M. Vidal and Anand Nair
This is an implementation of an automated beer distrubution game in a large tree-like network. We can observe the Bullwhip effect in action. We test survivability and dynamic behavior of the supply network under various types of attacks or failures. More information on this model can be found in
29 |20110501
Upgraded to 5.0
32 | 33 | 34 | -------------------------------------------------------------------------------- /beernet/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/beernet/medium.png -------------------------------------------------------------------------------- /beernet/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/beernet/thumb.png -------------------------------------------------------------------------------- /ca/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Generates and solves a combinatorial auction. The yellow circles represent the items for sale and the green squares represent the bids. Each bid is connected to the items it is over. The square bids with the squares around them are the ones in the revenue-maximizing solution, which we find upon "setup" by running a branch-and-bids algorithm. We implement a branch and bound algorithm on both the branch on items search tree and the branch on bids search tree.
The simple branch and bound algorithms implemented here are described in
29 |If you want to learn more about combinatorial auctions I recommend
32 |Jose M Vidal
20100623
35 | 36 | 37 | -------------------------------------------------------------------------------- /ca/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/ca/medium.png -------------------------------------------------------------------------------- /ca/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/ca/thumb.png -------------------------------------------------------------------------------- /circle/circle.nlogo: -------------------------------------------------------------------------------- 1 | ; move in a circle 2 | ; by 3 | ; Jose M Vidal 4 | 5 | to setup 6 | ;; (for this model to work with NetLogo's new plotting features, 7 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 8 | ;; the beginning of your setup procedure and reset-ticks at the end 9 | ;; of the procedure.) 10 | __clear-all-and-reset-ticks 11 | create-n-turtles num-turtles 12 | end 13 | 14 | to create-n-turtles [n] 15 | crt n [ 16 | fd random 20 17 | shake] 18 | end 19 | 20 | to update 21 | no-display 22 | if (count turtles < num-turtles)[ 23 | create-n-turtles num-turtles - count turtles] 24 | while [count turtles > num-turtles][ 25 | ask one-of turtles [die]] 26 | ask turtles [move] 27 | display 28 | end 29 | 30 | ; 31 | to move 32 | let cx 0 33 | let cy 0 34 | 35 | set cx mean [xcor] of turtles 36 | set cy mean [ycor] of turtles 37 | set heading towardsxy cx cy 38 | if (distancexy cx cy < radius) [ 39 | set heading heading + 180] 40 | if (abs distancexy cx cy - radius > 1)[ 41 | fd speed / 1.414] 42 | set heading towardsxy cx cy 43 | ifelse (clockwise) [ 44 | set heading heading - 90] 45 | [ 46 | set heading heading + 90] 47 | fd speed / 1.414 48 | end 49 | 50 | to shake 51 | set heading heading + (random 10) - 5 52 | set xcor xcor + random 10 - 5 53 | set ycor ycor + random 10 - 5 54 | end 55 | @#$#@#$#@ 56 | GRAPHICS-WINDOW 57 | 245 58 | 10 59 | 570 60 | 356 61 | 17 62 | 17 63 | 9.0 64 | 1 65 | 10 66 | 1 67 | 1 68 | 1 69 | 0 70 | 1 71 | 1 72 | 1 73 | -17 74 | 17 75 | -17 76 | 17 77 | 0 78 | 0 79 | 1 80 | ticks 81 | 30.0 82 | 83 | SLIDER 84 | 3 85 | 77 86 | 175 87 | 110 88 | num-turtles 89 | num-turtles 90 | 1 91 | 200 92 | 118 93 | 1 94 | 1 95 | NIL 96 | HORIZONTAL 97 | 98 | SLIDER 99 | 3 100 | 110 101 | 175 102 | 143 103 | radius 104 | radius 105 | 1 106 | 50 107 | 10 108 | 1 109 | 1 110 | NIL 111 | HORIZONTAL 112 | 113 | BUTTON 114 | 2 115 | 44 116 | 83 117 | 77 118 | NIL 119 | setup 120 | NIL 121 | 1 122 | T 123 | OBSERVER 124 | NIL 125 | NIL 126 | NIL 127 | NIL 128 | 1 129 | 130 | BUTTON 131 | 83 132 | 44 133 | 164 134 | 77 135 | NIL 136 | update 137 | NIL 138 | 1 139 | T 140 | OBSERVER 141 | NIL 142 | NIL 143 | NIL 144 | NIL 145 | 1 146 | 147 | BUTTON 148 | 164 149 | 44 150 | 245 151 | 77 152 | NIL 153 | update 154 | T 155 | 1 156 | T 157 | OBSERVER 158 | NIL 159 | NIL 160 | NIL 161 | NIL 162 | 1 163 | 164 | BUTTON 165 | 3 166 | 209 167 | 84 168 | 242 169 | shake 170 | ask turtles [shake] 171 | NIL 172 | 1 173 | T 174 | OBSERVER 175 | NIL 176 | NIL 177 | NIL 178 | NIL 179 | 1 180 | 181 | SLIDER 182 | 3 183 | 143 184 | 175 185 | 176 186 | speed 187 | speed 188 | 0 189 | 10 190 | 1.1 191 | 0.1 192 | 1 193 | NIL 194 | HORIZONTAL 195 | 196 | SWITCH 197 | 3 198 | 176 199 | 122 200 | 209 201 | clockwise 202 | clockwise 203 | 1 204 | 1 205 | -1000 206 | 207 | @#$#@#$#@ 208 | # Circle 209 | 210 | ## WHAT IS IT? 211 | 212 | A very simple application where the turtles move around in a circle. 213 | It serves as a fun example of emergent behavior. It also raises 214 | interesting questions: What is the most robust way to implement this? What if 215 | different people implement different turtles? What if we add some 216 | limitations to the environment? etc. 217 | 218 | ## CREDITS 219 | 220 | Jose M Vidal 221 | 222 | ## CHANGES 223 | 224 | 20100623 225 | @#$#@#$#@ 226 | default 227 | true 228 | 0 229 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 230 | 231 | ant 232 | true 233 | 0 234 | Polygon -7500403 true true 136 61 129 46 144 30 119 45 124 60 114 82 97 37 132 10 93 36 111 84 127 105 172 105 189 84 208 35 171 11 202 35 204 37 186 82 177 60 180 44 159 32 170 44 165 60 235 | Polygon -7500403 true true 150 95 135 103 139 117 125 149 137 180 135 196 150 204 166 195 161 180 174 150 158 116 164 102 236 | Polygon -7500403 true true 149 186 128 197 114 232 134 270 149 282 166 270 185 232 171 195 149 186 237 | Polygon -7500403 true true 225 66 230 107 159 122 161 127 234 111 236 106 238 | Polygon -7500403 true true 78 58 99 116 139 123 137 128 95 119 239 | Polygon -7500403 true true 48 103 90 147 129 147 130 151 86 151 240 | Polygon -7500403 true true 65 224 92 171 134 160 135 164 95 175 241 | Polygon -7500403 true true 235 222 210 170 163 162 161 166 208 174 242 | Polygon -7500403 true true 249 107 211 147 168 147 168 150 213 150 243 | 244 | arrow 245 | true 246 | 0 247 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 248 | 249 | bee 250 | true 251 | 0 252 | Polygon -1184463 true false 151 152 137 77 105 67 89 67 66 74 48 85 36 100 24 116 14 134 0 151 15 167 22 182 40 206 58 220 82 226 105 226 134 222 253 | Polygon -16777216 true false 151 150 149 128 149 114 155 98 178 80 197 80 217 81 233 95 242 117 246 141 247 151 245 177 234 195 218 207 206 211 184 211 161 204 151 189 148 171 254 | Polygon -7500403 true true 246 151 241 119 240 96 250 81 261 78 275 87 282 103 277 115 287 121 299 150 286 180 277 189 283 197 281 210 270 222 256 222 243 212 242 192 255 | Polygon -16777216 true false 115 70 129 74 128 223 114 224 256 | Polygon -16777216 true false 89 67 74 71 74 224 89 225 89 67 257 | Polygon -16777216 true false 43 91 31 106 31 195 45 211 258 | Line -1 false 200 144 213 70 259 | Line -1 false 213 70 213 45 260 | Line -1 false 214 45 203 26 261 | Line -1 false 204 26 185 22 262 | Line -1 false 185 22 170 25 263 | Line -1 false 169 26 159 37 264 | Line -1 false 159 37 156 55 265 | Line -1 false 157 55 199 143 266 | Line -1 false 200 141 162 227 267 | Line -1 false 162 227 163 241 268 | Line -1 false 163 241 171 249 269 | Line -1 false 171 249 190 254 270 | Line -1 false 192 253 203 248 271 | Line -1 false 205 249 218 235 272 | Line -1 false 218 235 200 144 273 | 274 | bird1 275 | false 276 | 0 277 | Polygon -7500403 true true 2 6 2 39 270 298 297 298 299 271 187 160 279 75 276 22 100 67 31 0 278 | 279 | bird2 280 | false 281 | 0 282 | Polygon -7500403 true true 2 4 33 4 298 270 298 298 272 298 155 184 117 289 61 295 61 105 0 43 283 | 284 | boat1 285 | false 286 | 0 287 | Polygon -1 true false 63 162 90 207 223 207 290 162 288 | Rectangle -6459832 true false 150 32 157 162 289 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 290 | Polygon -7500403 true true 158 33 230 157 182 150 169 151 157 156 291 | Polygon -7500403 true true 149 55 88 143 103 139 111 136 117 139 126 145 130 147 139 147 146 146 149 55 292 | 293 | boat2 294 | false 295 | 0 296 | Polygon -1 true false 63 162 90 207 223 207 290 162 297 | Rectangle -6459832 true false 150 32 157 162 298 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 299 | Polygon -7500403 true true 157 54 175 79 174 96 185 102 178 112 194 124 196 131 190 139 192 146 211 151 216 154 157 154 300 | Polygon -7500403 true true 150 74 146 91 139 99 143 114 141 123 137 126 131 129 132 139 142 136 126 142 119 147 148 147 301 | 302 | boat3 303 | false 304 | 0 305 | Polygon -1 true false 63 162 90 207 223 207 290 162 306 | Rectangle -6459832 true false 150 32 157 162 307 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 308 | Polygon -7500403 true true 158 37 172 45 188 59 202 79 217 109 220 130 218 147 204 156 158 156 161 142 170 123 170 102 169 88 165 62 309 | Polygon -7500403 true true 149 66 142 78 139 96 141 111 146 139 148 147 110 147 113 131 118 106 126 71 310 | 311 | box 312 | true 313 | 0 314 | Polygon -7500403 true true 45 255 255 255 255 45 45 45 315 | 316 | butterfly1 317 | true 318 | 0 319 | Polygon -16777216 true false 151 76 138 91 138 284 150 296 162 286 162 91 320 | Polygon -7500403 true true 164 106 184 79 205 61 236 48 259 53 279 86 287 119 289 158 278 177 256 182 164 181 321 | Polygon -7500403 true true 136 110 119 82 110 71 85 61 59 48 36 56 17 88 6 115 2 147 15 178 134 178 322 | Polygon -7500403 true true 46 181 28 227 50 255 77 273 112 283 135 274 135 180 323 | Polygon -7500403 true true 165 185 254 184 272 224 255 251 236 267 191 283 164 276 324 | Line -7500403 true 167 47 159 82 325 | Line -7500403 true 136 47 145 81 326 | Circle -7500403 true true 165 45 8 327 | Circle -7500403 true true 134 45 6 328 | Circle -7500403 true true 133 44 7 329 | Circle -7500403 true true 133 43 8 330 | 331 | circle 332 | false 333 | 0 334 | Circle -7500403 true true 35 35 230 335 | 336 | person 337 | false 338 | 0 339 | Circle -7500403 true true 155 20 63 340 | Rectangle -7500403 true true 158 79 217 164 341 | Polygon -7500403 true true 158 81 110 129 131 143 158 109 165 110 342 | Polygon -7500403 true true 216 83 267 123 248 143 215 107 343 | Polygon -7500403 true true 167 163 145 234 183 234 183 163 344 | Polygon -7500403 true true 195 163 195 233 227 233 206 159 345 | 346 | spacecraft 347 | true 348 | 0 349 | Polygon -7500403 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 350 | 351 | thin-arrow 352 | true 353 | 0 354 | Polygon -7500403 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 355 | 356 | truck-down 357 | false 358 | 0 359 | Polygon -7500403 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 360 | Polygon -8630108 true false 195 75 195 120 240 120 240 75 361 | Polygon -8630108 true false 195 225 195 180 240 180 240 225 362 | 363 | truck-left 364 | false 365 | 0 366 | Polygon -7500403 true true 120 135 225 135 225 210 75 210 75 165 105 165 367 | Polygon -8630108 true false 90 210 105 225 120 210 368 | Polygon -8630108 true false 180 210 195 225 210 210 369 | 370 | truck-right 371 | false 372 | 0 373 | Polygon -7500403 true true 180 135 75 135 75 210 225 210 225 165 195 165 374 | Polygon -8630108 true false 210 210 195 225 180 210 375 | Polygon -8630108 true false 120 210 105 225 90 210 376 | 377 | turtle 378 | true 379 | 0 380 | Polygon -7500403 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 381 | 382 | wolf-left 383 | false 384 | 3 385 | Polygon -6459832 true true 117 97 91 74 66 74 60 85 36 85 38 92 44 97 62 97 81 117 84 134 92 147 109 152 136 144 174 144 174 103 143 103 134 97 386 | Polygon -6459832 true true 87 80 79 55 76 79 387 | Polygon -6459832 true true 81 75 70 58 73 82 388 | Polygon -6459832 true true 99 131 76 152 76 163 96 182 104 182 109 173 102 167 99 173 87 159 104 140 389 | Polygon -6459832 true true 107 138 107 186 98 190 99 196 112 196 115 190 390 | Polygon -6459832 true true 116 140 114 189 105 137 391 | Rectangle -6459832 true true 109 150 114 192 392 | Rectangle -6459832 true true 111 143 116 191 393 | Polygon -6459832 true true 168 106 184 98 205 98 218 115 218 137 186 164 196 176 195 194 178 195 178 183 188 183 169 164 173 144 394 | Polygon -6459832 true true 207 140 200 163 206 175 207 192 193 189 192 177 198 176 185 150 395 | Polygon -6459832 true true 214 134 203 168 192 148 396 | Polygon -6459832 true true 204 151 203 176 193 148 397 | Polygon -6459832 true true 207 103 221 98 236 101 243 115 243 128 256 142 239 143 233 133 225 115 214 114 398 | 399 | wolf-right 400 | false 401 | 3 402 | Polygon -6459832 true true 170 127 200 93 231 93 237 103 262 103 261 113 253 119 231 119 215 143 213 160 208 173 189 187 169 190 154 190 126 180 106 171 72 171 73 126 122 126 144 123 159 123 403 | Polygon -6459832 true true 201 99 214 69 215 99 404 | Polygon -6459832 true true 207 98 223 71 220 101 405 | Polygon -6459832 true true 184 172 189 234 203 238 203 246 187 247 180 239 171 180 406 | Polygon -6459832 true true 197 174 204 220 218 224 219 234 201 232 195 225 179 179 407 | Polygon -6459832 true true 78 167 95 187 95 208 79 220 92 234 98 235 100 249 81 246 76 241 61 212 65 195 52 170 45 150 44 128 55 121 69 121 81 135 408 | Polygon -6459832 true true 48 143 58 141 409 | Polygon -6459832 true true 46 136 68 137 410 | Polygon -6459832 true true 45 129 35 142 37 159 53 192 47 210 62 238 80 237 411 | Line -16777216 false 74 237 59 213 412 | Line -16777216 false 59 213 59 212 413 | Line -16777216 false 58 211 67 192 414 | Polygon -6459832 true true 38 138 66 149 415 | Polygon -6459832 true true 46 128 33 120 21 118 11 123 3 138 5 160 13 178 9 192 0 199 20 196 25 179 24 161 25 148 45 140 416 | Polygon -6459832 true true 67 122 96 126 63 144 417 | 418 | @#$#@#$#@ 419 | NetLogo 5.0beta2 420 | @#$#@#$#@ 421 | @#$#@#$#@ 422 | @#$#@#$#@ 423 | @#$#@#$#@ 424 | @#$#@#$#@ 425 | default 426 | 0.0 427 | -0.2 0 0.0 1.0 428 | 0.0 1 1.0 0.0 429 | 0.2 0 0.0 1.0 430 | link direction 431 | true 432 | 0 433 | Line -7500403 true 150 150 90 180 434 | Line -7500403 true 150 150 210 180 435 | 436 | @#$#@#$#@ 437 | 0 438 | @#$#@#$#@ 439 | -------------------------------------------------------------------------------- /circle/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |A very simple application where the turtles move around in a circle.
29 | It serves as a fun example of emergent behavior. It also raises
30 | interesting questions: What is the most robust way to implement this? What if
31 | different people implement different turtles? What if we add some
32 | limitations to the environment? etc.
Jose M Vidal
20100623
33 | 34 | 35 | -------------------------------------------------------------------------------- /circle/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/circle/medium.png -------------------------------------------------------------------------------- /circle/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/circle/thumb.png -------------------------------------------------------------------------------- /code.js: -------------------------------------------------------------------------------- 1 | function popup (name,w,h) { 2 | var w = w + 30; 3 | var h = h + 100; 4 | window.open(name + '/index.html', name, 'width=' + w + ',height=' + h); 5 | return false; 6 | }; 7 | 8 | var showingModel = true; 9 | 10 | $(document).ready(function(){ 11 | $('.modelLink').hover( 12 | function(e){ console.log($(this)[0].id); $('#' + $(this)[0].id + 'Description').show(); }, //in 13 | function(e){ $('#' + $(this)[0].id + 'Description').hide();} //out 14 | ); 15 | $('#aboutLink').click(function(e){ 16 | if (showingModel){ 17 | $('#featuredModel').hide(); 18 | $('#aboutText').show(); 19 | showingModel = false; 20 | } else { 21 | $('#aboutText').hide(); 22 | $('#featuredModel').show(); 23 | showingModel = true; 24 | } 25 | return false; 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /coin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This model implements the COllective INtelligence framework and attempts to reproduce the results from
29 |It implements the wonderful life utility (WLU) clamped down to 0 (no attendance) and 1 (attend every day) and the aristrocatic utility function for the El Farol Bar problem. Since the paper does not mention the exact parameter values used I have been unable to exactly reproduce their results. Namely, this simulation seems to take longer to converge than theirs.
Each row in the main output window represents one agent and each of the 7 columns is a day of the week. The patch is set to blue when the agent attends that particular night. Note that the agent often converge if you let the model run over 1000 steps.
Optimal global utility is achieved, for num-nights=1, if 3 agents attend every night except one night when all the other agents attend.
Jose M Vidal
20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /coin/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/coin/medium.png -------------------------------------------------------------------------------- /coin/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/coin/thumb.png -------------------------------------------------------------------------------- /congregating/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |We implement the congregating algorithm from
29 |Jose M Vidal
20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /congregating/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/congregating/medium.png -------------------------------------------------------------------------------- /congregating/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/congregating/thumb.png -------------------------------------------------------------------------------- /coordination/coordination.nlogo: -------------------------------------------------------------------------------- 1 | ; Coordination game 2 | ; by 3 | ; Jose M Vidal 4 | ; $Id: coordination.nlogo,v 1.3 2005/01/30 20:20:08 jmvidal Exp jmvidal $ 5 | 6 | turtles-own [past-rewards-blue past-rewards-red update-clock friends] 7 | 8 | globals [time num-turtles old-k] 9 | 10 | to setup 11 | ;; (for this model to work with NetLogo's new plotting features, 12 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 13 | ;; the beginning of your setup procedure and reset-ticks at the end 14 | ;; of the procedure.) 15 | __clear-all-and-reset-ticks 16 | set time 0 17 | set-default-shape turtles "box" 18 | set num-turtles world-width * world-height 19 | set old-k k 20 | ask patches [ 21 | sprout 1 [ 22 | set heading 0 23 | set update-clock random update-delay 24 | ] 25 | ] 26 | ask turtles [ 27 | set friends get-friends 28 | set past-rewards-blue [] 29 | set past-rewards-red [] 30 | ifelse (random-float 1.0 < .5) [ 31 | set color blue] 32 | [ 33 | set color red]] 34 | end 35 | 36 | to-report converged? 37 | let c 0 38 | 39 | set c count turtles with [color = red] 40 | if (c = 0 or c = count turtles) [ 41 | report true] 42 | report false 43 | end 44 | 45 | to update 46 | let c 0 47 | 48 | if (converged?) [stop] 49 | if (old-k != k)[ 50 | ask turtles [set friends get-friends] 51 | set old-k k] 52 | ask one-of turtles [doit] 53 | set-current-plot-pen "red" 54 | set c count turtles with [color = red] 55 | plot c 56 | set-current-plot-pen "blue" 57 | plot num-turtles - c 58 | set time time + 1 59 | end 60 | 61 | ;;turtles 62 | to-report get-payoff [c1 c2] 63 | if (c1 = c2) [report 1] 64 | report -1 65 | end 66 | 67 | to update-history [p] 68 | ifelse (color = blue)[ 69 | set past-rewards-blue fput p past-rewards-blue 70 | set past-rewards-red fput 0 past-rewards-red] 71 | [ 72 | set past-rewards-blue fput 0 past-rewards-blue 73 | set past-rewards-red fput p past-rewards-red] 74 | while [length past-rewards-blue > memory-window] [ 75 | set past-rewards-blue butlast past-rewards-blue 76 | set past-rewards-red butlast past-rewards-red] 77 | end 78 | 79 | to set-next-color 80 | let b 0 81 | let w 0 82 | 83 | if (update-clock > 0)[ 84 | set update-clock update-clock - 1 85 | stop] 86 | set update-clock update-delay 87 | set b sum past-rewards-blue 88 | set w sum past-rewards-red 89 | ifelse (b > w) [ 90 | set color blue] 91 | [ 92 | if (b < w)[ 93 | set color red]] 94 | end 95 | 96 | to-report get-partner 97 | if (model = 1) [ 98 | ; report one-of (turtles with [who != [who] of myself]]) 99 | report one-of (other turtles)] 100 | if (model = 2)[ 101 | report one-of friends] 102 | end 103 | 104 | to-report get-friends 105 | report (other turtles) with [ 106 | ; (who != [who] of myself) and 107 | (min list abs (who - [who] of myself) 108 | abs (num-turtles - abs (who - [who] of myself))) <= k ] 109 | end 110 | 111 | to doit 112 | let the-other 0 113 | let payoff 0 114 | 115 | set the-other get-partner 116 | set payoff get-payoff color ([color] of the-other) 117 | update-history payoff 118 | ask the-other [update-history payoff] 119 | 120 | set-next-color 121 | ask the-other [set-next-color] 122 | 123 | end 124 | @#$#@#$#@ 125 | GRAPHICS-WINDOW 126 | 253 127 | 13 128 | 630 129 | 411 130 | 5 131 | 5 132 | 33.4 133 | 1 134 | 10 135 | 1 136 | 1 137 | 1 138 | 0 139 | 1 140 | 1 141 | 1 142 | -5 143 | 5 144 | -5 145 | 5 146 | 0 147 | 0 148 | 1 149 | ticks 150 | 30.0 151 | 152 | BUTTON 153 | 2 154 | 44 155 | 84 156 | 78 157 | NIL 158 | setup 159 | NIL 160 | 1 161 | T 162 | OBSERVER 163 | NIL 164 | NIL 165 | NIL 166 | NIL 167 | 1 168 | 169 | BUTTON 170 | 84 171 | 45 172 | 165 173 | 78 174 | NIL 175 | update 176 | T 177 | 1 178 | T 179 | OBSERVER 180 | NIL 181 | NIL 182 | NIL 183 | NIL 184 | 1 185 | 186 | SLIDER 187 | 4 188 | 81 189 | 176 190 | 114 191 | update-delay 192 | update-delay 193 | 0 194 | 200 195 | 69 196 | 1 197 | 1 198 | NIL 199 | HORIZONTAL 200 | 201 | PLOT 202 | 634 203 | 21 204 | 888 205 | 171 206 | Agents 207 | NIL 208 | NIL 209 | 0.0 210 | 100.0 211 | 0.0 212 | 100.0 213 | true 214 | false 215 | "" "" 216 | PENS 217 | "red" 1.0 0 -2674135 true "" "" 218 | "blue" 1.0 0 -13345367 true "" "" 219 | 220 | MONITOR 221 | 634 222 | 208 223 | 691 224 | 261 225 | NIL 226 | time 227 | 9 228 | 1 229 | 13 230 | 231 | SLIDER 232 | 4 233 | 115 234 | 176 235 | 148 236 | memory-window 237 | memory-window 238 | 1 239 | 200 240 | 200 241 | 1 242 | 1 243 | NIL 244 | HORIZONTAL 245 | 246 | BUTTON 247 | 166 248 | 45 249 | 247 250 | 78 251 | NIL 252 | update 253 | NIL 254 | 1 255 | T 256 | OBSERVER 257 | NIL 258 | NIL 259 | NIL 260 | NIL 261 | 1 262 | 263 | SLIDER 264 | 3 265 | 200 266 | 175 267 | 233 268 | model 269 | model 270 | 1 271 | 2 272 | 2 273 | 1 274 | 1 275 | NIL 276 | HORIZONTAL 277 | 278 | TEXTBOX 279 | 10 280 | 153 281 | 126 282 | 197 283 | 1=fully connected\n2=regular graph 284 | 13 285 | 0.0 286 | 0 287 | 288 | SLIDER 289 | 4 290 | 234 291 | 176 292 | 267 293 | k 294 | k 295 | 1 296 | 100 297 | 10 298 | 1 299 | 1 300 | NIL 301 | HORIZONTAL 302 | 303 | @#$#@#$#@ 304 | # The Coordination Game 305 | 306 | ## WHAT IS IT? 307 | This is the binary coordination game. Each agent can be either red 308 | or blue. At each time step some of the agents change their color simultaneously. 309 | The goal is to find out how long it takes, under different conditions, for the 310 | population to converge to one color. This problem was presented in 311 | 312 | 1. Yoav Shoham and Moshe Tennenholtz. [On the emergence of social conventions: modeling, analysis, and simulations](http://jmvidal.cse.sc.edu/lib/shoham97a.html). Artificial Intelligence, 94 (139--166) 1997. 313 | 314 | 2. Jordi Delgado. [Emergence of social conventions in complex networks](http://jmvidal.cse.sc.edu/lib/delgado02a.html). Artificial Intelligence, 141. p. 171--185, 2002. 315 | 316 | ## CREDITS 317 | 318 | Jose M Vidal 319 | 320 | ## CHANGES 321 | 322 | 20100623 323 | @#$#@#$#@ 324 | default 325 | true 326 | 0 327 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 328 | 329 | ant 330 | true 331 | 0 332 | Polygon -7500403 true true 136 61 129 46 144 30 119 45 124 60 114 82 97 37 132 10 93 36 111 84 127 105 172 105 189 84 208 35 171 11 202 35 204 37 186 82 177 60 180 44 159 32 170 44 165 60 333 | Polygon -7500403 true true 150 95 135 103 139 117 125 149 137 180 135 196 150 204 166 195 161 180 174 150 158 116 164 102 334 | Polygon -7500403 true true 149 186 128 197 114 232 134 270 149 282 166 270 185 232 171 195 149 186 335 | Polygon -7500403 true true 225 66 230 107 159 122 161 127 234 111 236 106 336 | Polygon -7500403 true true 78 58 99 116 139 123 137 128 95 119 337 | Polygon -7500403 true true 48 103 90 147 129 147 130 151 86 151 338 | Polygon -7500403 true true 65 224 92 171 134 160 135 164 95 175 339 | Polygon -7500403 true true 235 222 210 170 163 162 161 166 208 174 340 | Polygon -7500403 true true 249 107 211 147 168 147 168 150 213 150 341 | 342 | arrow 343 | true 344 | 0 345 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 346 | 347 | bee 348 | true 349 | 0 350 | Polygon -1184463 true false 151 152 137 77 105 67 89 67 66 74 48 85 36 100 24 116 14 134 0 151 15 167 22 182 40 206 58 220 82 226 105 226 134 222 351 | Polygon -16777216 true false 151 150 149 128 149 114 155 98 178 80 197 80 217 81 233 95 242 117 246 141 247 151 245 177 234 195 218 207 206 211 184 211 161 204 151 189 148 171 352 | Polygon -7500403 true true 246 151 241 119 240 96 250 81 261 78 275 87 282 103 277 115 287 121 299 150 286 180 277 189 283 197 281 210 270 222 256 222 243 212 242 192 353 | Polygon -16777216 true false 115 70 129 74 128 223 114 224 354 | Polygon -16777216 true false 89 67 74 71 74 224 89 225 89 67 355 | Polygon -16777216 true false 43 91 31 106 31 195 45 211 356 | Line -1 false 200 144 213 70 357 | Line -1 false 213 70 213 45 358 | Line -1 false 214 45 203 26 359 | Line -1 false 204 26 185 22 360 | Line -1 false 185 22 170 25 361 | Line -1 false 169 26 159 37 362 | Line -1 false 159 37 156 55 363 | Line -1 false 157 55 199 143 364 | Line -1 false 200 141 162 227 365 | Line -1 false 162 227 163 241 366 | Line -1 false 163 241 171 249 367 | Line -1 false 171 249 190 254 368 | Line -1 false 192 253 203 248 369 | Line -1 false 205 249 218 235 370 | Line -1 false 218 235 200 144 371 | 372 | bird1 373 | false 374 | 0 375 | Polygon -7500403 true true 2 6 2 39 270 298 297 298 299 271 187 160 279 75 276 22 100 67 31 0 376 | 377 | bird2 378 | false 379 | 0 380 | Polygon -7500403 true true 2 4 33 4 298 270 298 298 272 298 155 184 117 289 61 295 61 105 0 43 381 | 382 | boat1 383 | false 384 | 0 385 | Polygon -1 true false 63 162 90 207 223 207 290 162 386 | Rectangle -6459832 true false 150 32 157 162 387 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 388 | Polygon -7500403 true true 158 33 230 157 182 150 169 151 157 156 389 | Polygon -7500403 true true 149 55 88 143 103 139 111 136 117 139 126 145 130 147 139 147 146 146 149 55 390 | 391 | boat2 392 | false 393 | 0 394 | Polygon -1 true false 63 162 90 207 223 207 290 162 395 | Rectangle -6459832 true false 150 32 157 162 396 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 397 | Polygon -7500403 true true 157 54 175 79 174 96 185 102 178 112 194 124 196 131 190 139 192 146 211 151 216 154 157 154 398 | Polygon -7500403 true true 150 74 146 91 139 99 143 114 141 123 137 126 131 129 132 139 142 136 126 142 119 147 148 147 399 | 400 | boat3 401 | false 402 | 0 403 | Polygon -1 true false 63 162 90 207 223 207 290 162 404 | Rectangle -6459832 true false 150 32 157 162 405 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 406 | Polygon -7500403 true true 158 37 172 45 188 59 202 79 217 109 220 130 218 147 204 156 158 156 161 142 170 123 170 102 169 88 165 62 407 | Polygon -7500403 true true 149 66 142 78 139 96 141 111 146 139 148 147 110 147 113 131 118 106 126 71 408 | 409 | box 410 | true 411 | 0 412 | Polygon -7500403 true true 45 255 255 255 255 45 45 45 413 | 414 | butterfly1 415 | true 416 | 0 417 | Polygon -16777216 true false 151 76 138 91 138 284 150 296 162 286 162 91 418 | Polygon -7500403 true true 164 106 184 79 205 61 236 48 259 53 279 86 287 119 289 158 278 177 256 182 164 181 419 | Polygon -7500403 true true 136 110 119 82 110 71 85 61 59 48 36 56 17 88 6 115 2 147 15 178 134 178 420 | Polygon -7500403 true true 46 181 28 227 50 255 77 273 112 283 135 274 135 180 421 | Polygon -7500403 true true 165 185 254 184 272 224 255 251 236 267 191 283 164 276 422 | Line -7500403 true 167 47 159 82 423 | Line -7500403 true 136 47 145 81 424 | Circle -7500403 true true 165 45 8 425 | Circle -7500403 true true 134 45 6 426 | Circle -7500403 true true 133 44 7 427 | Circle -7500403 true true 133 43 8 428 | 429 | circle 430 | false 431 | 0 432 | Circle -7500403 true true 35 35 230 433 | 434 | person 435 | false 436 | 0 437 | Circle -7500403 true true 155 20 63 438 | Rectangle -7500403 true true 158 79 217 164 439 | Polygon -7500403 true true 158 81 110 129 131 143 158 109 165 110 440 | Polygon -7500403 true true 216 83 267 123 248 143 215 107 441 | Polygon -7500403 true true 167 163 145 234 183 234 183 163 442 | Polygon -7500403 true true 195 163 195 233 227 233 206 159 443 | 444 | spacecraft 445 | true 446 | 0 447 | Polygon -7500403 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 448 | 449 | thin-arrow 450 | true 451 | 0 452 | Polygon -7500403 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 453 | 454 | truck-down 455 | false 456 | 0 457 | Polygon -7500403 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 458 | Polygon -8630108 true false 195 75 195 120 240 120 240 75 459 | Polygon -8630108 true false 195 225 195 180 240 180 240 225 460 | 461 | truck-left 462 | false 463 | 0 464 | Polygon -7500403 true true 120 135 225 135 225 210 75 210 75 165 105 165 465 | Polygon -8630108 true false 90 210 105 225 120 210 466 | Polygon -8630108 true false 180 210 195 225 210 210 467 | 468 | truck-right 469 | false 470 | 0 471 | Polygon -7500403 true true 180 135 75 135 75 210 225 210 225 165 195 165 472 | Polygon -8630108 true false 210 210 195 225 180 210 473 | Polygon -8630108 true false 120 210 105 225 90 210 474 | 475 | turtle 476 | true 477 | 0 478 | Polygon -7500403 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 479 | 480 | wolf-left 481 | false 482 | 3 483 | Polygon -6459832 true true 117 97 91 74 66 74 60 85 36 85 38 92 44 97 62 97 81 117 84 134 92 147 109 152 136 144 174 144 174 103 143 103 134 97 484 | Polygon -6459832 true true 87 80 79 55 76 79 485 | Polygon -6459832 true true 81 75 70 58 73 82 486 | Polygon -6459832 true true 99 131 76 152 76 163 96 182 104 182 109 173 102 167 99 173 87 159 104 140 487 | Polygon -6459832 true true 107 138 107 186 98 190 99 196 112 196 115 190 488 | Polygon -6459832 true true 116 140 114 189 105 137 489 | Rectangle -6459832 true true 109 150 114 192 490 | Rectangle -6459832 true true 111 143 116 191 491 | Polygon -6459832 true true 168 106 184 98 205 98 218 115 218 137 186 164 196 176 195 194 178 195 178 183 188 183 169 164 173 144 492 | Polygon -6459832 true true 207 140 200 163 206 175 207 192 193 189 192 177 198 176 185 150 493 | Polygon -6459832 true true 214 134 203 168 192 148 494 | Polygon -6459832 true true 204 151 203 176 193 148 495 | Polygon -6459832 true true 207 103 221 98 236 101 243 115 243 128 256 142 239 143 233 133 225 115 214 114 496 | 497 | wolf-right 498 | false 499 | 3 500 | Polygon -6459832 true true 170 127 200 93 231 93 237 103 262 103 261 113 253 119 231 119 215 143 213 160 208 173 189 187 169 190 154 190 126 180 106 171 72 171 73 126 122 126 144 123 159 123 501 | Polygon -6459832 true true 201 99 214 69 215 99 502 | Polygon -6459832 true true 207 98 223 71 220 101 503 | Polygon -6459832 true true 184 172 189 234 203 238 203 246 187 247 180 239 171 180 504 | Polygon -6459832 true true 197 174 204 220 218 224 219 234 201 232 195 225 179 179 505 | Polygon -6459832 true true 78 167 95 187 95 208 79 220 92 234 98 235 100 249 81 246 76 241 61 212 65 195 52 170 45 150 44 128 55 121 69 121 81 135 506 | Polygon -6459832 true true 48 143 58 141 507 | Polygon -6459832 true true 46 136 68 137 508 | Polygon -6459832 true true 45 129 35 142 37 159 53 192 47 210 62 238 80 237 509 | Line -16777216 false 74 237 59 213 510 | Line -16777216 false 59 213 59 212 511 | Line -16777216 false 58 211 67 192 512 | Polygon -6459832 true true 38 138 66 149 513 | Polygon -6459832 true true 46 128 33 120 21 118 11 123 3 138 5 160 13 178 9 192 0 199 20 196 25 179 24 161 25 148 45 140 514 | Polygon -6459832 true true 67 122 96 126 63 144 515 | 516 | @#$#@#$#@ 517 | NetLogo 5.0beta2 518 | @#$#@#$#@ 519 | @#$#@#$#@ 520 | @#$#@#$#@ 521 | @#$#@#$#@ 522 | @#$#@#$#@ 523 | default 524 | 0.0 525 | -0.2 0 0.0 1.0 526 | 0.0 1 1.0 0.0 527 | 0.2 0 0.0 1.0 528 | link direction 529 | true 530 | 0 531 | Line -7500403 true 150 150 90 180 532 | Line -7500403 true 150 150 210 180 533 | 534 | @#$#@#$#@ 535 | 0 536 | @#$#@#$#@ 537 | -------------------------------------------------------------------------------- /coordination/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This is the binary coordination game. Each agent can be either red
29 | or blue. At each time step some of the agents change their color simultaneously.
30 | The goal is to find out how long it takes, under different conditions, for the
31 | population to converge to one color. This problem was presented in
Yoav Shoham and Moshe Tennenholtz. On the emergence of social conventions: modeling, analysis, and simulations. Artificial Intelligence, 94 (139--166) 1997.
36 |Jordi Delgado. Emergence of social conventions in complex networks. Artificial Intelligence, 141. p. 171--185, 2002.
39 |Jose M Vidal
20100623
41 | 42 | 43 | -------------------------------------------------------------------------------- /coordination/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/coordination/medium.png -------------------------------------------------------------------------------- /coordination/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/coordination/thumb.png -------------------------------------------------------------------------------- /distributedrec/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |A prototype implementation of a distributed recommender system as seen in
29 |Jose M Vidal
20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /distributedrec/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/distributedrec/medium.png -------------------------------------------------------------------------------- /distributedrec/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/distributedrec/thumb.png -------------------------------------------------------------------------------- /evolutionarygt/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |A visualization of a population of agents playing repeated games under the standard evolutionary game theory assumptions. We use a simplex to show how these populations evolve over time. Click the forever-go button and then click on the simplex to show how a population at that spot would evolve.
Jose M Vidal
20100623
29 | 30 | 31 | -------------------------------------------------------------------------------- /evolutionarygt/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/evolutionarygt/medium.png -------------------------------------------------------------------------------- /evolutionarygt/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/evolutionarygt/thumb.png -------------------------------------------------------------------------------- /find-coalition/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Solves a task allocation problem with the coalition formation algorithm from
29 |From the problem set description,
There are num-skills (slider) available to the agents. Each agent (there are num-agents of them) is born with a my-skills vector which contains a number between 0 a 1 for each one of these skills. These vectors represent how well the agent can perform each one of the skills.
There is also a breed of tasks, of which there are num-tasks. Each task has a requirements variable which is a vector of size num-skill where each entry is a number randomly chosen between 0 and max-need.
L is the list of all possible coalitions, and is found by each state adding the possible combinations of itself to the current sets in L, while pruning duplicates. Since each member of a coalition will add itself, the number of duplicates increases linearly as the coalition size increases. However, the code is direct and short.
Once this initialization takes place, the v(S) is calculated by each agent for its related coalitions, i.e. all possible coalitions it can be involved with, against each task. The v(S) are calculated during the find-coalition implementation instead of beforehand to cut down on global variables, since message-passing will take care of any agent's information needs.
find-coalition is executed after setup.
To visualize the algorithm, links indicate an association between an agent and a task. Tasks are in column formation on the right (Q1/Q4) hemisphere of the world; while, agents are arranged similarly on the left (Q2/Q3) hemisphere of the world.
Agents in the same coalition for a task will have the same color link connecting them to that specific task.
The requirements and my-skills vectors are displayed in the output window to the right of the world.
The tasks show their coalition solution as their label. The agents show their ID.
The trace toggle will allow you to view the find-coalition algorithm in a step-by-step basis. Expect alot of output for more than 3 agents or tasks.
If the max-need of the tasks is set above the number of agents, the problem becomes super-additive.
Setting the max-need above the number of agents.
Setting the mas-need to zero.
Performance analysis of the L constructor and find-coalition's max-arg (max-coalition in the implementation) for large agentsets. Possible future pruning and optimization in these areas
William Wiles
20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /find-coalition/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/find-coalition/medium.png -------------------------------------------------------------------------------- /find-coalition/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/find-coalition/thumb.png -------------------------------------------------------------------------------- /index.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |These are NetLogo models that demonstrate various well known 44 | MultiAgent algorithms and other related techniques. They have 45 | been developed by myself, my students, and 47 | others over the years.
48 |Many of these models implement algorithms described in detail 49 | in my free textbook Fundamentals of Multiagent 51 | Systems.
52 |If you need a consultant or just some help in building a 53 | NetLogo model for your research, let me know. Some of these 54 | models, and many others not shown here, are the results of 55 | collaborations with other researchers in various science and 56 | engineering disciplines.
57 |This is the classis MAS mailmen problem where a set of mailmen
29 | have to deliver a set of letters. Each letter must be delivered to
30 | a different place and mailmen can exchange letters. The goal is to
31 | minimize the total distance travelled by the mailmen. It is
32 | an instance of a distributed resource allocation problem. The solution
33 | provided here is only the most obvious. Better solutions are
34 | possible. AFAIK, there is no agreement on what is the best
35 | algorithm for solving this problem. This problem was first popularized in
Jose M Vidal
20100623
39 | 40 | 41 | -------------------------------------------------------------------------------- /mailmen/mailmen.nlogo: -------------------------------------------------------------------------------- 1 | ; Mailmen (letter delivery) simulation 2 | ; by Jose M. Vidal 3 | 4 | breed [ mailmen ] 5 | breed [ letters ] 6 | breed [ delivered-letters ] 7 | 8 | letters-own [destination-x destination-y carrier] 9 | mailmen-own [my-letters distance-travelled] 10 | 11 | to setup 12 | ;; (for this model to work with NetLogo's new plotting features, 13 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 14 | ;; the beginning of your setup procedure and reset-ticks at the end 15 | ;; of the procedure.) 16 | __clear-all-and-reset-ticks 17 | setup-mailmen 18 | setup-letters 19 | end 20 | 21 | to update 22 | if (not any? letters) [stop] 23 | ask mailmen [deliver-letters] 24 | plot total-distance-travelled 25 | end 26 | 27 | ;do not change 28 | to run-tests 29 | let dist 0 30 | let nr 0 31 | 32 | set nr 3 33 | set num-mailmen 1 34 | repeat 50 [ 35 | set dist 0 36 | repeat nr [ 37 | no-display 38 | ct 39 | setup-mailmen 40 | setup-letters 41 | while [any? letters][ 42 | ask mailmen [deliver-letters]] 43 | display 44 | set dist dist + total-distance-travelled] 45 | plot dist / nr 46 | set num-mailmen num-mailmen + 1 47 | ] 48 | end 49 | 50 | to-report get-random-xcor 51 | report (random world-width) + min-pxcor 52 | end 53 | 54 | to-report get-random-ycor 55 | report (random world-height) + min-pycor 56 | end 57 | 58 | 59 | to setup-mailmen 60 | set-default-shape mailmen "default" 61 | create-mailmen num-mailmen[ 62 | setxy get-random-xcor get-random-ycor ] 63 | end 64 | 65 | to setup-letters 66 | set-default-shape letters "box" 67 | set-default-shape delivered-letters "circle" 68 | create-letters num-letters [ 69 | setxy get-random-xcor get-random-ycor 70 | set carrier nobody 71 | set heading 0 72 | set destination-x get-random-xcor 73 | set destination-y get-random-ycor 74 | set color white] 75 | end 76 | 77 | to-report total-distance-travelled 78 | report sum ([distance-travelled] of mailmen ) 79 | end 80 | 81 | ;;;;;;;;;;;;;;;;; 82 | ;member functions of mailmen 83 | ;;;;;;;;;;;;;;;;; 84 | 85 | ;Each time its called it does 86 | ; if not carrying any letter then pick up the nearest one 87 | ; else drop the letter whose destination is closest to me. 88 | ; 89 | to deliver-letters 90 | let next-letter 0 91 | 92 | set my-letters letters with [carrier = [who] of myself] 93 | ifelse (any? my-letters) [ ;I am carrying some letters 94 | set next-letter (min-one-of my-letters [distancexy destination-x destination-y]) 95 | goto ([destination-x] of next-letter) ([destination-y] of next-letter) 96 | drop-letter next-letter] 97 | [ ;I am not carrying any letters. 98 | set next-letter (min-one-of (letters with [carrier = nobody]) [distance myself]) 99 | if next-letter = nobody [stop] ;there are no more letters! 100 | goto ([xcor] of next-letter) ([ycor] of next-letter) 101 | pickup-letters] 102 | end 103 | 104 | ;picks up all the letter here (in this patch) 105 | ;We need the without-interruption to prevent two mailmen from picking up the same letter. 106 | to pickup-letters 107 | let let-who 0 108 | 109 | without-interruption[ 110 | set let-who [who] of (letters-here with [carrier = nobody]) 111 | while [not empty? let-who][ 112 | ask (turtle first let-who) [ 113 | set carrier [who] of myself 114 | ] 115 | ;set [carrier] of (turtle first let-who) who 116 | set let-who butfirst let-who]] 117 | end 118 | 119 | ;drops "let" here. If let is at destination then change its breed to delivered-letters. 120 | to drop-letter [the-letter] 121 | print "drop-letter" 122 | ask the-letter [ 123 | set carrier nobody] 124 | ; set [carrier] of the-letter nobody 125 | if (([destination-x] of the-letter = (round xcor)) and ([destination-y] of the-letter = (round ycor))) [ 126 | ask the-letter[ 127 | set breed delivered-letters 128 | set color yellow] 129 | ] 130 | ; set [breed] of the-letter delivered-letters 131 | ; set [color] of the-letter yellow] 132 | set heading 0 ;set my heading to 0 so that I will appear "on top" of letter. 133 | end 134 | 135 | ;Moves the mailman to coordinates x,y, and his letters too 136 | ;Also updates the distance travelled. If you change this, make sure that the distance-travelled 137 | ;is updated correctly! 138 | to goto [x y] 139 | let steps 0 140 | 141 | set heading ifelse-value (distancexy x y < 1) [heading][towardsxy x y] ;I could have just setxy here, but this make for a more fun animation. 142 | set steps distancexy x y 143 | fd steps 144 | ask my-letters [ 145 | setxy ([xcor] of myself) ([ycor] of myself)] 146 | set distance-travelled (distance-travelled + steps) 147 | end 148 | @#$#@#$#@ 149 | GRAPHICS-WINDOW 150 | 261 151 | 13 152 | 586 153 | 359 154 | 17 155 | 17 156 | 9.0 157 | 1 158 | 10 159 | 1 160 | 1 161 | 1 162 | 0 163 | 1 164 | 1 165 | 1 166 | -17 167 | 17 168 | -17 169 | 17 170 | 0 171 | 0 172 | 1 173 | ticks 174 | 30.0 175 | 176 | BUTTON 177 | 8 178 | 46 179 | 89 180 | 79 181 | NIL 182 | setup 183 | NIL 184 | 1 185 | T 186 | OBSERVER 187 | NIL 188 | NIL 189 | NIL 190 | NIL 191 | 1 192 | 193 | BUTTON 194 | 89 195 | 46 196 | 179 197 | 79 198 | NIL 199 | update 200 | NIL 201 | 1 202 | T 203 | OBSERVER 204 | NIL 205 | NIL 206 | NIL 207 | NIL 208 | 1 209 | 210 | SLIDER 211 | 8 212 | 80 213 | 180 214 | 113 215 | num-mailmen 216 | num-mailmen 217 | 1 218 | 100 219 | 20 220 | 1 221 | 1 222 | NIL 223 | HORIZONTAL 224 | 225 | SLIDER 226 | 8 227 | 114 228 | 180 229 | 147 230 | num-letters 231 | num-letters 232 | 1 233 | 200 234 | 100 235 | 1 236 | 1 237 | NIL 238 | HORIZONTAL 239 | 240 | BUTTON 241 | 9 242 | 149 243 | 113 244 | 182 245 | NIL 246 | run-tests 247 | NIL 248 | 1 249 | T 250 | OBSERVER 251 | NIL 252 | NIL 253 | NIL 254 | NIL 255 | 1 256 | 257 | MONITOR 258 | 9 259 | 184 260 | 195 261 | 229 262 | NIL 263 | total-distance-travelled 264 | 0 265 | 1 266 | 11 267 | 268 | BUTTON 269 | 179 270 | 46 271 | 260 272 | 79 273 | update 274 | update 275 | T 276 | 1 277 | T 278 | OBSERVER 279 | NIL 280 | NIL 281 | NIL 282 | NIL 283 | 1 284 | 285 | PLOT 286 | 9 287 | 235 288 | 209 289 | 385 290 | Distance 291 | NIL 292 | NIL 293 | 0.0 294 | 10.0 295 | 0.0 296 | 10.0 297 | true 298 | false 299 | "" "" 300 | PENS 301 | "default" 1.0 0 -16777216 true "" "" 302 | 303 | @#$#@#$#@ 304 | # Mailmen 305 | 306 | ## WHAT IS IT? 307 | 308 | This is the classis MAS mailmen problem where a set of mailmen 309 | have to deliver a set of letters. Each letter must be delivered to 310 | a different place and mailmen can exchange letters. The goal is to 311 | minimize the total distance travelled by the mailmen. It is 312 | an instance of a distributed resource allocation problem. The solution 313 | provided here is only the most obvious. Better solutions are 314 | possible. AFAIK, there is no agreement on what is the best 315 | algorithm for solving this problem. This problem was first popularized in 316 | 317 | * Jeffrey S. Rosenschein and Gilad Zlotkin. [Rules of Encounter](http://www.amazon.com/exec/obidos/ASIN/0262181592/multiagentcom/). The MIT Press, Cambridge, MA, 1994. 318 | 319 | ## CREDITS 320 | 321 | Jose M Vidal 322 | 323 | ## CHANGES 324 | 325 | 20100623 326 | @#$#@#$#@ 327 | default 328 | true 329 | 0 330 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 331 | 332 | ant 333 | true 334 | 0 335 | Polygon -7500403 true true 136 61 129 46 144 30 119 45 124 60 114 82 97 37 132 10 93 36 111 84 127 105 172 105 189 84 208 35 171 11 202 35 204 37 186 82 177 60 180 44 159 32 170 44 165 60 336 | Polygon -7500403 true true 150 95 135 103 139 117 125 149 137 180 135 196 150 204 166 195 161 180 174 150 158 116 164 102 337 | Polygon -7500403 true true 149 186 128 197 114 232 134 270 149 282 166 270 185 232 171 195 149 186 338 | Polygon -7500403 true true 225 66 230 107 159 122 161 127 234 111 236 106 339 | Polygon -7500403 true true 78 58 99 116 139 123 137 128 95 119 340 | Polygon -7500403 true true 48 103 90 147 129 147 130 151 86 151 341 | Polygon -7500403 true true 65 224 92 171 134 160 135 164 95 175 342 | Polygon -7500403 true true 235 222 210 170 163 162 161 166 208 174 343 | Polygon -7500403 true true 249 107 211 147 168 147 168 150 213 150 344 | 345 | arrow 346 | true 347 | 0 348 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 349 | 350 | bee 351 | true 352 | 0 353 | Polygon -1184463 true false 151 152 137 77 105 67 89 67 66 74 48 85 36 100 24 116 14 134 0 151 15 167 22 182 40 206 58 220 82 226 105 226 134 222 354 | Polygon -16777216 true false 151 150 149 128 149 114 155 98 178 80 197 80 217 81 233 95 242 117 246 141 247 151 245 177 234 195 218 207 206 211 184 211 161 204 151 189 148 171 355 | Polygon -7500403 true true 246 151 241 119 240 96 250 81 261 78 275 87 282 103 277 115 287 121 299 150 286 180 277 189 283 197 281 210 270 222 256 222 243 212 242 192 356 | Polygon -16777216 true false 115 70 129 74 128 223 114 224 357 | Polygon -16777216 true false 89 67 74 71 74 224 89 225 89 67 358 | Polygon -16777216 true false 43 91 31 106 31 195 45 211 359 | Line -1 false 200 144 213 70 360 | Line -1 false 213 70 213 45 361 | Line -1 false 214 45 203 26 362 | Line -1 false 204 26 185 22 363 | Line -1 false 185 22 170 25 364 | Line -1 false 169 26 159 37 365 | Line -1 false 159 37 156 55 366 | Line -1 false 157 55 199 143 367 | Line -1 false 200 141 162 227 368 | Line -1 false 162 227 163 241 369 | Line -1 false 163 241 171 249 370 | Line -1 false 171 249 190 254 371 | Line -1 false 192 253 203 248 372 | Line -1 false 205 249 218 235 373 | Line -1 false 218 235 200 144 374 | 375 | bird1 376 | false 377 | 0 378 | Polygon -7500403 true true 2 6 2 39 270 298 297 298 299 271 187 160 279 75 276 22 100 67 31 0 379 | 380 | bird2 381 | false 382 | 0 383 | Polygon -7500403 true true 2 4 33 4 298 270 298 298 272 298 155 184 117 289 61 295 61 105 0 43 384 | 385 | boat1 386 | false 387 | 0 388 | Polygon -1 true false 63 162 90 207 223 207 290 162 389 | Rectangle -6459832 true false 150 32 157 162 390 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 391 | Polygon -7500403 true true 158 33 230 157 182 150 169 151 157 156 392 | Polygon -7500403 true true 149 55 88 143 103 139 111 136 117 139 126 145 130 147 139 147 146 146 149 55 393 | 394 | boat2 395 | false 396 | 0 397 | Polygon -1 true false 63 162 90 207 223 207 290 162 398 | Rectangle -6459832 true false 150 32 157 162 399 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 400 | Polygon -7500403 true true 157 54 175 79 174 96 185 102 178 112 194 124 196 131 190 139 192 146 211 151 216 154 157 154 401 | Polygon -7500403 true true 150 74 146 91 139 99 143 114 141 123 137 126 131 129 132 139 142 136 126 142 119 147 148 147 402 | 403 | boat3 404 | false 405 | 0 406 | Polygon -1 true false 63 162 90 207 223 207 290 162 407 | Rectangle -6459832 true false 150 32 157 162 408 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 409 | Polygon -7500403 true true 158 37 172 45 188 59 202 79 217 109 220 130 218 147 204 156 158 156 161 142 170 123 170 102 169 88 165 62 410 | Polygon -7500403 true true 149 66 142 78 139 96 141 111 146 139 148 147 110 147 113 131 118 106 126 71 411 | 412 | box 413 | true 414 | 0 415 | Polygon -7500403 true true 45 255 255 255 255 45 45 45 416 | 417 | butterfly1 418 | true 419 | 0 420 | Polygon -16777216 true false 151 76 138 91 138 284 150 296 162 286 162 91 421 | Polygon -7500403 true true 164 106 184 79 205 61 236 48 259 53 279 86 287 119 289 158 278 177 256 182 164 181 422 | Polygon -7500403 true true 136 110 119 82 110 71 85 61 59 48 36 56 17 88 6 115 2 147 15 178 134 178 423 | Polygon -7500403 true true 46 181 28 227 50 255 77 273 112 283 135 274 135 180 424 | Polygon -7500403 true true 165 185 254 184 272 224 255 251 236 267 191 283 164 276 425 | Line -7500403 true 167 47 159 82 426 | Line -7500403 true 136 47 145 81 427 | Circle -7500403 true true 165 45 8 428 | Circle -7500403 true true 134 45 6 429 | Circle -7500403 true true 133 44 7 430 | Circle -7500403 true true 133 43 8 431 | 432 | circle 433 | false 434 | 0 435 | Circle -7500403 true true 35 35 230 436 | 437 | person 438 | false 439 | 0 440 | Circle -7500403 true true 155 20 63 441 | Rectangle -7500403 true true 158 79 217 164 442 | Polygon -7500403 true true 158 81 110 129 131 143 158 109 165 110 443 | Polygon -7500403 true true 216 83 267 123 248 143 215 107 444 | Polygon -7500403 true true 167 163 145 234 183 234 183 163 445 | Polygon -7500403 true true 195 163 195 233 227 233 206 159 446 | 447 | spacecraft 448 | true 449 | 0 450 | Polygon -7500403 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 451 | 452 | thin-arrow 453 | true 454 | 0 455 | Polygon -7500403 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 456 | 457 | truck-down 458 | false 459 | 0 460 | Polygon -7500403 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 461 | Polygon -8630108 true false 195 75 195 120 240 120 240 75 462 | Polygon -8630108 true false 195 225 195 180 240 180 240 225 463 | 464 | truck-left 465 | false 466 | 0 467 | Polygon -7500403 true true 120 135 225 135 225 210 75 210 75 165 105 165 468 | Polygon -8630108 true false 90 210 105 225 120 210 469 | Polygon -8630108 true false 180 210 195 225 210 210 470 | 471 | truck-right 472 | false 473 | 0 474 | Polygon -7500403 true true 180 135 75 135 75 210 225 210 225 165 195 165 475 | Polygon -8630108 true false 210 210 195 225 180 210 476 | Polygon -8630108 true false 120 210 105 225 90 210 477 | 478 | turtle 479 | true 480 | 0 481 | Polygon -7500403 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 482 | 483 | wolf-left 484 | false 485 | 3 486 | Polygon -6459832 true true 117 97 91 74 66 74 60 85 36 85 38 92 44 97 62 97 81 117 84 134 92 147 109 152 136 144 174 144 174 103 143 103 134 97 487 | Polygon -6459832 true true 87 80 79 55 76 79 488 | Polygon -6459832 true true 81 75 70 58 73 82 489 | Polygon -6459832 true true 99 131 76 152 76 163 96 182 104 182 109 173 102 167 99 173 87 159 104 140 490 | Polygon -6459832 true true 107 138 107 186 98 190 99 196 112 196 115 190 491 | Polygon -6459832 true true 116 140 114 189 105 137 492 | Rectangle -6459832 true true 109 150 114 192 493 | Rectangle -6459832 true true 111 143 116 191 494 | Polygon -6459832 true true 168 106 184 98 205 98 218 115 218 137 186 164 196 176 195 194 178 195 178 183 188 183 169 164 173 144 495 | Polygon -6459832 true true 207 140 200 163 206 175 207 192 193 189 192 177 198 176 185 150 496 | Polygon -6459832 true true 214 134 203 168 192 148 497 | Polygon -6459832 true true 204 151 203 176 193 148 498 | Polygon -6459832 true true 207 103 221 98 236 101 243 115 243 128 256 142 239 143 233 133 225 115 214 114 499 | 500 | wolf-right 501 | false 502 | 3 503 | Polygon -6459832 true true 170 127 200 93 231 93 237 103 262 103 261 113 253 119 231 119 215 143 213 160 208 173 189 187 169 190 154 190 126 180 106 171 72 171 73 126 122 126 144 123 159 123 504 | Polygon -6459832 true true 201 99 214 69 215 99 505 | Polygon -6459832 true true 207 98 223 71 220 101 506 | Polygon -6459832 true true 184 172 189 234 203 238 203 246 187 247 180 239 171 180 507 | Polygon -6459832 true true 197 174 204 220 218 224 219 234 201 232 195 225 179 179 508 | Polygon -6459832 true true 78 167 95 187 95 208 79 220 92 234 98 235 100 249 81 246 76 241 61 212 65 195 52 170 45 150 44 128 55 121 69 121 81 135 509 | Polygon -6459832 true true 48 143 58 141 510 | Polygon -6459832 true true 46 136 68 137 511 | Polygon -6459832 true true 45 129 35 142 37 159 53 192 47 210 62 238 80 237 512 | Line -16777216 false 74 237 59 213 513 | Line -16777216 false 59 213 59 212 514 | Line -16777216 false 58 211 67 192 515 | Polygon -6459832 true true 38 138 66 149 516 | Polygon -6459832 true true 46 128 33 120 21 118 11 123 3 138 5 160 13 178 9 192 0 199 20 196 25 179 24 161 25 148 45 140 517 | Polygon -6459832 true true 67 122 96 126 63 144 518 | 519 | @#$#@#$#@ 520 | NetLogo 5.0beta2 521 | @#$#@#$#@ 522 | @#$#@#$#@ 523 | @#$#@#$#@ 524 | @#$#@#$#@ 525 | @#$#@#$#@ 526 | default 527 | 0.0 528 | -0.2 0 1.0 0.0 529 | 0.0 1 1.0 0.0 530 | 0.2 0 1.0 0.0 531 | link direction 532 | true 533 | 0 534 | Line -7500403 true 150 150 90 180 535 | Line -7500403 true 150 150 210 180 536 | 537 | @#$#@#$#@ 538 | 0 539 | @#$#@#$#@ 540 | -------------------------------------------------------------------------------- /mailmen/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/mailmen/medium.png -------------------------------------------------------------------------------- /mailmen/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/mailmen/thumb.png -------------------------------------------------------------------------------- /marriage-problem/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |There are 64 single men and 64 single women, all heterosexual its is presumed, who want to get married. Each one ranks all possible mates. The problem is how to find the set of marriages so that no two people (one man one woman) that are not married to each other do, in fact, prefer each other over their assigned partners.
The solution we implement is the deferred acceptance algorithm from
29 |In this model the woman are the pink circles and the men are blue (well, cyan). When a man connects to a woman (edge) it means he proposes to her. The numbers in the nodes represent the preference of that node for its partner. The algorithm works as follows
32 |When done, all women have one proposal which they accept and live happily ever after. The resulting marriages are stable.
The scatter plot shows the marriages that we find, where the x coordinate is the man's preference for the woman and the y coordinate is the woman's preference for the man (1 means her most preferred). Notice that even though women turn down men, the men do much better.
Jose M Vidal
20100623
35 | 36 | 37 | -------------------------------------------------------------------------------- /marriage-problem/marriage-problem.nlogo: -------------------------------------------------------------------------------- 1 | breed [men man] 2 | breed [women woman] 3 | 4 | men-own [preferences] 5 | women-own [preferences] 6 | 7 | to setup 8 | ;; (for this model to work with NetLogo's new plotting features, 9 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 10 | ;; the beginning of your setup procedure and reset-ticks at the end 11 | ;; of the procedure.) 12 | __clear-all-and-reset-ticks 13 | ask patches [set pcolor white] 14 | create-women 64 [ 15 | set heading 0 16 | set shape "circle" 17 | set color pink 18 | set label-color black 19 | set size 1.5 20 | setxy 3 + (((max-pxcor) / 8) * (who mod 8)) 3 + ((max-pycor) / 8) * (floor (who / 8)) 21 | ] 22 | let list-of-women sort women 23 | create-men 64 [ 24 | set preferences shuffle list-of-women 25 | set heading 0 26 | set shape "circle" 27 | set color cyan 28 | set label-color black 29 | set size 1.5 30 | setxy random-pxcor random-pycor 31 | ] 32 | let list-of-men sort men 33 | ask women [ 34 | set preferences shuffle list-of-men 35 | ] 36 | ask men [update-link] 37 | layout 38 | end 39 | 40 | ;Make it look pretty. Men move around the woman they point to. 41 | to layout 42 | no-display 43 | ask women [ 44 | let old-x xcor 45 | let old-y ycor 46 | layout-radial in-link-neighbors links self 47 | ask in-link-neighbors [ 48 | set heading towards myself 49 | forward 14.5 50 | set heading 0 51 | ] 52 | let dxm (xcor - old-x) 53 | let dym (ycor - old-y) 54 | ask in-link-neighbors [ 55 | setxy (xcor - dxm) (ycor - dym) 56 | ] 57 | setxy old-x old-y 58 | ] 59 | display 60 | end 61 | 62 | to go 63 | tick 64 | ifelse (ticks mod 2 = 0) [ 65 | ask men with [not any? my-out-links] [update-link] 66 | layout 67 | ][ 68 | ask women with [any? in-link-neighbors] [turn-down-proposals] 69 | ask women with [any? in-link-neighbors] [ 70 | let suitor one-of in-link-neighbors 71 | set label 1 + position suitor preferences 72 | ] 73 | ask men [ 74 | set label 64 - length preferences + 1 75 | ] 76 | set-current-plot "Matchings by Prefence" 77 | clear-plot 78 | ask links [ 79 | plotxy ([label] of end1) ([label] of end2) 80 | ] 81 | set-current-plot "Bachelors" 82 | plot count men with [not any? my-out-links] 83 | if (all? women [count my-in-links = 1]) [stop] 84 | ] 85 | end 86 | 87 | 88 | to update-link 89 | create-link-to first preferences 90 | end 91 | 92 | 93 | ;;women functions 94 | to turn-down-proposals 95 | let suitors sort-by [position ?1 preferences < position ?2 preferences] in-link-neighbors 96 | if (length suitors <= 1) [stop] 97 | foreach (butfirst suitors) [ 98 | ask ? [ 99 | ask my-out-links [die] 100 | set preferences butfirst preferences 101 | ] 102 | ] 103 | end 104 | @#$#@#$#@ 105 | GRAPHICS-WINDOW 106 | 205 107 | 10 108 | 625 109 | 451 110 | -1 111 | -1 112 | 10.0 113 | 1 114 | 10 115 | 1 116 | 1 117 | 1 118 | 0 119 | 1 120 | 1 121 | 1 122 | 0 123 | 40 124 | 0 125 | 40 126 | 0 127 | 0 128 | 1 129 | ticks 130 | 30.0 131 | 132 | BUTTON 133 | 3 134 | 12 135 | 72 136 | 45 137 | NIL 138 | setup 139 | NIL 140 | 1 141 | T 142 | OBSERVER 143 | NIL 144 | NIL 145 | NIL 146 | NIL 147 | 1 148 | 149 | BUTTON 150 | 75 151 | 12 152 | 138 153 | 45 154 | NIL 155 | go 156 | NIL 157 | 1 158 | T 159 | OBSERVER 160 | NIL 161 | NIL 162 | NIL 163 | NIL 164 | 1 165 | 166 | BUTTON 167 | 141 168 | 12 169 | 204 170 | 45 171 | NIL 172 | go 173 | T 174 | 1 175 | T 176 | OBSERVER 177 | NIL 178 | NIL 179 | NIL 180 | NIL 181 | 1 182 | 183 | PLOT 184 | 5 185 | 48 186 | 204 187 | 253 188 | Matchings by Prefence 189 | Men 190 | Women 191 | 0.0 192 | 64.0 193 | 0.0 194 | 64.0 195 | false 196 | false 197 | "" "" 198 | PENS 199 | "default" 1.0 2 -16777216 false "" "" 200 | 201 | PLOT 202 | 6 203 | 254 204 | 204 205 | 374 206 | Bachelors 207 | num bachelors 208 | NIL 209 | 0.0 210 | 10.0 211 | 0.0 212 | 10.0 213 | true 214 | false 215 | "" "" 216 | PENS 217 | "default" 1.0 0 -13345367 true "" "" 218 | 219 | @#$#@#$#@ 220 | # Marriage Problem 221 | 222 | ## WHAT IS IT? 223 | 224 | There are 64 single men and 64 single women, all heterosexual its is presumed, who want to get married. Each one ranks all possible mates. The problem is how to find the set of marriages so that no two people (one man one woman) that are not married to each other do, in fact, prefer each other over their assigned partners. 225 | 226 | The solution we implement is the deferred acceptance algorithm from 227 | 228 | * D. Gale and L. S. Shapley. [College Admissions and the Stability of Marriage](http://jmvidal.cse.sc.edu/lib/gale62a.html). _The American Mathematical Monthly,_ 69(1):9--15, Mathematical Association of America. 1962. 229 | 230 | In this model the woman are the pink circles and the men are blue (well, cyan). When a man connects to a woman (edge) it means he proposes to her. The numbers in the nodes represent the preference of that node for its partner. The algorithm works as follows 231 | 232 | 1. while there are women without a proposal 233 | 2. every man proposes to the his most preferred woman who has not rejected him 234 | 3. every woman with multiple proposals rejects all but the one she prefers the most 235 | 236 | When done, all women have one proposal which they accept and live happily ever after. The resulting marriages are stable. 237 | 238 | The scatter plot shows the marriages that we find, where the x coordinate is the man's preference for the woman and the y coordinate is the woman's preference for the man (1 means her most preferred). Notice that even though women turn down men, the men do much better. 239 | 240 | ## CREDITS 241 | 242 | Jose M Vidal 243 | 244 | ## CHANGES 245 | 246 | 20100623 247 | @#$#@#$#@ 248 | default 249 | true 250 | 0 251 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 252 | 253 | airplane 254 | true 255 | 0 256 | Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 257 | 258 | arrow 259 | true 260 | 0 261 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 262 | 263 | box 264 | false 265 | 0 266 | Polygon -7500403 true true 150 285 285 225 285 75 150 135 267 | Polygon -7500403 true true 150 135 15 75 150 15 285 75 268 | Polygon -7500403 true true 15 75 15 225 150 285 150 135 269 | Line -16777216 false 150 285 150 135 270 | Line -16777216 false 150 135 15 75 271 | Line -16777216 false 150 135 285 75 272 | 273 | bug 274 | true 275 | 0 276 | Circle -7500403 true true 96 182 108 277 | Circle -7500403 true true 110 127 80 278 | Circle -7500403 true true 110 75 80 279 | Line -7500403 true 150 100 80 30 280 | Line -7500403 true 150 100 220 30 281 | 282 | butterfly 283 | true 284 | 0 285 | Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 286 | Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 287 | Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 288 | Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 289 | Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 290 | Circle -16777216 true false 135 90 30 291 | Line -16777216 false 150 105 195 60 292 | Line -16777216 false 150 105 105 60 293 | 294 | car 295 | false 296 | 0 297 | Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 298 | Circle -16777216 true false 180 180 90 299 | Circle -16777216 true false 30 180 90 300 | Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 301 | Circle -7500403 true true 47 195 58 302 | Circle -7500403 true true 195 195 58 303 | 304 | circle 305 | false 306 | 0 307 | Circle -7500403 true true 0 0 300 308 | 309 | circle 2 310 | false 311 | 0 312 | Circle -7500403 true true 0 0 300 313 | Circle -16777216 true false 30 30 240 314 | 315 | cow 316 | false 317 | 0 318 | Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 319 | Polygon -7500403 true true 73 210 86 251 62 249 48 208 320 | Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 321 | 322 | cylinder 323 | false 324 | 0 325 | Circle -7500403 true true 0 0 300 326 | 327 | dot 328 | false 329 | 0 330 | Circle -7500403 true true 90 90 120 331 | 332 | face happy 333 | false 334 | 0 335 | Circle -7500403 true true 8 8 285 336 | Circle -16777216 true false 60 75 60 337 | Circle -16777216 true false 180 75 60 338 | Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 339 | 340 | face neutral 341 | false 342 | 0 343 | Circle -7500403 true true 8 7 285 344 | Circle -16777216 true false 60 75 60 345 | Circle -16777216 true false 180 75 60 346 | Rectangle -16777216 true false 60 195 240 225 347 | 348 | face sad 349 | false 350 | 0 351 | Circle -7500403 true true 8 8 285 352 | Circle -16777216 true false 60 75 60 353 | Circle -16777216 true false 180 75 60 354 | Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 355 | 356 | fish 357 | false 358 | 0 359 | Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 360 | Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 361 | Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 362 | Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 363 | Circle -16777216 true false 215 106 30 364 | 365 | flag 366 | false 367 | 0 368 | Rectangle -7500403 true true 60 15 75 300 369 | Polygon -7500403 true true 90 150 270 90 90 30 370 | Line -7500403 true 75 135 90 135 371 | Line -7500403 true 75 45 90 45 372 | 373 | flower 374 | false 375 | 0 376 | Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 377 | Circle -7500403 true true 85 132 38 378 | Circle -7500403 true true 130 147 38 379 | Circle -7500403 true true 192 85 38 380 | Circle -7500403 true true 85 40 38 381 | Circle -7500403 true true 177 40 38 382 | Circle -7500403 true true 177 132 38 383 | Circle -7500403 true true 70 85 38 384 | Circle -7500403 true true 130 25 38 385 | Circle -7500403 true true 96 51 108 386 | Circle -16777216 true false 113 68 74 387 | Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 388 | Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 389 | 390 | house 391 | false 392 | 0 393 | Rectangle -7500403 true true 45 120 255 285 394 | Rectangle -16777216 true false 120 210 180 285 395 | Polygon -7500403 true true 15 120 150 15 285 120 396 | Line -16777216 false 30 120 270 120 397 | 398 | leaf 399 | false 400 | 0 401 | Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 402 | Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 403 | 404 | line 405 | true 406 | 0 407 | Line -7500403 true 150 0 150 300 408 | 409 | line half 410 | true 411 | 0 412 | Line -7500403 true 150 0 150 150 413 | 414 | man 415 | false 416 | 0 417 | Circle -7500403 true true 110 5 80 418 | Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 419 | Rectangle -7500403 true true 127 79 172 94 420 | Polygon -7500403 true true 195 90 240 150 225 180 165 105 421 | Polygon -7500403 true true 105 90 60 150 75 180 135 105 422 | 423 | pentagon 424 | false 425 | 0 426 | Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 427 | 428 | person 429 | false 430 | 0 431 | Circle -7500403 true true 110 5 80 432 | Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 433 | Rectangle -7500403 true true 127 79 172 94 434 | Polygon -7500403 true true 195 90 240 150 225 180 165 105 435 | Polygon -7500403 true true 105 90 60 150 75 180 135 105 436 | 437 | plant 438 | false 439 | 0 440 | Rectangle -7500403 true true 135 90 165 300 441 | Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 442 | Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 443 | Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 444 | Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 445 | Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 446 | Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 447 | Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 448 | 449 | square 450 | false 451 | 0 452 | Rectangle -7500403 true true 30 30 270 270 453 | 454 | square 2 455 | false 456 | 0 457 | Rectangle -7500403 true true 30 30 270 270 458 | Rectangle -16777216 true false 60 60 240 240 459 | 460 | star 461 | false 462 | 0 463 | Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 464 | 465 | target 466 | false 467 | 0 468 | Circle -7500403 true true 0 0 300 469 | Circle -16777216 true false 30 30 240 470 | Circle -7500403 true true 60 60 180 471 | Circle -16777216 true false 90 90 120 472 | Circle -7500403 true true 120 120 60 473 | 474 | tree 475 | false 476 | 0 477 | Circle -7500403 true true 118 3 94 478 | Rectangle -6459832 true false 120 195 180 300 479 | Circle -7500403 true true 65 21 108 480 | Circle -7500403 true true 116 41 127 481 | Circle -7500403 true true 45 90 120 482 | Circle -7500403 true true 104 74 152 483 | 484 | triangle 485 | false 486 | 0 487 | Polygon -7500403 true true 150 30 15 255 285 255 488 | 489 | triangle 2 490 | false 491 | 0 492 | Polygon -7500403 true true 150 30 15 255 285 255 493 | Polygon -16777216 true false 151 99 225 223 75 224 494 | 495 | truck 496 | false 497 | 0 498 | Rectangle -7500403 true true 4 45 195 187 499 | Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 500 | Rectangle -1 true false 195 60 195 105 501 | Polygon -16777216 true false 238 112 252 141 219 141 218 112 502 | Circle -16777216 true false 234 174 42 503 | Rectangle -7500403 true true 181 185 214 194 504 | Circle -16777216 true false 144 174 42 505 | Circle -16777216 true false 24 174 42 506 | Circle -7500403 false true 24 174 42 507 | Circle -7500403 false true 144 174 42 508 | Circle -7500403 false true 234 174 42 509 | 510 | turtle 511 | true 512 | 0 513 | Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 514 | Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 515 | Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 516 | Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 517 | Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 518 | Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 519 | 520 | wheel 521 | false 522 | 0 523 | Circle -7500403 true true 3 3 294 524 | Circle -16777216 true false 30 30 240 525 | Line -7500403 true 150 285 150 15 526 | Line -7500403 true 15 150 285 150 527 | Circle -7500403 true true 120 120 60 528 | Line -7500403 true 216 40 79 269 529 | Line -7500403 true 40 84 269 221 530 | Line -7500403 true 40 216 269 79 531 | Line -7500403 true 84 40 221 269 532 | 533 | woman 534 | false 535 | 0 536 | Circle -7500403 true true 110 5 80 537 | Polygon -7500403 true true 105 90 120 135 75 270 105 270 135 270 150 270 165 270 195 270 225 270 180 135 195 90 538 | Rectangle -7500403 true true 127 79 172 94 539 | Polygon -7500403 true true 195 90 240 150 225 180 165 105 540 | Polygon -7500403 true true 105 90 60 150 75 180 135 105 541 | 542 | x 543 | false 544 | 0 545 | Polygon -7500403 true true 270 75 225 30 30 225 75 270 546 | Polygon -7500403 true true 30 75 75 30 270 225 225 270 547 | 548 | @#$#@#$#@ 549 | NetLogo 5.0beta2 550 | @#$#@#$#@ 551 | @#$#@#$#@ 552 | @#$#@#$#@ 553 | @#$#@#$#@ 554 | @#$#@#$#@ 555 | default 556 | 0.0 557 | -0.2 0 0.0 1.0 558 | 0.0 1 1.0 0.0 559 | 0.2 0 0.0 1.0 560 | link direction 561 | true 562 | 0 563 | Line -7500403 true 150 150 90 180 564 | Line -7500403 true 150 150 210 180 565 | 566 | @#$#@#$#@ 567 | 0 568 | @#$#@#$#@ 569 | -------------------------------------------------------------------------------- /marriage-problem/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/marriage-problem/medium.png -------------------------------------------------------------------------------- /marriage-problem/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/marriage-problem/thumb.png -------------------------------------------------------------------------------- /model.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |This program solves the n-queens problem using the Adopt algorith.
29 | The Adopt algorithm appears in
Jose M Vidal
20100623
33 | 34 | 35 | -------------------------------------------------------------------------------- /nqueens-adopt/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/nqueens-adopt/medium.png -------------------------------------------------------------------------------- /nqueens-adopt/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/nqueens-adopt/thumb.png -------------------------------------------------------------------------------- /nqueensawc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Rosa L. Zavala Gutierrez
This is the implementation of the Asynchronous Weak-Commitment Search for the n-queens problem.
It also shows the number of messages sent by each agent. It behaves different that the Adopt algorithm in which a few agents end up sending the great majority of the messages. Here, the messages sent are better distributed among the agents.
29 | 30 | 31 | -------------------------------------------------------------------------------- /nqueensawc/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/nqueensawc/medium.png -------------------------------------------------------------------------------- /nqueensawc/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/nqueensawc/thumb.png -------------------------------------------------------------------------------- /packages/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M Vidal
In the package delivery problem a the agents must deliver a set of packages from a central depot. The destinations lie along one of several spokes emaniting from the central depot. The agents can exchange packages only at the depot. The cost to an agent is proportional to the number of packages carried.
The optimal solution to this problem is to choose one agent to go on each spoke and deliver all the packages scheduled for it. However, this would require completely selfless agents. In this program we study the dynamics that emerege when using different populations of selfish, philantropic, reciprocal, and individual agents behave.
These results were first presented in
29 |Sandip Sen. Reciprocity: a foundational principle for promoting cooperative behavior among self-interested agents 33 | In Proceedings of the Second International Conference on Multiagent Systems, p.322--329, AAAI Press, Menlo Park, CA. 1996.
34 |Sandip Sen and Partha Sarathi Dutta. The evolution and stability of cooperative traits. In Proceedings of the First Intenational Joint Conference on Autonomous Agents and Multiagent Systems, pages 1114-1120. ACM Press, NY, NY, 2002.
37 |Sandip Sen. Believing others: Pros and cons. Artificial Intelligence, 142(2):179-203, December 2002.
40 |20100623
42 | 43 | 44 | -------------------------------------------------------------------------------- /packages/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/packages/medium.png -------------------------------------------------------------------------------- /packages/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/packages/thumb.png -------------------------------------------------------------------------------- /paretolearn/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M Vidal
Description: An implementation of conditional joint action learners (CJAL) in the prisoner's dilemma as described in:
29 |These agents reach the Pareto optimal (cooperate,cooperate) solution in repeated play.
20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /paretolearn/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/paretolearn/medium.png -------------------------------------------------------------------------------- /paretolearn/paretolearn.nlogo: -------------------------------------------------------------------------------- 1 | ;Pareto Learning 2 | ;by 3 | ;Jose M. Vidal 4 | 5 | globals [cooperate defect] 6 | 7 | breed [agents agent] 8 | 9 | ;n: two-dimensional list that contains the number of times whe have played each pair of actions 10 | ; item my-action (item his-action n) 11 | ;alpha is the learning rate 12 | ;action: the action the agent takes 13 | agents-own [n n-joint alpha epsilon action] 14 | 15 | to-report utility [my-action his-action] 16 | report item his-action (item my-action payoffs) 17 | end 18 | 19 | to setup 20 | ;; (for this model to work with NetLogo's new plotting features, 21 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 22 | ;; the beginning of your setup procedure and reset-ticks at the end 23 | ;; of the procedure.) 24 | __clear-all-and-reset-ticks 25 | clear-all-plots 26 | ask patches [set pcolor white] 27 | ; set payoffs [[3 0][5 1]] ;action 0 is cooperate, 1 is defect 28 | set cooperate 0 29 | set defect 1 30 | create-agents 2 [ 31 | set heading 0 32 | set color gray 33 | set size 2 34 | set epsilon exploration-rate 35 | set n [[1 1][1 1]] ;start all at 1 to avoid division by zero 36 | ] 37 | ask (agent 0) [ 38 | set xcor -5 39 | ] 40 | ask (agent 1) [ 41 | set xcor 5 42 | ] 43 | end 44 | 45 | to go 46 | tick 47 | ask agents [take-action] 48 | ask agents [ 49 | ; set alpha learning-rate ;in case the user changes it 50 | adapt 51 | ] 52 | ask (agent 0) [ 53 | set-current-plot "Expected Utility" 54 | let eucooperate get-expected-utility cooperate 55 | set-current-plot-pen "cooperation" 56 | plot eucooperate 57 | set-current-plot-pen "defection" 58 | let eudefect get-expected-utility defect 59 | plot eudefect 60 | set-current-plot "Actions" 61 | plotxy (ni defect - ni cooperate) ([ni cooperate - ni defect] of (agent 1)) 62 | set xcor 0 - (max-pxcor * eudefect / (eucooperate + eudefect)) 63 | ] 64 | ask (agent 1) [ 65 | let eucooperate get-expected-utility cooperate 66 | let eudefect get-expected-utility defect 67 | set xcor max-pxcor * eudefect / (eucooperate + eudefect) 68 | ] 69 | end 70 | 71 | ;;agent functions 72 | 73 | to-report nij [my-action his-action] 74 | report item my-action (item his-action n) 75 | end 76 | 77 | to-report ni [my-action] 78 | report (item my-action (item 0 n)) + (item my-action (item 1 n)) 79 | end 80 | 81 | to update-count [my-action his-action] 82 | let c nij my-action his-action 83 | set n replace-item his-action n (replace-item my-action (item his-action n) (c + 1)) 84 | end 85 | 86 | ;Equation (4) 87 | to-report get-expected-utility [my-action] 88 | report sum map [(utility my-action ?) * ( (nij my-action ?) / (ni my-action))] [0 1] 89 | end 90 | 91 | ;Returns an index in the range [0..length v] chosen stochastically---in proportion to the values of the items in v. 92 | to-report stochastic-choice [v] 93 | let r random-float sum v 94 | let index 0 95 | let base-prob 0 96 | repeat length v [ 97 | set base-prob base-prob + (item index v) 98 | if (r <= base-prob) [ report index] 99 | set index index + 1 100 | ] 101 | show "ERROR: stochastic-choice" 102 | end 103 | 104 | to take-action 105 | ifelse (ticks < 400) [ ;initial exploration rate of 400 106 | set action random 2 107 | ][ 108 | ;Following Definition 1 from the paper: "A JCAL learner is an agent i who at time t chooses an action a with a probability propotional to the expected utility" 109 | let Evector (map [get-expected-utility ?] [0 1]) 110 | ;set action stochastic-choice Evector 111 | 112 | ;Section 3.2 of the paper contradicts Definition 1 and says instead that the action chosen, with probability 1-epsilon, is the one that maximizes the agent's utility 113 | ; and with probability epsilon whe choose the other action 114 | let best-action position (max Evector) Evector 115 | ifelse (random-float 1 < 1 - epsilon) [ 116 | set action best-action 117 | ][ 118 | set action (best-action + 1) mod 2 119 | ] 120 | 121 | ] 122 | ifelse (action = 0) [ 123 | set color green ;cooperate 124 | ][ 125 | set color red ;defect 126 | ] 127 | end 128 | 129 | to adapt 130 | let his-action (first [action] of other agents) 131 | update-count action his-action 132 | ; let q-value qij action his-action 133 | ; update-q action his-action (q-value + alpha * ((utility action his-action) - q-value)) ;eq (6) 134 | end 135 | @#$#@#$#@ 136 | GRAPHICS-WINDOW 137 | 207 138 | 10 139 | 641 140 | 79 141 | 16 142 | 1 143 | 12.85 144 | 1 145 | 10 146 | 1 147 | 1 148 | 1 149 | 0 150 | 1 151 | 1 152 | 1 153 | -16 154 | 16 155 | -1 156 | 1 157 | 0 158 | 0 159 | 1 160 | ticks 161 | 30.0 162 | 163 | BUTTON 164 | 18 165 | 12 166 | 90 167 | 45 168 | NIL 169 | setup\n 170 | NIL 171 | 1 172 | T 173 | OBSERVER 174 | NIL 175 | NIL 176 | NIL 177 | NIL 178 | 1 179 | 180 | BUTTON 181 | 21 182 | 55 183 | 84 184 | 88 185 | NIL 186 | go 187 | NIL 188 | 1 189 | T 190 | OBSERVER 191 | NIL 192 | NIL 193 | NIL 194 | NIL 195 | 1 196 | 197 | BUTTON 198 | 93 199 | 55 200 | 156 201 | 88 202 | NIL 203 | go 204 | T 205 | 1 206 | T 207 | OBSERVER 208 | NIL 209 | NIL 210 | NIL 211 | NIL 212 | 1 213 | 214 | PLOT 215 | 210 216 | 93 217 | 638 218 | 426 219 | Expected Utility 220 | Iterations 221 | Expected Utility 222 | 0.0 223 | 1000.0 224 | 0.0 225 | 4.0 226 | true 227 | true 228 | "" "" 229 | PENS 230 | "cooperation" 1.0 0 -10899396 true "" "" 231 | "defection" 1.0 0 -2674135 true "" "" 232 | 233 | SLIDER 234 | 19 235 | 104 236 | 196 237 | 137 238 | exploration-rate 239 | exploration-rate 240 | 0 241 | 1 242 | 0 243 | .01 244 | 1 245 | NIL 246 | HORIZONTAL 247 | 248 | CHOOSER 249 | 18 250 | 152 251 | 156 252 | 197 253 | payoffs 254 | payoffs 255 | [[3 0] [5 1]] [[3 0] [5 2]] [[3 2] [4 1]] 256 | 0 257 | 258 | PLOT 259 | 6 260 | 208 261 | 208 262 | 376 263 | Actions 264 | NIL 265 | NIL 266 | 0.0 267 | 10.0 268 | 0.0 269 | 10.0 270 | true 271 | false 272 | "" "" 273 | PENS 274 | "default" 1.0 0 -13345367 true "" "" 275 | 276 | @#$#@#$#@ 277 | # Pareto Learning 278 | 279 | ## CREDITS 280 | 281 | Jose M Vidal 282 | 283 | ## WHAT IS IT? 284 | 285 | Description: An implementation of conditional joint action learners (CJAL) in the prisoner's dilemma as described in: 286 | 287 | * Dipyaman Banerjee and Sandip Sen. [Reaching pareto-optimality in prisoner's dilemma using conditional joint action learning](http://jmvidal.cse.sc.edu/lib/banerjee07a.html). _Autonomous Agents and Multi-Agent Systems,_ 15(1):91--108, Kluwer Academic Publishers. 2007. 288 | 289 | These agents reach the Pareto optimal (cooperate,cooperate) solution in repeated play. 290 | 291 | ## CHANGES 292 | 293 | 20100623 294 | @#$#@#$#@ 295 | default 296 | true 297 | 0 298 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 299 | 300 | airplane 301 | true 302 | 0 303 | Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 304 | 305 | arrow 306 | true 307 | 0 308 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 309 | 310 | box 311 | false 312 | 0 313 | Polygon -7500403 true true 150 285 285 225 285 75 150 135 314 | Polygon -7500403 true true 150 135 15 75 150 15 285 75 315 | Polygon -7500403 true true 15 75 15 225 150 285 150 135 316 | Line -16777216 false 150 285 150 135 317 | Line -16777216 false 150 135 15 75 318 | Line -16777216 false 150 135 285 75 319 | 320 | bug 321 | true 322 | 0 323 | Circle -7500403 true true 96 182 108 324 | Circle -7500403 true true 110 127 80 325 | Circle -7500403 true true 110 75 80 326 | Line -7500403 true 150 100 80 30 327 | Line -7500403 true 150 100 220 30 328 | 329 | butterfly 330 | true 331 | 0 332 | Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 333 | Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 334 | Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 335 | Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 336 | Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 337 | Circle -16777216 true false 135 90 30 338 | Line -16777216 false 150 105 195 60 339 | Line -16777216 false 150 105 105 60 340 | 341 | car 342 | false 343 | 0 344 | Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 345 | Circle -16777216 true false 180 180 90 346 | Circle -16777216 true false 30 180 90 347 | Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 348 | Circle -7500403 true true 47 195 58 349 | Circle -7500403 true true 195 195 58 350 | 351 | circle 352 | false 353 | 0 354 | Circle -7500403 true true 0 0 300 355 | 356 | circle 2 357 | false 358 | 0 359 | Circle -7500403 true true 0 0 300 360 | Circle -16777216 true false 30 30 240 361 | 362 | cow 363 | false 364 | 0 365 | Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 366 | Polygon -7500403 true true 73 210 86 251 62 249 48 208 367 | Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 368 | 369 | cylinder 370 | false 371 | 0 372 | Circle -7500403 true true 0 0 300 373 | 374 | dot 375 | false 376 | 0 377 | Circle -7500403 true true 90 90 120 378 | 379 | face happy 380 | false 381 | 0 382 | Circle -7500403 true true 8 8 285 383 | Circle -16777216 true false 60 75 60 384 | Circle -16777216 true false 180 75 60 385 | Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 386 | 387 | face neutral 388 | false 389 | 0 390 | Circle -7500403 true true 8 7 285 391 | Circle -16777216 true false 60 75 60 392 | Circle -16777216 true false 180 75 60 393 | Rectangle -16777216 true false 60 195 240 225 394 | 395 | face sad 396 | false 397 | 0 398 | Circle -7500403 true true 8 8 285 399 | Circle -16777216 true false 60 75 60 400 | Circle -16777216 true false 180 75 60 401 | Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 402 | 403 | fish 404 | false 405 | 0 406 | Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 407 | Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 408 | Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 409 | Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 410 | Circle -16777216 true false 215 106 30 411 | 412 | flag 413 | false 414 | 0 415 | Rectangle -7500403 true true 60 15 75 300 416 | Polygon -7500403 true true 90 150 270 90 90 30 417 | Line -7500403 true 75 135 90 135 418 | Line -7500403 true 75 45 90 45 419 | 420 | flower 421 | false 422 | 0 423 | Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 424 | Circle -7500403 true true 85 132 38 425 | Circle -7500403 true true 130 147 38 426 | Circle -7500403 true true 192 85 38 427 | Circle -7500403 true true 85 40 38 428 | Circle -7500403 true true 177 40 38 429 | Circle -7500403 true true 177 132 38 430 | Circle -7500403 true true 70 85 38 431 | Circle -7500403 true true 130 25 38 432 | Circle -7500403 true true 96 51 108 433 | Circle -16777216 true false 113 68 74 434 | Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 435 | Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 436 | 437 | house 438 | false 439 | 0 440 | Rectangle -7500403 true true 45 120 255 285 441 | Rectangle -16777216 true false 120 210 180 285 442 | Polygon -7500403 true true 15 120 150 15 285 120 443 | Line -16777216 false 30 120 270 120 444 | 445 | leaf 446 | false 447 | 0 448 | Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 449 | Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 450 | 451 | line 452 | true 453 | 0 454 | Line -7500403 true 150 0 150 300 455 | 456 | line half 457 | true 458 | 0 459 | Line -7500403 true 150 0 150 150 460 | 461 | pentagon 462 | false 463 | 0 464 | Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 465 | 466 | person 467 | false 468 | 0 469 | Circle -7500403 true true 110 5 80 470 | Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 471 | Rectangle -7500403 true true 127 79 172 94 472 | Polygon -7500403 true true 195 90 240 150 225 180 165 105 473 | Polygon -7500403 true true 105 90 60 150 75 180 135 105 474 | 475 | plant 476 | false 477 | 0 478 | Rectangle -7500403 true true 135 90 165 300 479 | Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 480 | Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 481 | Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 482 | Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 483 | Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 484 | Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 485 | Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 486 | 487 | square 488 | false 489 | 0 490 | Rectangle -7500403 true true 30 30 270 270 491 | 492 | square 2 493 | false 494 | 0 495 | Rectangle -7500403 true true 30 30 270 270 496 | Rectangle -16777216 true false 60 60 240 240 497 | 498 | star 499 | false 500 | 0 501 | Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 502 | 503 | target 504 | false 505 | 0 506 | Circle -7500403 true true 0 0 300 507 | Circle -16777216 true false 30 30 240 508 | Circle -7500403 true true 60 60 180 509 | Circle -16777216 true false 90 90 120 510 | Circle -7500403 true true 120 120 60 511 | 512 | tree 513 | false 514 | 0 515 | Circle -7500403 true true 118 3 94 516 | Rectangle -6459832 true false 120 195 180 300 517 | Circle -7500403 true true 65 21 108 518 | Circle -7500403 true true 116 41 127 519 | Circle -7500403 true true 45 90 120 520 | Circle -7500403 true true 104 74 152 521 | 522 | triangle 523 | false 524 | 0 525 | Polygon -7500403 true true 150 30 15 255 285 255 526 | 527 | triangle 2 528 | false 529 | 0 530 | Polygon -7500403 true true 150 30 15 255 285 255 531 | Polygon -16777216 true false 151 99 225 223 75 224 532 | 533 | truck 534 | false 535 | 0 536 | Rectangle -7500403 true true 4 45 195 187 537 | Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 538 | Rectangle -1 true false 195 60 195 105 539 | Polygon -16777216 true false 238 112 252 141 219 141 218 112 540 | Circle -16777216 true false 234 174 42 541 | Rectangle -7500403 true true 181 185 214 194 542 | Circle -16777216 true false 144 174 42 543 | Circle -16777216 true false 24 174 42 544 | Circle -7500403 false true 24 174 42 545 | Circle -7500403 false true 144 174 42 546 | Circle -7500403 false true 234 174 42 547 | 548 | turtle 549 | true 550 | 0 551 | Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 552 | Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 553 | Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 554 | Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 555 | Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 556 | Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 557 | 558 | wheel 559 | false 560 | 0 561 | Circle -7500403 true true 3 3 294 562 | Circle -16777216 true false 30 30 240 563 | Line -7500403 true 150 285 150 15 564 | Line -7500403 true 15 150 285 150 565 | Circle -7500403 true true 120 120 60 566 | Line -7500403 true 216 40 79 269 567 | Line -7500403 true 40 84 269 221 568 | Line -7500403 true 40 216 269 79 569 | Line -7500403 true 84 40 221 269 570 | 571 | x 572 | false 573 | 0 574 | Polygon -7500403 true true 270 75 225 30 30 225 75 270 575 | Polygon -7500403 true true 30 75 75 30 270 225 225 270 576 | 577 | @#$#@#$#@ 578 | NetLogo 5.0beta2 579 | @#$#@#$#@ 580 | @#$#@#$#@ 581 | @#$#@#$#@ 582 | @#$#@#$#@ 583 | @#$#@#$#@ 584 | default 585 | 0.0 586 | -0.2 0 0.0 1.0 587 | 0.0 1 1.0 0.0 588 | 0.2 0 0.0 1.0 589 | link direction 590 | true 591 | 0 592 | Line -7500403 true 150 150 90 180 593 | Line -7500403 true 150 150 210 180 594 | 595 | @#$#@#$#@ 596 | 0 597 | @#$#@#$#@ 598 | -------------------------------------------------------------------------------- /paretolearn/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/paretolearn/thumb.png -------------------------------------------------------------------------------- /path-finding/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M Vidal
In this problem a series of drones tries to find a path from the source
29 | to the target while staying away from the obstacles. They use pheromones.
30 | I tried to implement something similar to
20100623
34 | 35 | 36 | -------------------------------------------------------------------------------- /path-finding/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/path-finding/medium.png -------------------------------------------------------------------------------- /path-finding/path-finding.nlogo: -------------------------------------------------------------------------------- 1 | ; path-finding with pheronomes problem 2 | ; by 3 | ; Jose M Vidal 4 | 5 | breed [ ghosts ] 6 | breed [ targets ] 7 | breed [ hazards ] 8 | breed [ walkers ] 9 | 10 | 11 | ;There are 4 pheronomes. Their values range from 0-1. 12 | patches-own [target hazard to-target to-home] 13 | 14 | ;when wait-steps is 0 the walker can fd 1, these set it back to walker-speed. 15 | walkers-own [wait-steps steps hazards-hit] 16 | 17 | ;mode = "to-target" or "to-home" 18 | ghosts-own [mode steps drop-size] 19 | 20 | 21 | to-report get-random-xcor 22 | report (random world-width) + min-pxcor 23 | end 24 | 25 | to-report get-random-ycor 26 | report (random world-height) + min-pycor 27 | end 28 | 29 | to setup 30 | ;; (for this model to work with NetLogo's new plotting features, 31 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 32 | ;; the beginning of your setup procedure and reset-ticks at the end 33 | ;; of the procedure.) 34 | __clear-all-and-reset-ticks 35 | set-default-shape walkers "box" 36 | set-default-shape targets "circle" 37 | set-default-shape hazards "box" 38 | create-hazards num-hazards [ 39 | setxy get-random-xcor get-random-ycor 40 | set color orange 41 | set heading 0 42 | ask patch-here [ 43 | set hazard 10] 44 | ] 45 | create-targets num-targets [ 46 | setxy get-random-xcor get-random-ycor 47 | set color green 48 | ask patch-here [ 49 | set target 10 50 | ] 51 | ] 52 | create-walkers 1 [ 53 | set wait-steps walker-speed 54 | setxy get-random-xcor get-random-ycor 55 | set color magenta] 56 | end 57 | 58 | to update 59 | ask targets [go-targets] 60 | ask hazards [go-hazards] 61 | ask ghosts [find-target-or-home] 62 | ask walkers [move-to-target] 63 | diffuse target diffusion-rate / 100 64 | diffuse hazard diffusion-rate / 100 65 | diffuse to-target diffusion-rate / 100 66 | diffuse to-home diffusion-rate / 100 67 | ask patches [go-patches] 68 | 69 | if (first [at-target?] of walkers) [stop] 70 | end 71 | 72 | ;ghosts 73 | to find-target-or-home 74 | set steps steps + 1 75 | if (steps > ghosts-lifetime) [die] 76 | ifelse (mode = "to-target")[ ;;looking for the target 77 | if (any? targets-here) [ 78 | set mode "to-home" 79 | set color magenta 80 | set drop-size 20 81 | rt 180 82 | stop] 83 | set to-home (to-home + drop-size) 84 | set drop-size drop-size - 1 85 | if (drop-size < 1) [set drop-size 1] 86 | uphill target 87 | ; set heading uphill target ; or to-target 88 | ; fd 1 89 | ] 90 | [ 91 | if (any? walkers-here) [ ;were home 92 | die] 93 | set to-target (to-target + drop-size) 94 | set drop-size drop-size - 1 95 | if (drop-size < 1) [set drop-size 1] 96 | uphill-to-home 97 | fd 1 98 | ] 99 | end 100 | 101 | to uphill-to-home 102 | let ahead 0 103 | let scent-left 0 104 | let scent-right 0 105 | 106 | ;; sniff left and right, and go where the strongest smell is 107 | set ahead next-to-home 108 | rt 45 109 | set scent-right next-to-home 110 | lt 90 111 | set scent-left next-to-home 112 | rt 45 113 | if ((scent-right > ahead) or (scent-left > ahead)) 114 | [ ifelse (scent-right > scent-left) 115 | [ rt 45 ] 116 | [ lt 45 ] 117 | ] 118 | end 119 | 120 | to-report next-to-home ;; reports what the strength of chemical right in front of the ant is 121 | report [to-home] of patch-at dx dy 122 | end 123 | 124 | ;walkers 125 | to move-to-target 126 | if (wait-steps = 0)[ 127 | set wait-steps walker-speed 128 | set steps steps + 1 129 | uphill to-target 130 | ; set heading uphill to-target 131 | ; fd 1 132 | if (any? hazards-here) [ 133 | set hazards-hit hazards-hit + 1] 134 | ] 135 | set wait-steps wait-steps - 1 136 | if (count ghosts < max-num-ghosts) [ 137 | ask patch-here [ 138 | sprout 1 [ 139 | set breed ghosts 140 | set drop-size 20 141 | set mode "to-target" 142 | set color green 143 | fd 1]]] 144 | end 145 | 146 | to-report at-target? 147 | report any? targets-here 148 | end 149 | 150 | ;patches 151 | to go-patches 152 | set target target * (100 - evaporation-rate) / 100 153 | set hazard hazard * (100 - evaporation-rate) / 100 154 | set to-target to-target * (100 - evaporation-rate) / 100 155 | set to-home to-home * (100 - evaporation-rate) / 100 156 | if (show-target) [ 157 | set pcolor scale-color yellow target 0 1] 158 | if (show-hazard) [ 159 | set pcolor scale-color yellow hazard 0 1] 160 | if (show-to-home) [ 161 | set pcolor scale-color yellow to-home 0 1] 162 | if (show-to-target) [ 163 | set pcolor scale-color yellow to-target 0 1] 164 | end 165 | 166 | ;hazards 167 | to go-hazards 168 | set hazard hazard + 1 169 | end 170 | 171 | ;targets 172 | to go-targets 173 | set target target + 1 174 | end 175 | @#$#@#$#@ 176 | GRAPHICS-WINDOW 177 | 247 178 | 10 179 | 572 180 | 356 181 | 17 182 | 17 183 | 9.0 184 | 1 185 | 10 186 | 1 187 | 1 188 | 1 189 | 0 190 | 1 191 | 1 192 | 1 193 | -17 194 | 17 195 | -17 196 | 17 197 | 0 198 | 0 199 | 1 200 | ticks 201 | 30.0 202 | 203 | SLIDER 204 | 3 205 | 76 206 | 175 207 | 109 208 | num-targets 209 | num-targets 210 | 1 211 | 100 212 | 1 213 | 1 214 | 1 215 | NIL 216 | HORIZONTAL 217 | 218 | SLIDER 219 | 3 220 | 142 221 | 175 222 | 175 223 | walker-speed 224 | walker-speed 225 | 0 226 | 100 227 | 50 228 | 1 229 | 1 230 | NIL 231 | HORIZONTAL 232 | 233 | SLIDER 234 | 3 235 | 175 236 | 176 237 | 208 238 | max-num-ghosts 239 | max-num-ghosts 240 | 0 241 | 100 242 | 5 243 | 1 244 | 1 245 | NIL 246 | HORIZONTAL 247 | 248 | BUTTON 249 | 3 250 | 42 251 | 84 252 | 75 253 | NIL 254 | setup 255 | NIL 256 | 1 257 | T 258 | OBSERVER 259 | NIL 260 | NIL 261 | NIL 262 | NIL 263 | 1 264 | 265 | BUTTON 266 | 84 267 | 42 268 | 165 269 | 75 270 | NIL 271 | update 272 | NIL 273 | 1 274 | T 275 | OBSERVER 276 | NIL 277 | NIL 278 | NIL 279 | NIL 280 | 1 281 | 282 | BUTTON 283 | 165 284 | 42 285 | 246 286 | 75 287 | NIL 288 | update 289 | T 290 | 1 291 | T 292 | OBSERVER 293 | NIL 294 | NIL 295 | NIL 296 | NIL 297 | 1 298 | 299 | SLIDER 300 | 3 301 | 109 302 | 175 303 | 142 304 | num-hazards 305 | num-hazards 306 | 1 307 | 100 308 | 100 309 | 1 310 | 1 311 | NIL 312 | HORIZONTAL 313 | 314 | SLIDER 315 | 4 316 | 241 317 | 176 318 | 274 319 | diffusion-rate 320 | diffusion-rate 321 | 0 322 | 100 323 | 10 324 | 1 325 | 1 326 | NIL 327 | HORIZONTAL 328 | 329 | SLIDER 330 | 4 331 | 274 332 | 176 333 | 307 334 | evaporation-rate 335 | evaporation-rate 336 | 0 337 | 100 338 | 5 339 | 1 340 | 1 341 | NIL 342 | HORIZONTAL 343 | 344 | SWITCH 345 | 564 346 | 42 347 | 702 348 | 75 349 | show-target 350 | show-target 351 | 1 352 | 1 353 | -1000 354 | 355 | SWITCH 356 | 564 357 | 75 358 | 710 359 | 108 360 | show-hazard 361 | show-hazard 362 | 0 363 | 1 364 | -1000 365 | 366 | SWITCH 367 | 564 368 | 108 369 | 720 370 | 141 371 | show-to-home 372 | show-to-home 373 | 0 374 | 1 375 | -1000 376 | 377 | SWITCH 378 | 564 379 | 141 380 | 722 381 | 174 382 | show-to-target 383 | show-to-target 384 | 1 385 | 1 386 | -1000 387 | 388 | SLIDER 389 | 4 390 | 208 391 | 176 392 | 241 393 | ghosts-lifetime 394 | ghosts-lifetime 395 | 0 396 | 100 397 | 50 398 | 1 399 | 1 400 | NIL 401 | HORIZONTAL 402 | 403 | MONITOR 404 | 177 405 | 76 406 | 234 407 | 121 408 | steps 409 | [steps] of one-of walkers 410 | 0 411 | 1 412 | 11 413 | 414 | MONITOR 415 | 177 416 | 126 417 | 244 418 | 171 419 | hazards 420 | [hazards-hit] of one-of walkers 421 | 0 422 | 1 423 | 11 424 | 425 | @#$#@#$#@ 426 | # Path-Finding Using Pheromones 427 | ## CREDITS 428 | 429 | Jose M Vidal 430 | 431 | ## WHAT IS IT? 432 | 433 | In this problem a series of drones tries to find a path from the source 434 | to the target while staying away from the obstacles. They use pheromones. 435 | I tried to implement something similar to 436 | 437 | * H. Van Dyke Parunak, Sven Brueckner, and John Sauter. [Synthetic pheronome mechanisms for coordination of unmanned vehicles](http://jmvidal.cse.sc.edu/library/parunak02a.html) In _Proceedings of the First Intenational Joint Conference on Autonomous Agents and Multiagent Systems_, pages 448-450, Bologna, Italy, 2002. ACM Press, New York, NY. 438 | 439 | ## CHANGES 440 | 441 | 20100623 442 | @#$#@#$#@ 443 | default 444 | true 445 | 0 446 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 447 | 448 | ant 449 | true 450 | 0 451 | Polygon -7500403 true true 136 61 129 46 144 30 119 45 124 60 114 82 97 37 132 10 93 36 111 84 127 105 172 105 189 84 208 35 171 11 202 35 204 37 186 82 177 60 180 44 159 32 170 44 165 60 452 | Polygon -7500403 true true 150 95 135 103 139 117 125 149 137 180 135 196 150 204 166 195 161 180 174 150 158 116 164 102 453 | Polygon -7500403 true true 149 186 128 197 114 232 134 270 149 282 166 270 185 232 171 195 149 186 454 | Polygon -7500403 true true 225 66 230 107 159 122 161 127 234 111 236 106 455 | Polygon -7500403 true true 78 58 99 116 139 123 137 128 95 119 456 | Polygon -7500403 true true 48 103 90 147 129 147 130 151 86 151 457 | Polygon -7500403 true true 65 224 92 171 134 160 135 164 95 175 458 | Polygon -7500403 true true 235 222 210 170 163 162 161 166 208 174 459 | Polygon -7500403 true true 249 107 211 147 168 147 168 150 213 150 460 | 461 | arrow 462 | true 463 | 0 464 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 465 | 466 | bee 467 | true 468 | 0 469 | Polygon -1184463 true false 151 152 137 77 105 67 89 67 66 74 48 85 36 100 24 116 14 134 0 151 15 167 22 182 40 206 58 220 82 226 105 226 134 222 470 | Polygon -16777216 true false 151 150 149 128 149 114 155 98 178 80 197 80 217 81 233 95 242 117 246 141 247 151 245 177 234 195 218 207 206 211 184 211 161 204 151 189 148 171 471 | Polygon -7500403 true true 246 151 241 119 240 96 250 81 261 78 275 87 282 103 277 115 287 121 299 150 286 180 277 189 283 197 281 210 270 222 256 222 243 212 242 192 472 | Polygon -16777216 true false 115 70 129 74 128 223 114 224 473 | Polygon -16777216 true false 89 67 74 71 74 224 89 225 89 67 474 | Polygon -16777216 true false 43 91 31 106 31 195 45 211 475 | Line -1 false 200 144 213 70 476 | Line -1 false 213 70 213 45 477 | Line -1 false 214 45 203 26 478 | Line -1 false 204 26 185 22 479 | Line -1 false 185 22 170 25 480 | Line -1 false 169 26 159 37 481 | Line -1 false 159 37 156 55 482 | Line -1 false 157 55 199 143 483 | Line -1 false 200 141 162 227 484 | Line -1 false 162 227 163 241 485 | Line -1 false 163 241 171 249 486 | Line -1 false 171 249 190 254 487 | Line -1 false 192 253 203 248 488 | Line -1 false 205 249 218 235 489 | Line -1 false 218 235 200 144 490 | 491 | bird1 492 | false 493 | 0 494 | Polygon -7500403 true true 2 6 2 39 270 298 297 298 299 271 187 160 279 75 276 22 100 67 31 0 495 | 496 | bird2 497 | false 498 | 0 499 | Polygon -7500403 true true 2 4 33 4 298 270 298 298 272 298 155 184 117 289 61 295 61 105 0 43 500 | 501 | boat1 502 | false 503 | 0 504 | Polygon -1 true false 63 162 90 207 223 207 290 162 505 | Rectangle -6459832 true false 150 32 157 162 506 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 507 | Polygon -7500403 true true 158 33 230 157 182 150 169 151 157 156 508 | Polygon -7500403 true true 149 55 88 143 103 139 111 136 117 139 126 145 130 147 139 147 146 146 149 55 509 | 510 | boat2 511 | false 512 | 0 513 | Polygon -1 true false 63 162 90 207 223 207 290 162 514 | Rectangle -6459832 true false 150 32 157 162 515 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 516 | Polygon -7500403 true true 157 54 175 79 174 96 185 102 178 112 194 124 196 131 190 139 192 146 211 151 216 154 157 154 517 | Polygon -7500403 true true 150 74 146 91 139 99 143 114 141 123 137 126 131 129 132 139 142 136 126 142 119 147 148 147 518 | 519 | boat3 520 | false 521 | 0 522 | Polygon -1 true false 63 162 90 207 223 207 290 162 523 | Rectangle -6459832 true false 150 32 157 162 524 | Polygon -13345367 true false 150 34 131 49 145 47 147 48 149 49 525 | Polygon -7500403 true true 158 37 172 45 188 59 202 79 217 109 220 130 218 147 204 156 158 156 161 142 170 123 170 102 169 88 165 62 526 | Polygon -7500403 true true 149 66 142 78 139 96 141 111 146 139 148 147 110 147 113 131 118 106 126 71 527 | 528 | box 529 | true 530 | 0 531 | Polygon -7500403 true true 45 255 255 255 255 45 45 45 532 | 533 | butterfly1 534 | true 535 | 0 536 | Polygon -16777216 true false 151 76 138 91 138 284 150 296 162 286 162 91 537 | Polygon -7500403 true true 164 106 184 79 205 61 236 48 259 53 279 86 287 119 289 158 278 177 256 182 164 181 538 | Polygon -7500403 true true 136 110 119 82 110 71 85 61 59 48 36 56 17 88 6 115 2 147 15 178 134 178 539 | Polygon -7500403 true true 46 181 28 227 50 255 77 273 112 283 135 274 135 180 540 | Polygon -7500403 true true 165 185 254 184 272 224 255 251 236 267 191 283 164 276 541 | Line -7500403 true 167 47 159 82 542 | Line -7500403 true 136 47 145 81 543 | Circle -7500403 true true 165 45 8 544 | Circle -7500403 true true 134 45 6 545 | Circle -7500403 true true 133 44 7 546 | Circle -7500403 true true 133 43 8 547 | 548 | circle 549 | false 550 | 0 551 | Circle -7500403 true true 35 35 230 552 | 553 | person 554 | false 555 | 0 556 | Circle -7500403 true true 155 20 63 557 | Rectangle -7500403 true true 158 79 217 164 558 | Polygon -7500403 true true 158 81 110 129 131 143 158 109 165 110 559 | Polygon -7500403 true true 216 83 267 123 248 143 215 107 560 | Polygon -7500403 true true 167 163 145 234 183 234 183 163 561 | Polygon -7500403 true true 195 163 195 233 227 233 206 159 562 | 563 | spacecraft 564 | true 565 | 0 566 | Polygon -7500403 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 567 | 568 | thin-arrow 569 | true 570 | 0 571 | Polygon -7500403 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 572 | 573 | truck-down 574 | false 575 | 0 576 | Polygon -7500403 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 577 | Polygon -8630108 true false 195 75 195 120 240 120 240 75 578 | Polygon -8630108 true false 195 225 195 180 240 180 240 225 579 | 580 | truck-left 581 | false 582 | 0 583 | Polygon -7500403 true true 120 135 225 135 225 210 75 210 75 165 105 165 584 | Polygon -8630108 true false 90 210 105 225 120 210 585 | Polygon -8630108 true false 180 210 195 225 210 210 586 | 587 | truck-right 588 | false 589 | 0 590 | Polygon -7500403 true true 180 135 75 135 75 210 225 210 225 165 195 165 591 | Polygon -8630108 true false 210 210 195 225 180 210 592 | Polygon -8630108 true false 120 210 105 225 90 210 593 | 594 | turtle 595 | true 596 | 0 597 | Polygon -7500403 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 598 | 599 | wolf-left 600 | false 601 | 3 602 | Polygon -6459832 true true 117 97 91 74 66 74 60 85 36 85 38 92 44 97 62 97 81 117 84 134 92 147 109 152 136 144 174 144 174 103 143 103 134 97 603 | Polygon -6459832 true true 87 80 79 55 76 79 604 | Polygon -6459832 true true 81 75 70 58 73 82 605 | Polygon -6459832 true true 99 131 76 152 76 163 96 182 104 182 109 173 102 167 99 173 87 159 104 140 606 | Polygon -6459832 true true 107 138 107 186 98 190 99 196 112 196 115 190 607 | Polygon -6459832 true true 116 140 114 189 105 137 608 | Rectangle -6459832 true true 109 150 114 192 609 | Rectangle -6459832 true true 111 143 116 191 610 | Polygon -6459832 true true 168 106 184 98 205 98 218 115 218 137 186 164 196 176 195 194 178 195 178 183 188 183 169 164 173 144 611 | Polygon -6459832 true true 207 140 200 163 206 175 207 192 193 189 192 177 198 176 185 150 612 | Polygon -6459832 true true 214 134 203 168 192 148 613 | Polygon -6459832 true true 204 151 203 176 193 148 614 | Polygon -6459832 true true 207 103 221 98 236 101 243 115 243 128 256 142 239 143 233 133 225 115 214 114 615 | 616 | wolf-right 617 | false 618 | 3 619 | Polygon -6459832 true true 170 127 200 93 231 93 237 103 262 103 261 113 253 119 231 119 215 143 213 160 208 173 189 187 169 190 154 190 126 180 106 171 72 171 73 126 122 126 144 123 159 123 620 | Polygon -6459832 true true 201 99 214 69 215 99 621 | Polygon -6459832 true true 207 98 223 71 220 101 622 | Polygon -6459832 true true 184 172 189 234 203 238 203 246 187 247 180 239 171 180 623 | Polygon -6459832 true true 197 174 204 220 218 224 219 234 201 232 195 225 179 179 624 | Polygon -6459832 true true 78 167 95 187 95 208 79 220 92 234 98 235 100 249 81 246 76 241 61 212 65 195 52 170 45 150 44 128 55 121 69 121 81 135 625 | Polygon -6459832 true true 48 143 58 141 626 | Polygon -6459832 true true 46 136 68 137 627 | Polygon -6459832 true true 45 129 35 142 37 159 53 192 47 210 62 238 80 237 628 | Line -16777216 false 74 237 59 213 629 | Line -16777216 false 59 213 59 212 630 | Line -16777216 false 58 211 67 192 631 | Polygon -6459832 true true 38 138 66 149 632 | Polygon -6459832 true true 46 128 33 120 21 118 11 123 3 138 5 160 13 178 9 192 0 199 20 196 25 179 24 161 25 148 45 140 633 | Polygon -6459832 true true 67 122 96 126 63 144 634 | 635 | @#$#@#$#@ 636 | NetLogo 5.0beta2 637 | @#$#@#$#@ 638 | @#$#@#$#@ 639 | @#$#@#$#@ 640 | @#$#@#$#@ 641 | @#$#@#$#@ 642 | default 643 | 0.0 644 | -0.2 0 1.0 0.0 645 | 0.0 1 1.0 0.0 646 | 0.2 0 1.0 0.0 647 | link direction 648 | true 649 | 0 650 | Line -7500403 true 150 150 90 180 651 | Line -7500403 true 150 150 210 180 652 | 653 | @#$#@#$#@ 654 | 0 655 | @#$#@#$#@ 656 | -------------------------------------------------------------------------------- /path-finding/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/path-finding/thumb.png -------------------------------------------------------------------------------- /port/NetLogoLite.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/port/NetLogoLite.jar -------------------------------------------------------------------------------- /port/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |A simulation of a container port. We model the movement of the cranes using various utility functions to determine what is the best behavior for the crane operators. The trucks have random arrival times. More details can be found at
29 |Nathan Huynh and Jose M. Vidal. An Agent-Based Approach to Modeling Yard Cranes at Seaport Container Terminals. In Proceedings of the Symposium on Theory of Modeling and Simulation, 2010.
33 |Jose M Vidal and Nathan Huynh. Building Agent-Based Models of Seaport Container Terminals. In Proceedings of 6th Workshop on Agents in Traffic and Transportation, 2010.
36 |Jose M Vidal and Nathan Huynh
20110303
Last change.
38 | 39 | 40 | -------------------------------------------------------------------------------- /port/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/port/medium.png -------------------------------------------------------------------------------- /port/port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/port/port.png -------------------------------------------------------------------------------- /port/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/port/thumb.png -------------------------------------------------------------------------------- /qlearning/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Seang Chan Ryu
An implementation of the Q-learning algorithm for a simple path-finding domain.
29 |20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /qlearning/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/qlearning/medium.png -------------------------------------------------------------------------------- /qlearning/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/qlearning/thumb.png -------------------------------------------------------------------------------- /replicator/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Scott Langevin
A visualization of the dynamics of a populations of agents using replicator dynamics. The players are of one of three types, each type playing a pure strategy in a 3x3 game. The user can change the payoffs of the game (but this still needs some work, we also need to add arrow that show direction. You interested?). The results are displayes in a simplex plot where each corner corresponds to one of the strategies. Dark areas correspond to fast movement of the population while lite areas represent slow movement.
20100623
29 | 30 | 31 | -------------------------------------------------------------------------------- /replicator/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/replicator/medium.png -------------------------------------------------------------------------------- /replicator/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/replicator/thumb.png -------------------------------------------------------------------------------- /shapebugs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Matt Baker
This is an implementation of the Shapebugs algorithm from
29 |My program begins (via the setup button) by randomly dispersing the agents throughout the display. All agents start in the lost state and assume that they are outside of the desired shape. An agent inside the shape is assumed to have been found.
Each agent's movement is as follows:
32 |Agent colors:
35 | * A red agent is an agent outside of the desired shape
36 | * A blue agent is an agent inside of the desired shape
37 | * A green agent is an agent that has been displaced
Agents can be added or removed dynamically via the slider. The shake button chooses a random square from the screen and moves all agents within that square in random directions away from their starting positions.
Note: I found that using 1,000+ agents seems to work best for modeling the shape.
20100623
38 | 39 | 40 | -------------------------------------------------------------------------------- /shapebugs/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/shapebugs/medium.png -------------------------------------------------------------------------------- /shapebugs/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/shapebugs/thumb.png -------------------------------------------------------------------------------- /sns/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M Vidal
This model shows how various supply-chain network topologies fare under attack. The original model was developed to study the military's supply chain vulnerability to terrorist or military attacks, part of the Ultralog project.
29 |20100623
32 | 33 | 34 | -------------------------------------------------------------------------------- /sns/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/sns/medium.png -------------------------------------------------------------------------------- /sns/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/sns/thumb.png -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial,Helvetica,Sans-serif; 3 | font-size: 13px; 4 | } 5 | a { 6 | color: #900; 7 | text-decoration: none; 8 | } 9 | 10 | #page{ 11 | width: 960px; 12 | padding: 0; 13 | position:relative; 14 | margin: 0px auto; 15 | } 16 | 17 | #header { 18 | height: 38px; 19 | display: block; 20 | padding: 21px 0; 21 | position: relative; 22 | } 23 | 24 | #header ul#nav { 25 | width: 670px; 26 | float: left; 27 | line-height: 35px; 28 | } 29 | 30 | #header ul#nav li { 31 | margin-right: 20px; 32 | display: inline; 33 | } 34 | 35 | #header ul#nav li a { 36 | font-size: 14px; 37 | } 38 | 39 | #header ul#nav li a.active { 40 | color: #FFF; 41 | text-decoration: underline; 42 | font-weight: bold; 43 | } 44 | 45 | #header ul#nav a:hover { 46 | text-decoration: none; 47 | } 48 | 49 | #header ul#nav li select{ 50 | display:inline; 51 | } 52 | 53 | #header h4#title { 54 | position: absolute; 55 | right: 2px; 56 | font-size: 22px; 57 | text-align: right; 58 | line-height: 24px; 59 | } 60 | #header h4#title span#tagline { 61 | display: block; 62 | font-size: 12px; 63 | line-height: 18px; 64 | } 65 | 66 | #grid { 67 | overflow: hidden; 68 | width: 962px; 69 | padding-bottom: 100px; 70 | padding-top: 10px; 71 | position:relative; 72 | margin: 0px auto; 73 | } 74 | 75 | div.model { 76 | height: 70px; 77 | width: 282px; 78 | float: left; 79 | line-height: 14px; 80 | margin: 15px 0 18px 0; 81 | padding-left: 35px; 82 | } 83 | 84 | 85 | div.model div.thumbHolder { 86 | line-height:70px; 87 | float:left; 88 | width:90px; 89 | height: 90px; 90 | overflow: hidden; 91 | margin-bottom: 5px; 92 | text-align:center; 93 | margin-right: 12px; 94 | } 95 | 96 | div.model h4 { 97 | font-size: 14px; 98 | font-weight: normal; 99 | margin: 0; 100 | } 101 | 102 | div.model h5 { 103 | font-weight: normal; 104 | margin: 0; 105 | } 106 | div.model h5 p, div.model h4 p{ 107 | margin: 0; 108 | } 109 | 110 | 111 | #featuredSection { 112 | background-color: #fcfcfc; 113 | height: 319px; 114 | padding: 20px 0; 115 | font-size: 13px; 116 | position: relative; 117 | overflow: hidden; 118 | width: 962px; 119 | } 120 | 121 | #featuredSection div.last { 122 | padding-right: 0; 123 | } 124 | 125 | #featuredSection .featuredImage { 126 | height: 209px; 127 | line-height:209px; 128 | overflow: hidden; 129 | margin-bottom: 8px; 130 | border: 1px solid #1c1c1c; 131 | text-align:center; 132 | } 133 | #featuredSection .featuredImage a { 134 | margin:auto; 135 | width: 280px; 136 | display:block; 137 | line-height:209px; 138 | text-decoration: none; 139 | float:left; 140 | } 141 | 142 | 143 | #featuredSection .featuredImage a img{ 144 | vertical-align:middle; 145 | width: 280px; 146 | } 147 | #featuredVideo { 148 | padding-top: 9px; 149 | position: relative; 150 | } 151 | 152 | #featuredSection img.header { 153 | position: absolute; 154 | top: 30px; 155 | overflow: hidden; 156 | height: 319px; 157 | margin-left: 30px; 158 | } 159 | 160 | #featuredVideo dt, 161 | #featuredVideo dd {float: right; margin-left: 500px; position: relative; text-align: left; width: 425px; margin-right: 20px;} 162 | #featuredVideo dt { font-size: 18px; margin-bottom: 20px; padding-top: 40px; } 163 | #featuredVideo dt a { color: #900; text-decoration: none; -moz-transition: all 0.3s ease-in-out; -webkit-transition: all 0.3s ease-in-out; } 164 | #featuredVideo dt a:hover { color: #F00; text-decoration: underline; -moz-transition: all 0.3s ease-in-out; -webkit-transition: all 0.3s ease-in-out; } 165 | a:hover { color: #F00; text-decoration: underline; -moz-transition: all 0.3s ease-in-out; -webkit-transition: all 0.3s ease-in-out; } 166 | 167 | #featuredVideo dd { color: #222; font-size: 13px; line-height: 20px; } 168 | #featuredVideo a { color: #111; } 169 | 170 | .description { 171 | display: none; 172 | padding: 1px 1px; 173 | position:absolute; 174 | border:1px solid #cccccc; 175 | width: auto; 176 | height: auto; 177 | overflow: hidden; 178 | z-index:10; 179 | background:#fff; 180 | font-size: 10px; 181 | line-height: 12px; 182 | margin-top: 40px; 183 | } 184 | 185 | a#download { 186 | background-color: #009ed9; 187 | color: #fff; 188 | cursor: pointer; 189 | display: inline-block; 190 | float: right; 191 | font-family: Helvetica, Arial, sans-serif; 192 | font-size: 19px; 193 | margin-top: 27px; 194 | padding: 0 50px; 195 | line-height: 42px; 196 | height: 40px; 197 | text-decoration: none; 198 | -moz-border-radius: 5px; 199 | -webkit-border-radius: 5px; 200 | -webkit-transition: all 0.3s ease-in-out; 201 | } 202 | 203 | a#download:hover, 204 | #featured_experiment a#launch:hover { 205 | background-color: #18b0e9; 206 | -webkit-transition: all 0.3s ease-in-out; 207 | } 208 | 209 | a#download { background: #009ed9 url(/img/bg_arrow.png) 193px center no-repeat; padding-right: 40px; } 210 | 211 | #aboutText { 212 | display: none; 213 | font-size: 13px; 214 | margin: 30px; 215 | } 216 | 217 | a.download:hover { 218 | background-color: #18b0e9; 219 | } 220 | 221 | a.download { 222 | text-align:center; 223 | padding-left: 5px; 224 | padding-right: 5px; 225 | font-size: 16px; 226 | font-weight: bold;} -------------------------------------------------------------------------------- /tileworld/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M Vidal
This is the classic tileworld problem. There are empty holes and tiles.
29 | The agents must push the tiles so that they cover the empty holes. Agents
30 | can push each other or more than one tile at once. The solution implemented
31 | here is the obvious one. AFAIK, there is no consensus on what is the
32 | best algorithm for solving this problem. The Tileworld was first introduced in
20100623
37 | 38 | 39 | -------------------------------------------------------------------------------- /tileworld/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/tileworld/medium.png -------------------------------------------------------------------------------- /tileworld/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/tileworld/thumb.png -------------------------------------------------------------------------------- /top-trading-cycle/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Jose M Vidal
In this problem every node represents an agent with a house that he wants to trade. Every agent has an ordered preference of the other agents' houses he prefers (this list includes the agent's own house). The trick then is to get all agents to trade houses so that they all end up in a house that is at least as good, in their eyes, as the one they currently have.
The Top Trading Cycle Algorithm (TTCA) solves this problem using a very simple greedy method. It was first proposed in:
29 |The algorithm is:
32 | while there are agents in the game
33 | --each agent points to the one it prefers most
34 | --all agents that are in a loop drop out of the game
35 |
In this animation the blue nodes are the ones that have not traded and the green nodes have already traded. Once a trade cycle is found all the links in the cycle turn black. The edges represent an agent's most preferred house where a node with no edge prefers its own house. As the algorithm runs the nodes adjust their edges in case their most preferred node turns green.
TTCA is guaranteed to find a solution, and that solution is in the core. That is, there is no subset of agents that could deviate from this solution and everyone one of them receive a house that they like better than the one the got under TTCA.
I have extended the basic algorithm with a distributed method for identifying cycles. In this program each agent only talks to the one it prefers the most. Of course, if the one it prefers most drops out of the game then the agent talks to the his next most prefered agent that is still in the game. This implementation cheats in that the agents do know the total number of other agents that are blue.
20100623
36 | 37 | 38 | -------------------------------------------------------------------------------- /top-trading-cycle/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/top-trading-cycle/medium.png -------------------------------------------------------------------------------- /top-trading-cycle/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/top-trading-cycle/thumb.png -------------------------------------------------------------------------------- /top-trading-cycle/top-trading-cycle.nlogo: -------------------------------------------------------------------------------- 1 | ;TTCA 2 | ;by Jose M Vidal 3 | breed [agents agent] 4 | 5 | ;preferences - list of agents in order of preference: (first preferences) is the agent that owns the house I like best, and so on. 6 | ;reach-me-agents - list of who of agents that can reach me 7 | ;color - blue agents are in the game, green agents have already found a trade (cycle). 8 | agents-own [preferences reach-me-agents] 9 | 10 | ;cycle-steps - number of steps left before we end the cycle. When it reaches 0 agents that are still blue will re-align their edges to point to another blue agent. 11 | globals [cycle-steps] 12 | 13 | 14 | to setup 15 | ;; (for this model to work with NetLogo's new plotting features, 16 | ;; __clear-all-and-reset-ticks should be replaced with clear-all at 17 | ;; the beginning of your setup procedure and reset-ticks at the end 18 | ;; of the procedure.) 19 | __clear-all-and-reset-ticks 20 | ask patches [set pcolor white] 21 | create-agents num-agents [ 22 | set color blue 23 | set shape "circle" 24 | set label-color black 25 | set size 1.2 26 | ] 27 | let all-agents sort agents 28 | ask agents [ 29 | set preferences shuffle all-agents 30 | ] 31 | ask agents [ 32 | setup-link 33 | ] 34 | repeat 50 [ 35 | layout-spring agents links 0.2 5 1] 36 | set cycle-steps count agents 37 | end 38 | 39 | to go 40 | if (cycle-steps = 0) [stop] ;all done 41 | tick 42 | layout 43 | ask agents [ 44 | send-message ] 45 | ask agents [ ;if I can reach myself, I drop out 46 | if (member? who reach-me-agents) [ 47 | set color green 48 | set label num-agents - length preferences + 1 49 | ] 50 | ] 51 | set cycle-steps (cycle-steps - 1) 52 | if (cycle-steps = 0) [;end of cycle, time for agents to re-set their most preferred 53 | ask links with [[color] of end2 = green][ ;links that point to green agents are set to black 54 | set color black 55 | ] 56 | histogram [num-agents - length preferences + 1] of (agents with [color = green]) 57 | set cycle-steps count (agents with [color = blue]) 58 | ask agents with [color = blue][ 59 | setup-link 60 | ] 61 | ] 62 | end 63 | 64 | to-report closest-xy [x y agent-set] ; Return closest agent to x, y 65 | report min-one-of agent-set [distancexy x y] 66 | end 67 | 68 | to layout 69 | layout-spring agents links 0.2 5 .2 70 | if mouse-down? [ 71 | let chosen-one closest-xy mouse-xcor mouse-ycor agents 72 | while [mouse-down?][ 73 | ask chosen-one [setxy mouse-xcor mouse-ycor] 74 | layout-spring agents links 0.2 5 .2 75 | ] 76 | ] 77 | end 78 | 79 | to-report union [a b] 80 | report remove-duplicates sentence a b 81 | end 82 | 83 | ; 84 | ;agent functions 85 | ; 86 | ;make link to my most prefered blue agent, except if that agent is me. 87 | to setup-link 88 | set reach-me-agents [] 89 | ask my-out-links [die] 90 | while [[color] of (first preferences) = green] [ ;set my first preference to the first one that is not green (still in the game) 91 | set preferences butfirst preferences 92 | ] 93 | if (first preferences != self) [ 94 | create-link-to first preferences 95 | ] 96 | end 97 | 98 | to send-message 99 | ifelse (any? out-link-neighbors) [ 100 | if (count out-link-neighbors != 1) [ show "ERROR: there should only be one outlink" ] ;assert out-link-neighbors == 1 101 | let him one-of out-link-neighbors 102 | ask him [ 103 | set reach-me-agents union (fput ([who] of myself) ([reach-me-agents] of myself)) reach-me-agents 104 | ] 105 | ; set ([reach-me-agents] of him) union (fput who reach-me-agents) ([reach-me-agents] of him) 106 | ][ ; I link to myself 107 | set reach-me-agents (list who) 108 | ] 109 | end 110 | @#$#@#$#@ 111 | GRAPHICS-WINDOW 112 | 205 113 | 10 114 | 644 115 | 470 116 | 16 117 | 16 118 | 13.0 119 | 1 120 | 10 121 | 1 122 | 1 123 | 1 124 | 0 125 | 0 126 | 0 127 | 1 128 | -16 129 | 16 130 | -16 131 | 16 132 | 0 133 | 0 134 | 1 135 | ticks 136 | 30.0 137 | 138 | SLIDER 139 | 4 140 | 53 141 | 176 142 | 86 143 | num-agents 144 | num-agents 145 | 2 146 | 100 147 | 50 148 | 1 149 | 1 150 | NIL 151 | HORIZONTAL 152 | 153 | BUTTON 154 | 3 155 | 12 156 | 72 157 | 45 158 | NIL 159 | setup 160 | NIL 161 | 1 162 | T 163 | OBSERVER 164 | NIL 165 | NIL 166 | NIL 167 | NIL 168 | 1 169 | 170 | BUTTON 171 | 74 172 | 12 173 | 137 174 | 45 175 | NIL 176 | go\n 177 | NIL 178 | 1 179 | T 180 | OBSERVER 181 | NIL 182 | NIL 183 | NIL 184 | NIL 185 | 1 186 | 187 | BUTTON 188 | 140 189 | 12 190 | 203 191 | 45 192 | NIL 193 | go 194 | T 195 | 1 196 | T 197 | OBSERVER 198 | NIL 199 | NIL 200 | NIL 201 | NIL 202 | 1 203 | 204 | PLOT 205 | 3 206 | 154 207 | 204 208 | 308 209 | Preferences Histogram 210 | Choice Number 211 | Num Agents 212 | 1.0 213 | 10.0 214 | 0.0 215 | 10.0 216 | true 217 | false 218 | "" "" 219 | PENS 220 | "default" 1.0 1 -16777216 true "" "" 221 | 222 | BUTTON 223 | 5 224 | 339 225 | 76 226 | 372 227 | NIL 228 | layout 229 | T 230 | 1 231 | T 232 | OBSERVER 233 | NIL 234 | NIL 235 | NIL 236 | NIL 237 | 1 238 | 239 | @#$#@#$#@ 240 | # Top Trading Cycle Algorithm 241 | ## CREDITS 242 | 243 | Jose M Vidal 244 | 245 | ## WHAT IS IT? 246 | 247 | In this problem every node represents an agent with a house that he wants to trade. Every agent has an ordered preference of the other agents' houses he prefers (this list includes the agent's own house). The trick then is to get all agents to trade houses so that they all end up in a house that is at least as good, in their eyes, as the one they currently have. 248 | 249 | The Top Trading Cycle Algorithm (TTCA) solves this problem using a very simple greedy method. It was first proposed in: 250 | 251 | * Lloyd Shapley and Herbert Scarf. [On cores and indivisibility](http://jmvidal.cse.sc.edu/lib/shapley74a.html). _Journal of Mathematical Economics,_ 1(1):23--37, 1974. 252 | 253 | ## HOW DOES IT WORK? 254 | 255 | The algorithm is: 256 | 257 | while there are agents in the game 258 | --each agent points to the one it prefers most 259 | --all agents that are in a loop drop out of the game 260 | 261 | In this animation the blue nodes are the ones that have not traded and the green nodes have already traded. Once a trade cycle is found all the links in the cycle turn black. The edges represent an agent's most preferred house where a node with no edge prefers its own house. As the algorithm runs the nodes adjust their edges in case their most preferred node turns green. 262 | 263 | TTCA is guaranteed to find a solution, and that solution is in the core. That is, there is no subset of agents that could deviate from this solution and everyone one of them receive a house that they like better than the one the got under TTCA. 264 | 265 | I have extended the basic algorithm with a distributed method for identifying cycles. In this program each agent only talks to the one it prefers the most. Of course, if the one it prefers most drops out of the game then the agent talks to the his next most prefered agent that is still in the game. This implementation cheats in that the agents do know the total number of other agents that are blue. 266 | 267 | ## CHANGES 268 | 269 | 20100623 270 | 271 | @#$#@#$#@ 272 | default 273 | true 274 | 0 275 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 276 | 277 | airplane 278 | true 279 | 0 280 | Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 281 | 282 | arrow 283 | true 284 | 0 285 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 286 | 287 | box 288 | false 289 | 0 290 | Polygon -7500403 true true 150 285 285 225 285 75 150 135 291 | Polygon -7500403 true true 150 135 15 75 150 15 285 75 292 | Polygon -7500403 true true 15 75 15 225 150 285 150 135 293 | Line -16777216 false 150 285 150 135 294 | Line -16777216 false 150 135 15 75 295 | Line -16777216 false 150 135 285 75 296 | 297 | bug 298 | true 299 | 0 300 | Circle -7500403 true true 96 182 108 301 | Circle -7500403 true true 110 127 80 302 | Circle -7500403 true true 110 75 80 303 | Line -7500403 true 150 100 80 30 304 | Line -7500403 true 150 100 220 30 305 | 306 | butterfly 307 | true 308 | 0 309 | Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 310 | Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 311 | Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 312 | Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 313 | Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 314 | Circle -16777216 true false 135 90 30 315 | Line -16777216 false 150 105 195 60 316 | Line -16777216 false 150 105 105 60 317 | 318 | car 319 | false 320 | 0 321 | Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 322 | Circle -16777216 true false 180 180 90 323 | Circle -16777216 true false 30 180 90 324 | Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 325 | Circle -7500403 true true 47 195 58 326 | Circle -7500403 true true 195 195 58 327 | 328 | circle 329 | false 330 | 0 331 | Circle -7500403 true true 0 0 300 332 | 333 | circle 2 334 | false 335 | 0 336 | Circle -7500403 true true 0 0 300 337 | Circle -16777216 true false 30 30 240 338 | 339 | cow 340 | false 341 | 0 342 | Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 343 | Polygon -7500403 true true 73 210 86 251 62 249 48 208 344 | Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 345 | 346 | cylinder 347 | false 348 | 0 349 | Circle -7500403 true true 0 0 300 350 | 351 | dot 352 | false 353 | 0 354 | Circle -7500403 true true 90 90 120 355 | 356 | face happy 357 | false 358 | 0 359 | Circle -7500403 true true 8 8 285 360 | Circle -16777216 true false 60 75 60 361 | Circle -16777216 true false 180 75 60 362 | Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 363 | 364 | face neutral 365 | false 366 | 0 367 | Circle -7500403 true true 8 7 285 368 | Circle -16777216 true false 60 75 60 369 | Circle -16777216 true false 180 75 60 370 | Rectangle -16777216 true false 60 195 240 225 371 | 372 | face sad 373 | false 374 | 0 375 | Circle -7500403 true true 8 8 285 376 | Circle -16777216 true false 60 75 60 377 | Circle -16777216 true false 180 75 60 378 | Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 379 | 380 | fish 381 | false 382 | 0 383 | Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 384 | Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 385 | Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 386 | Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 387 | Circle -16777216 true false 215 106 30 388 | 389 | flag 390 | false 391 | 0 392 | Rectangle -7500403 true true 60 15 75 300 393 | Polygon -7500403 true true 90 150 270 90 90 30 394 | Line -7500403 true 75 135 90 135 395 | Line -7500403 true 75 45 90 45 396 | 397 | flower 398 | false 399 | 0 400 | Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 401 | Circle -7500403 true true 85 132 38 402 | Circle -7500403 true true 130 147 38 403 | Circle -7500403 true true 192 85 38 404 | Circle -7500403 true true 85 40 38 405 | Circle -7500403 true true 177 40 38 406 | Circle -7500403 true true 177 132 38 407 | Circle -7500403 true true 70 85 38 408 | Circle -7500403 true true 130 25 38 409 | Circle -7500403 true true 96 51 108 410 | Circle -16777216 true false 113 68 74 411 | Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 412 | Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 413 | 414 | house 415 | false 416 | 0 417 | Rectangle -7500403 true true 45 120 255 285 418 | Rectangle -16777216 true false 120 210 180 285 419 | Polygon -7500403 true true 15 120 150 15 285 120 420 | Line -16777216 false 30 120 270 120 421 | 422 | leaf 423 | false 424 | 0 425 | Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 426 | Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 427 | 428 | line 429 | true 430 | 0 431 | Line -7500403 true 150 0 150 300 432 | 433 | line half 434 | true 435 | 0 436 | Line -7500403 true 150 0 150 150 437 | 438 | pentagon 439 | false 440 | 0 441 | Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 442 | 443 | person 444 | false 445 | 0 446 | Circle -7500403 true true 110 5 80 447 | Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 448 | Rectangle -7500403 true true 127 79 172 94 449 | Polygon -7500403 true true 195 90 240 150 225 180 165 105 450 | Polygon -7500403 true true 105 90 60 150 75 180 135 105 451 | 452 | plant 453 | false 454 | 0 455 | Rectangle -7500403 true true 135 90 165 300 456 | Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 457 | Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 458 | Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 459 | Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 460 | Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 461 | Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 462 | Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 463 | 464 | square 465 | false 466 | 0 467 | Rectangle -7500403 true true 30 30 270 270 468 | 469 | square 2 470 | false 471 | 0 472 | Rectangle -7500403 true true 30 30 270 270 473 | Rectangle -16777216 true false 60 60 240 240 474 | 475 | star 476 | false 477 | 0 478 | Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 479 | 480 | target 481 | false 482 | 0 483 | Circle -7500403 true true 0 0 300 484 | Circle -16777216 true false 30 30 240 485 | Circle -7500403 true true 60 60 180 486 | Circle -16777216 true false 90 90 120 487 | Circle -7500403 true true 120 120 60 488 | 489 | tree 490 | false 491 | 0 492 | Circle -7500403 true true 118 3 94 493 | Rectangle -6459832 true false 120 195 180 300 494 | Circle -7500403 true true 65 21 108 495 | Circle -7500403 true true 116 41 127 496 | Circle -7500403 true true 45 90 120 497 | Circle -7500403 true true 104 74 152 498 | 499 | triangle 500 | false 501 | 0 502 | Polygon -7500403 true true 150 30 15 255 285 255 503 | 504 | triangle 2 505 | false 506 | 0 507 | Polygon -7500403 true true 150 30 15 255 285 255 508 | Polygon -16777216 true false 151 99 225 223 75 224 509 | 510 | truck 511 | false 512 | 0 513 | Rectangle -7500403 true true 4 45 195 187 514 | Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 515 | Rectangle -1 true false 195 60 195 105 516 | Polygon -16777216 true false 238 112 252 141 219 141 218 112 517 | Circle -16777216 true false 234 174 42 518 | Rectangle -7500403 true true 181 185 214 194 519 | Circle -16777216 true false 144 174 42 520 | Circle -16777216 true false 24 174 42 521 | Circle -7500403 false true 24 174 42 522 | Circle -7500403 false true 144 174 42 523 | Circle -7500403 false true 234 174 42 524 | 525 | turtle 526 | true 527 | 0 528 | Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 529 | Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 530 | Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 531 | Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 532 | Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 533 | Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 534 | 535 | wheel 536 | false 537 | 0 538 | Circle -7500403 true true 3 3 294 539 | Circle -16777216 true false 30 30 240 540 | Line -7500403 true 150 285 150 15 541 | Line -7500403 true 15 150 285 150 542 | Circle -7500403 true true 120 120 60 543 | Line -7500403 true 216 40 79 269 544 | Line -7500403 true 40 84 269 221 545 | Line -7500403 true 40 216 269 79 546 | Line -7500403 true 84 40 221 269 547 | 548 | x 549 | false 550 | 0 551 | Polygon -7500403 true true 270 75 225 30 30 225 75 270 552 | Polygon -7500403 true true 30 75 75 30 270 225 225 270 553 | 554 | @#$#@#$#@ 555 | NetLogo 5.0beta2 556 | @#$#@#$#@ 557 | @#$#@#$#@ 558 | @#$#@#$#@ 559 | @#$#@#$#@ 560 | @#$#@#$#@ 561 | default 562 | 0.0 563 | -0.2 0 0.0 1.0 564 | 0.0 1 1.0 0.0 565 | 0.2 0 0.0 1.0 566 | link direction 567 | true 568 | 0 569 | Line -7500403 true 150 150 90 180 570 | Line -7500403 true 150 150 210 180 571 | 572 | @#$#@#$#@ 573 | 0 574 | @#$#@#$#@ 575 | -------------------------------------------------------------------------------- /valueiter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |A demonstration of the value iteration algorithm as applied to a 2D world where a robot can move North, South, East, or West.
We build a graph where the _node_s represent the state of the underlying MDP and the directed links represent actions that can be taken on each state. Each link has a transitions variable which holds the set of nodes that can be reached when taken that action, along with the probabilities.
The thickness of each edge/action is proportional to its current utility.
prob-action-works is the probability that the action (North, South, East, West) will actually take the robot to that square. With 1 - prob-action-works the robot will end up either at its current spot or at one of the other reachable nodes that is a distance of < 2 from the intended destination, with equal probability.
The plot shows the maximum change in utility over all nodes. As expected, this value decreases monotonically.
Setup and Go.
Jose M Vidal
20110514
Initial revision
29 | 30 | 31 | -------------------------------------------------------------------------------- /valueiter/medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/valueiter/medium.png -------------------------------------------------------------------------------- /valueiter/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/josemvidal/netlogomas/ca862892a5c96f6b4e285b2e371bb65ce321e49b/valueiter/thumb.png -------------------------------------------------------------------------------- /valueiter/valueiter.nlogo: -------------------------------------------------------------------------------- 1 | ;a node turtle sits in the middle of each patch 2 | ;each node is also a state in the mdp 3 | breed [nodes node] 4 | 5 | ;each link represents an action 6 | ;transitions: [[.8 nodea] [.2 nodeb]] 7 | ;even thought a link only points to one other node, the transions variable actually holds all the 8 | ;u: utility, new-u, the new one for t+1 9 | links-own [u new-u transitions] 10 | 11 | ;reward: fixed reward for reaching state 12 | ;utility: expected utility, calculated by the value iteration algorithm 13 | nodes-own [reward utility new-utility] 14 | 15 | to setup 16 | ca 17 | ask patches [ 18 | ifelse ((pxcor + pycor) mod 2) = 0 [ 19 | set pcolor white 20 | ][ 21 | set pcolor white 22 | ] 23 | ] 24 | ask patches [ 25 | sprout-nodes 1 [ 26 | set shape "circle" 27 | set size .1 28 | set color black 29 | set utility 0 30 | set new-utility utility 31 | set reward 0 32 | ] 33 | ] 34 | ask n-of dead-nodes nodes [die] 35 | ask one-of nodes [ 36 | set color red 37 | set reward 10 38 | set utility reward 39 | set new-utility utility 40 | set size .4 41 | ] 42 | ask nodes [ 43 | foreach sort turtle-set nodes-on neighbors4 [ 44 | create-link-to ? 45 | ] 46 | ] 47 | ask links [ 48 | let destination end2 49 | let other-possibilities sort ([out-link-neighbors] of end1) with [(distance destination < 2) and self != destination] 50 | let rest-prob (1 - prob-action-works) / (1 + length other-possibilities) 51 | set transitions (list (list prob-action-works end2) (list rest-prob end1)) 52 | foreach other-possibilities[ 53 | set transitions fput (list rest-prob ?) transitions 54 | ] 55 | set label-color black 56 | ] 57 | reset-ticks 58 | end 59 | 60 | 61 | to go 62 | ask nodes [set utility new-utility] 63 | ask nodes [ 64 | update-utilities 65 | ] 66 | ask links [set u new-u] 67 | tick 68 | end 69 | 70 | ;;link' methods 71 | 72 | ;re-set u 73 | to update-utility 74 | set new-u 0 75 | foreach transitions [ 76 | let probability first ? 77 | let destination item 1 ? 78 | set new-u new-u + (probability * [utility] of destination) 79 | ] 80 | set thickness new-u / thickness-denominator 81 | end 82 | 83 | ;;nodes' methods 84 | 85 | to update-utilities 86 | if (any? my-out-links) [ 87 | ask my-out-links [update-utility] 88 | let best-action max-one-of my-out-links [new-u] 89 | set new-utility reward + (gamma * [new-u] of best-action) 90 | ] 91 | end 92 | @#$#@#$#@ 93 | GRAPHICS-WINDOW 94 | 210 95 | 10 96 | 720 97 | 541 98 | -1 99 | -1 100 | 50.0 101 | 1 102 | 10 103 | 1 104 | 1 105 | 1 106 | 0 107 | 0 108 | 0 109 | 1 110 | 0 111 | 9 112 | 0 113 | 9 114 | 1 115 | 1 116 | 1 117 | ticks 118 | 30.0 119 | 120 | BUTTON 121 | 2 122 | 36 123 | 68 124 | 69 125 | NIL 126 | setup\n 127 | NIL 128 | 1 129 | T 130 | OBSERVER 131 | NIL 132 | NIL 133 | NIL 134 | NIL 135 | 1 136 | 137 | BUTTON 138 | 70 139 | 36 140 | 133 141 | 69 142 | NIL 143 | go 144 | NIL 145 | 1 146 | T 147 | OBSERVER 148 | NIL 149 | NIL 150 | NIL 151 | NIL 152 | 1 153 | 154 | SLIDER 155 | 2 156 | 84 157 | 174 158 | 117 159 | gamma 160 | gamma 161 | 0 162 | 1 163 | 0.8 164 | .01 165 | 1 166 | NIL 167 | HORIZONTAL 168 | 169 | SLIDER 170 | 3 171 | 160 172 | 175 173 | 193 174 | dead-nodes 175 | dead-nodes 176 | 0 177 | 20 178 | 20 179 | 1 180 | 1 181 | NIL 182 | HORIZONTAL 183 | 184 | SLIDER 185 | 3 186 | 122 187 | 175 188 | 155 189 | prob-action-works 190 | prob-action-works 191 | 0 192 | 1 193 | 0.5 194 | .01 195 | 1 196 | NIL 197 | HORIZONTAL 198 | 199 | SLIDER 200 | 3 201 | 210 202 | 201 203 | 243 204 | thickness-denominator 205 | thickness-denominator 206 | 0 207 | 200 208 | 96 209 | 1 210 | 1 211 | NIL 212 | HORIZONTAL 213 | 214 | PLOT 215 | 4 216 | 303 217 | 204 218 | 453 219 | Max Delta 220 | tick 221 | NIL 222 | 0.0 223 | 4.0 224 | 0.0 225 | 4.0 226 | true 227 | false 228 | "" "" 229 | PENS 230 | "default" 1.0 1 -16777216 false "" "if (ticks > 0) [plot max [abs new-utility - utility] of nodes]" 231 | 232 | @#$#@#$#@ 233 | # Value Iteration 234 | 235 | ## WHAT IS IT? 236 | 237 | A demonstration of the value iteration algorithm as applied to a 2D world where a robot can move North, South, East, or West. 238 | 239 | ## HOW IT WORKS 240 | 241 | We build a graph where the _node_s represent the state of the underlying MDP and the directed _links_ represent actions that can be taken on each state. Each link has a _transitions_ variable which holds the set of _nodes_ that can be reached when taken that action, along with the probabilities. 242 | 243 | The thickness of each edge/action is proportional to its current utility. 244 | 245 | _prob-action-works_ is the probability that the action (North, South, East, West) will actually take the robot to that square. With 1 - _prob-action-works_ the robot will end up either at its current spot or at one of the other reachable nodes that is a distance of < 2 from the intended destination, with equal probability. 246 | 247 | The plot shows the maximum change in utility over all nodes. As expected, this value decreases monotonically. 248 | 249 | ## HOW TO USE IT 250 | 251 | Setup and Go. 252 | 253 | ## CREDITS AND REFERENCES 254 | 255 | Jose M Vidal 256 | 257 | ## CHANGES 258 | 259 | 20110514 260 | 261 | Initial revision 262 | @#$#@#$#@ 263 | default 264 | true 265 | 0 266 | Polygon -7500403 true true 150 5 40 250 150 205 260 250 267 | 268 | airplane 269 | true 270 | 0 271 | Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 272 | 273 | arrow 274 | true 275 | 0 276 | Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 277 | 278 | arrow half 279 | true 280 | 0 281 | Line -7500403 true 150 0 150 150 282 | Line -7500403 true 150 0 120 30 283 | Line -7500403 true 150 0 180 30 284 | 285 | box 286 | false 287 | 0 288 | Polygon -7500403 true true 150 285 285 225 285 75 150 135 289 | Polygon -7500403 true true 150 135 15 75 150 15 285 75 290 | Polygon -7500403 true true 15 75 15 225 150 285 150 135 291 | Line -16777216 false 150 285 150 135 292 | Line -16777216 false 150 135 15 75 293 | Line -16777216 false 150 135 285 75 294 | 295 | bug 296 | true 297 | 0 298 | Circle -7500403 true true 96 182 108 299 | Circle -7500403 true true 110 127 80 300 | Circle -7500403 true true 110 75 80 301 | Line -7500403 true 150 100 80 30 302 | Line -7500403 true 150 100 220 30 303 | 304 | butterfly 305 | true 306 | 0 307 | Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 308 | Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 309 | Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 310 | Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 311 | Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 312 | Circle -16777216 true false 135 90 30 313 | Line -16777216 false 150 105 195 60 314 | Line -16777216 false 150 105 105 60 315 | 316 | car 317 | false 318 | 0 319 | Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 320 | Circle -16777216 true false 180 180 90 321 | Circle -16777216 true false 30 180 90 322 | Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 323 | Circle -7500403 true true 47 195 58 324 | Circle -7500403 true true 195 195 58 325 | 326 | circle 327 | false 328 | 0 329 | Circle -7500403 true true 0 0 300 330 | 331 | circle 2 332 | false 333 | 0 334 | Circle -7500403 true true 0 0 300 335 | Circle -16777216 true false 30 30 240 336 | 337 | cow 338 | false 339 | 0 340 | Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 341 | Polygon -7500403 true true 73 210 86 251 62 249 48 208 342 | Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 343 | 344 | cylinder 345 | false 346 | 0 347 | Circle -7500403 true true 0 0 300 348 | 349 | dot 350 | false 351 | 0 352 | Circle -7500403 true true 90 90 120 353 | 354 | face happy 355 | false 356 | 0 357 | Circle -7500403 true true 8 8 285 358 | Circle -16777216 true false 60 75 60 359 | Circle -16777216 true false 180 75 60 360 | Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 361 | 362 | face neutral 363 | false 364 | 0 365 | Circle -7500403 true true 8 7 285 366 | Circle -16777216 true false 60 75 60 367 | Circle -16777216 true false 180 75 60 368 | Rectangle -16777216 true false 60 195 240 225 369 | 370 | face sad 371 | false 372 | 0 373 | Circle -7500403 true true 8 8 285 374 | Circle -16777216 true false 60 75 60 375 | Circle -16777216 true false 180 75 60 376 | Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 377 | 378 | fish 379 | false 380 | 0 381 | Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 382 | Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 383 | Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 384 | Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 385 | Circle -16777216 true false 215 106 30 386 | 387 | flag 388 | false 389 | 0 390 | Rectangle -7500403 true true 60 15 75 300 391 | Polygon -7500403 true true 90 150 270 90 90 30 392 | Line -7500403 true 75 135 90 135 393 | Line -7500403 true 75 45 90 45 394 | 395 | flower 396 | false 397 | 0 398 | Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 399 | Circle -7500403 true true 85 132 38 400 | Circle -7500403 true true 130 147 38 401 | Circle -7500403 true true 192 85 38 402 | Circle -7500403 true true 85 40 38 403 | Circle -7500403 true true 177 40 38 404 | Circle -7500403 true true 177 132 38 405 | Circle -7500403 true true 70 85 38 406 | Circle -7500403 true true 130 25 38 407 | Circle -7500403 true true 96 51 108 408 | Circle -16777216 true false 113 68 74 409 | Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 410 | Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 411 | 412 | house 413 | false 414 | 0 415 | Rectangle -7500403 true true 45 120 255 285 416 | Rectangle -16777216 true false 120 210 180 285 417 | Polygon -7500403 true true 15 120 150 15 285 120 418 | Line -16777216 false 30 120 270 120 419 | 420 | leaf 421 | false 422 | 0 423 | Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 424 | Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 425 | 426 | line 427 | true 428 | 0 429 | Line -7500403 true 150 0 150 300 430 | 431 | pentagon 432 | false 433 | 0 434 | Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 435 | 436 | person 437 | false 438 | 0 439 | Circle -7500403 true true 110 5 80 440 | Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 441 | Rectangle -7500403 true true 127 79 172 94 442 | Polygon -7500403 true true 195 90 240 150 225 180 165 105 443 | Polygon -7500403 true true 105 90 60 150 75 180 135 105 444 | 445 | plant 446 | false 447 | 0 448 | Rectangle -7500403 true true 135 90 165 300 449 | Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 450 | Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 451 | Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 452 | Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 453 | Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 454 | Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 455 | Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 456 | 457 | sheep 458 | false 459 | 0 460 | Rectangle -7500403 true true 151 225 180 285 461 | Rectangle -7500403 true true 47 225 75 285 462 | Rectangle -7500403 true true 15 75 210 225 463 | Circle -7500403 true true 135 75 150 464 | Circle -16777216 true false 165 76 116 465 | 466 | square 467 | false 468 | 0 469 | Rectangle -7500403 true true 30 30 270 270 470 | 471 | square 2 472 | false 473 | 0 474 | Rectangle -7500403 true true 30 30 270 270 475 | Rectangle -16777216 true false 60 60 240 240 476 | 477 | star 478 | false 479 | 0 480 | Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 481 | 482 | target 483 | false 484 | 0 485 | Circle -7500403 true true 0 0 300 486 | Circle -16777216 true false 30 30 240 487 | Circle -7500403 true true 60 60 180 488 | Circle -16777216 true false 90 90 120 489 | Circle -7500403 true true 120 120 60 490 | 491 | tree 492 | false 493 | 0 494 | Circle -7500403 true true 118 3 94 495 | Rectangle -6459832 true false 120 195 180 300 496 | Circle -7500403 true true 65 21 108 497 | Circle -7500403 true true 116 41 127 498 | Circle -7500403 true true 45 90 120 499 | Circle -7500403 true true 104 74 152 500 | 501 | triangle 502 | false 503 | 0 504 | Polygon -7500403 true true 150 30 15 255 285 255 505 | 506 | triangle 2 507 | false 508 | 0 509 | Polygon -7500403 true true 150 30 15 255 285 255 510 | Polygon -16777216 true false 151 99 225 223 75 224 511 | 512 | truck 513 | false 514 | 0 515 | Rectangle -7500403 true true 4 45 195 187 516 | Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 517 | Rectangle -1 true false 195 60 195 105 518 | Polygon -16777216 true false 238 112 252 141 219 141 218 112 519 | Circle -16777216 true false 234 174 42 520 | Rectangle -7500403 true true 181 185 214 194 521 | Circle -16777216 true false 144 174 42 522 | Circle -16777216 true false 24 174 42 523 | Circle -7500403 false true 24 174 42 524 | Circle -7500403 false true 144 174 42 525 | Circle -7500403 false true 234 174 42 526 | 527 | turtle 528 | true 529 | 0 530 | Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 531 | Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 532 | Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 533 | Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 534 | Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 535 | Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 536 | 537 | wheel 538 | false 539 | 0 540 | Circle -7500403 true true 3 3 294 541 | Circle -16777216 true false 30 30 240 542 | Line -7500403 true 150 285 150 15 543 | Line -7500403 true 15 150 285 150 544 | Circle -7500403 true true 120 120 60 545 | Line -7500403 true 216 40 79 269 546 | Line -7500403 true 40 84 269 221 547 | Line -7500403 true 40 216 269 79 548 | Line -7500403 true 84 40 221 269 549 | 550 | x 551 | false 552 | 0 553 | Polygon -7500403 true true 270 75 225 30 30 225 75 270 554 | Polygon -7500403 true true 30 75 75 30 270 225 225 270 555 | 556 | @#$#@#$#@ 557 | NetLogo 5.0beta2 558 | @#$#@#$#@ 559 | @#$#@#$#@ 560 | @#$#@#$#@ 561 | @#$#@#$#@ 562 | @#$#@#$#@ 563 | default 564 | 0.2 565 | -0.2 0 0.0 1.0 566 | 0.0 1 1.0 0.0 567 | 0.2 0 0.0 1.0 568 | link direction 569 | true 570 | 0 571 | Line -7500403 true 150 150 135 165 572 | Line -7500403 true 150 150 165 165 573 | 574 | @#$#@#$#@ 575 | 0 576 | @#$#@#$#@ 577 | --------------------------------------------------------------------------------