├── .gitignore ├── NetLogo-Mathematica Tutorial.nb ├── NetLogo-Mathematica Tutorial.pdf ├── NetLogo.m ├── README.md ├── build.sbt ├── project └── build.properties └── src └── main └── NLink.java /.gitignore: -------------------------------------------------------------------------------- 1 | /JLink.jar 2 | /*.class 3 | /target/ 4 | /project/target 5 | /project/project 6 | -------------------------------------------------------------------------------- /NetLogo-Mathematica Tutorial.nb: -------------------------------------------------------------------------------- 1 | (* Content-type: application/vnd.wolfram.mathematica *) 2 | 3 | (*** Wolfram Notebook File ***) 4 | (* http://www.wolfram.com/nb *) 5 | 6 | (* CreatedBy='Mathematica 12.2' *) 7 | 8 | (*CacheID: 234*) 9 | (* Internal cache information: 10 | NotebookFileLineBreakTest 11 | NotebookFileLineBreakTest 12 | NotebookDataPosition[ 158, 7] 13 | NotebookDataLength[ 94837, 2486] 14 | NotebookOptionsPosition[ 76140, 2143] 15 | NotebookOutlinePosition[ 79008, 2228] 16 | CellTagsIndexPosition[ 78812, 2220] 17 | WindowFrame->Normal*) 18 | 19 | (* Beginning of Notebook Content *) 20 | Notebook[{ 21 | Cell[TextData[{ 22 | StyleBox["NetLogo-", 23 | FontWeight->"Bold"], 24 | StyleBox["Mathematica", 25 | FontWeight->"Bold", 26 | FontSlant->"Italic"], 27 | StyleBox[" Link\[LineSeparator]", 28 | FontWeight->"Bold"], 29 | StyleBox["Tutorials and Examples", "Subsubtitle", 30 | FontWeight->"Plain"] 31 | }], "Title", 32 | CellFrame->True, 33 | CellChangeTimes->{{3.396108953925385*^9, 3.39610895489642*^9}, { 34 | 3.396109154888516*^9, 3.396109205364633*^9}, {3.3961127582735567`*^9, 35 | 3.396112759546694*^9}, {3.396135821265427*^9, 3.396135827341074*^9}}, 36 | Background->RGBColor[ 37 | 0.956364, 0.856878, 38 | 0.636696],ExpressionUUID->"eacb4ec8-43f4-403b-825b-c3d2a3df1381"], 39 | 40 | Cell[TextData[{ 41 | "This document will show how to use the NetLogo-", 42 | StyleBox["Mathematica", 43 | FontSlant->"Italic"], 44 | " add-on to application interface. The notebook has examples that make use \ 45 | of sample models included with NetLogo. Click the right-most bracket of each \ 46 | cell to collapse a section." 47 | }], "Text", 48 | CellChangeTimes->{{3.379268197719895*^9, 3.3792682289026937`*^9}, { 49 | 3.395788167600391*^9, 3.395788205335956*^9}, {3.396109525181209*^9, 50 | 3.396109529696267*^9}, {3.39610957304434*^9, 3.3961095914168167`*^9}, { 51 | 3.3961124357197523`*^9, 3.396112436020528*^9}, {3.3961808256316423`*^9, 52 | 3.396180914574497*^9}},ExpressionUUID->"698b9b16-b219-4d10-b3b0-\ 53 | d652402cdbef"], 54 | 55 | Cell[TextData[{ 56 | StyleBox["Warning: It is important that you follow the procedure described \ 57 | in ", 58 | FontSize->14], 59 | StyleBox["Installing NetLogo-Mathematica", 60 | FontSlant->"Italic"], 61 | StyleBox[" ", 62 | FontSize->14], 63 | StyleBox["Link", 64 | FontSize->14, 65 | FontSlant->"Italic"], 66 | StyleBox[" and execute the code in ", 67 | FontSize->14], 68 | StyleBox["Starting NetLogo", 69 | FontSize->14, 70 | FontSlant->"Italic"], 71 | StyleBox[" before continuing with the tutorial. You may skip around \ 72 | sections, but within each section, you must start from the top and execute \ 73 | each consecutive command. Sections will ", 74 | FontSize->14], 75 | StyleBox["not work properly", 76 | FontSize->14, 77 | FontSlant->"Italic"], 78 | StyleBox[" if you do not follow the instructions step-by-step. If you follow \ 79 | the directions in order and find you are getting errors, please see the ", 80 | FontSize->14], 81 | StyleBox[ButtonBox["troubleshooting", 82 | BaseStyle->"Hyperlink", 83 | ButtonData->"troubleshooting"], 84 | FontSize->14], 85 | StyleBox[" section.", 86 | FontSize->14] 87 | }], "Text", 88 | CellChangeTimes->{{3.396180411581019*^9, 3.396180510400729*^9}, { 89 | 3.396180542523769*^9, 3.3961806270103703`*^9}, {3.3962279099080687`*^9, 90 | 3.396227913624112*^9}, {3.661532063665539*^9, 3.661532123673815*^9}, { 91 | 3.704209037273026*^9, 3.704209050319108*^9}, {3.70421053181789*^9, 92 | 3.704210547467452*^9}}, 93 | FontWeight->"Bold",ExpressionUUID->"63d9cc59-cef9-4904-a0f1-2665dfda7175"], 94 | 95 | Cell[CellGroupData[{ 96 | 97 | Cell[TextData[{ 98 | "Installing NetLogo-", 99 | StyleBox["Mathematica", 100 | FontSlant->"Italic"], 101 | " Link" 102 | }], "Section", 103 | CellChangeTimes->{{3.379267175343656*^9, 3.379267178452536*^9}, { 104 | 3.396099257580571*^9, 3.396099263891943*^9}, {3.661532117953534*^9, 105 | 3.661532118313595*^9}}, 106 | CellTags-> 107 | "installing",ExpressionUUID->"cf89693c-1762-4b2b-aaaa-80eea3b3423e"], 108 | 109 | Cell[TextData[{ 110 | "To install the NetLogo-", 111 | StyleBox["Mathematica", 112 | FontSlant->"Italic"], 113 | " link, go to the menu bar in ", 114 | StyleBox["Mathematica", 115 | FontSlant->"Italic"], 116 | ", click on ", 117 | StyleBox["File", 118 | FontSlant->"Italic"], 119 | " and select ", 120 | StyleBox["Install...", 121 | FontSlant->"Italic"], 122 | " In the Install ", 123 | StyleBox["Mathematica", 124 | FontSlant->"Italic"], 125 | " Item dialog, select ", 126 | StyleBox["Package", 127 | FontSlant->"Italic"], 128 | " for ", 129 | StyleBox["Type of item to install", 130 | FontSlant->"Italic"], 131 | ", click Source, and select ", 132 | StyleBox["From file...", 133 | FontSlant->"Italic"], 134 | " In the file browser, go to the location of your NetLogo installation, \ 135 | click on the Mathematica Link subfolder, and select NetLogo.m. For ", 136 | StyleBox["Install Name", 137 | FontSlant->"Italic"], 138 | ", enter ", 139 | StyleBox["NetLogo", 140 | FontSlant->"Italic"], 141 | ". You can either install the NetLogo link in your user base directory or \ 142 | in the system-wide directory. If the NetLogo link is installed in the user \ 143 | base directory, other users on the system must also go through the NetLogo-", 144 | StyleBox["Mathematica", 145 | FontSlant->"Italic"], 146 | " link installation process to use it. This option might be preferable if \ 147 | you do not have permission to modify files outside of your home directory. \ 148 | Otherwise, you can install NetLogo-", 149 | StyleBox["Mathematica", 150 | FontSlant->"Italic"], 151 | " link in the system-wide ", 152 | StyleBox["Mathematica", 153 | FontSlant->"Italic"], 154 | " base directory." 155 | }], "Text", 156 | CellChangeTimes->{{3.379267184507855*^9, 3.379267321058403*^9}, { 157 | 3.379267371845751*^9, 3.379267462950327*^9}, {3.395769300808814*^9, 158 | 3.3957693401425467`*^9}, {3.395769429059865*^9, 3.395769452922413*^9}, { 159 | 3.3957696295780773`*^9, 3.395769698850263*^9}, {3.395769847225362*^9, 160 | 3.395770218940879*^9}, {3.396099344700583*^9, 3.396099361163451*^9}, { 161 | 3.39610960430308*^9, 3.396109618130539*^9}, {3.396227493157465*^9, 162 | 3.396227530986553*^9}, {3.396227800527182*^9, 163 | 3.3962278577081223`*^9}},ExpressionUUID->"b113e1ef-5b9e-4cd1-9902-\ 164 | 8d76280961d5"] 165 | }, Open ]], 166 | 167 | Cell[CellGroupData[{ 168 | 169 | Cell["Starting NetLogo", "Section", 170 | CellChangeTimes->{{3.37926690887947*^9, 3.379266912212112*^9}, { 171 | 3.396107855489249*^9, 172 | 3.396107856533155*^9}},ExpressionUUID->"53b6a1ea-2960-44c3-82b2-\ 173 | 48fb85ba5fea"], 174 | 175 | Cell[CellGroupData[{ 176 | 177 | Cell["\<\ 178 | Once installed, the NetLogo package can be loaded at any time with the \ 179 | following command:\ 180 | \>", "Text", 181 | CellChangeTimes->{{3.379267500655287*^9, 3.37926752304792*^9}, { 182 | 3.396141872152175*^9, 3.39614187532401*^9}, 183 | 3.396227561920313*^9},ExpressionUUID->"fd224ba7-f6fb-4147-9839-\ 184 | c4ad8bce8d51"], 185 | 186 | Cell[BoxData[ 187 | RowBox[{"<<", "NetLogo`"}]], "Input", 188 | CellChangeTimes->{{3.395770226463278*^9, 3.395770232062625*^9}, { 189 | 3.3960992528444567`*^9, 190 | 3.396099254004483*^9}},ExpressionUUID->"76201619-afc4-4fb2-8865-\ 191 | dc60b2271a79"] 192 | }, Open ]], 193 | 194 | Cell[CellGroupData[{ 195 | 196 | Cell["\<\ 197 | To start NetLogo simply type the following command, and use the file browser \ 198 | to locate the NetLogo parent directory, typically located in \ 199 | \"/Applications/NetLogo 6.2.0\" or \"C:\\Program Files\\NetLogo 6.2.0\", on \ 200 | Macintosh and Windows systems, respectively.\ 201 | \>", "Text", 202 | CellChangeTimes->{{3.37925209162411*^9, 3.379252174789466*^9}, { 203 | 3.379266451851063*^9, 3.379266462782384*^9}, {3.379267547349929*^9, 204 | 3.379267548691347*^9}, 3.396227574876734*^9, {3.3967585502242002`*^9, 205 | 3.396758608251115*^9}, {3.3967588419795647`*^9, 3.3967589061331987`*^9}, { 206 | 3.6929733808314047`*^9, 3.6929733850353527`*^9}, {3.704208363472691*^9, 207 | 3.7042083683903837`*^9}, {3.711102617423896*^9, 3.7111026180234756`*^9}, { 208 | 3.828701037319882*^9, 209 | 3.828701039663349*^9}},ExpressionUUID->"c704b4f5-b7f9-4a52-bd4a-\ 210 | 36c5bf976564"], 211 | 212 | Cell[BoxData[ 213 | RowBox[{"NLStart", "[", "]"}]], "Input", 214 | CellChangeTimes->{{3.396758562981241*^9, 215 | 3.3967585646029787`*^9}},ExpressionUUID->"11a31024-496b-4843-b3ed-\ 216 | 651f017d982f"] 217 | }, Open ]], 218 | 219 | Cell[CellGroupData[{ 220 | 221 | Cell[TextData[{ 222 | "The NetLogo-", 223 | StyleBox["Mathematica", 224 | FontSlant->"Italic"], 225 | " Link will store this path in", 226 | StyleBox[" $NLHome. ", 227 | FontFamily->"Courier", 228 | FontWeight->"Bold"], 229 | "We also store the default models folder path in ", 230 | StyleBox["$NLModels", 231 | FontWeight->"Bold"], 232 | " for loading our examples. The path given is for macOS." 233 | }], "Text", 234 | CellChangeTimes->{{3.3967586156477003`*^9, 3.396758657381135*^9}, { 235 | 3.828700314296001*^9, 236 | 3.828700358043539*^9}},ExpressionUUID->"75280f20-54bd-427a-8b03-\ 237 | 8af7c712c674"], 238 | 239 | Cell[BoxData[{"$NLHome", "\[IndentingNewLine]", 240 | RowBox[{"$NLModels", " ", "=", " ", 241 | RowBox[{"ToFileName", "[", 242 | RowBox[{"{", 243 | RowBox[{"$NLHome", ",", " ", "\"\\""}], "}"}], "]"}]}]}], "Input",\ 244 | 245 | CellChangeTimes->{{3.396758658363719*^9, 3.3967586604780817`*^9}, { 246 | 3.828700214974881*^9, 247 | 3.8287002208206797`*^9}},ExpressionUUID->"6c233054-858e-401b-a820-\ 248 | 3f979dca5b94"] 249 | }, Open ]] 250 | }, Open ]], 251 | 252 | Cell[TextData[{ 253 | "One can also manually specify the ", 254 | StyleBox["$NLHome", 255 | FontFamily->"Courier", 256 | FontWeight->"Bold"], 257 | " directory by hard coding in your NetLogo installation directory. This is \ 258 | preferable in many real-world scenarios when one uses the NetLogo-", 259 | StyleBox["Mathematica", 260 | FontSlant->"Italic"], 261 | " Link often." 262 | }], "Text", 263 | CellChangeTimes->{{3.3967586761771507`*^9, 3.3967588246025677`*^9}, { 264 | 3.3967589184958363`*^9, 3.396758918902239*^9}, {3.3967591812758217`*^9, 265 | 3.396759238536141*^9}},ExpressionUUID->"9d48a520-cae3-4303-8742-\ 266 | 21e81e18d876"], 267 | 268 | Cell[BoxData[{ 269 | RowBox[{ 270 | RowBox[{"$NLHome", " ", "=", " ", "\"\\""}], 271 | ";"}], "\[IndentingNewLine]", 272 | RowBox[{ 273 | RowBox[{ 274 | "$NLHome", " ", "=", " ", "\"\\""}], 275 | ";"}]}], "Code", 276 | Evaluatable->False, 277 | CellChangeTimes->{ 278 | 3.392740837255293*^9, {3.396758946336493*^9, 3.3967589810336313`*^9}, { 279 | 3.396759047742971*^9, 3.396759050331758*^9}, {3.661531942289324*^9, 280 | 3.6615319490693207`*^9}, {3.692973389571623*^9, 3.69297339476723*^9}, { 281 | 3.704208395225827*^9, 3.7042083980574636`*^9}, {3.7111025915495663`*^9, 282 | 3.711102594277955*^9}, {3.828699913414028*^9, 283 | 3.8286999155387173`*^9}},ExpressionUUID->"e64b844f-c2aa-4f99-ab93-\ 284 | b46177895c5b"], 285 | 286 | Cell[CellGroupData[{ 287 | 288 | Cell["\<\ 289 | Once again, to start NetLogo using the default path (now specified by \ 290 | $NLHome) enter\ 291 | \>", "Text", 292 | CellChangeTimes->{{3.3967590615715313`*^9, 293 | 3.396759108052608*^9}},ExpressionUUID->"8af1c074-959e-4eeb-a3ec-\ 294 | a78c455044ed"], 295 | 296 | Cell[BoxData[ 297 | RowBox[{"NLStart", "[", "]"}]], "Input", 298 | CellChangeTimes->{{3.39675908567559*^9, 3.396759087371797*^9}, 299 | 3.828698441374526*^9},ExpressionUUID->"224035f1-822a-4640-966a-\ 300 | 537c944e9f28"] 301 | }, Open ]], 302 | 303 | Cell[TextData[{ 304 | "If you are running on Windows or Linux, you should set your ", 305 | StyleBox["$NLModels", 306 | FontWeight->"Bold"], 307 | " variable to the below path." 308 | }], "Text", 309 | CellChangeTimes->{{3.828700238521339*^9, 310 | 3.8287002629852448`*^9}},ExpressionUUID->"c6eed7d8-941f-4a33-bf34-\ 311 | 99f6b55724d7"], 312 | 313 | Cell[BoxData[ 314 | RowBox[{"$NLModels", " ", "=", " ", 315 | RowBox[{"ToFileName", "[", 316 | RowBox[{"{", 317 | RowBox[{"$NLHome", ",", "\"\\"", ",", " ", "\"\\""}], 318 | "}"}], "]"}]}]], "Input", 319 | CellChangeTimes->{{3.828698455221457*^9, 3.8286984774800777`*^9}, { 320 | 3.8286985135002623`*^9, 321 | 3.828698516619619*^9}},ExpressionUUID->"fda5a45b-ed88-40d5-9fcb-\ 322 | 26c5b13bdb56"], 323 | 324 | Cell[CellGroupData[{ 325 | 326 | Cell[TextData[{ 327 | "An Overview of the NetLogo-", 328 | StyleBox["Mathematica", 329 | FontSlant->"Italic"], 330 | " Link using Fire" 331 | }], "Section", 332 | CellChangeTimes->{{3.396142017135027*^9, 3.396142050232482*^9}, { 333 | 3.396180783744823*^9, 3.396180807396174*^9}, {3.39622041966368*^9, 334 | 3.396220474589232*^9}},ExpressionUUID->"9a73e35f-249d-4bc2-8855-\ 335 | 7abf4eb6e09d"], 336 | 337 | Cell[CellGroupData[{ 338 | 339 | Cell["Loading a NetLogo model", "Subsubsection", 340 | CellChangeTimes->{{3.3957867307429028`*^9, 3.3957867326573963`*^9}, { 341 | 3.395787476101246*^9, 342 | 3.395787477337536*^9}},ExpressionUUID->"43fb015c-52dc-43fc-a389-\ 343 | ac3bb522ed50"], 344 | 345 | Cell[CellGroupData[{ 346 | 347 | Cell[TextData[{ 348 | StyleBox["Use ", 349 | FontSize->13], 350 | StyleBox["NLLoadModel[]", 351 | FontFamily->"Courier", 352 | FontSize->13, 353 | FontWeight->"Bold"], 354 | StyleBox[" to load the Fire example from the models library.", 355 | FontSize->13] 356 | }], "Text", 357 | CellChangeTimes->{{3.3957706583196783`*^9, 3.395770711777224*^9}, { 358 | 3.395786590689625*^9, 3.39578661537565*^9}, {3.3962257508964043`*^9, 359 | 3.396225866892043*^9}, {3.396226057307824*^9, 360 | 3.39622605967979*^9}},ExpressionUUID->"1e14ac98-5fab-41c7-9606-\ 361 | 52514fd4c89d"], 362 | 363 | Cell[BoxData[ 364 | RowBox[{ 365 | RowBox[{"NLLoadModel", "[", 366 | RowBox[{"ToFileName", "[", 367 | RowBox[{ 368 | RowBox[{"{", 369 | RowBox[{ 370 | "$NLModels", ",", "\"\\"", ",", 371 | "\"\\""}], "}"}], ",", "\"\\""}], "]"}], 372 | "]"}], ";"}]], "Input", 373 | CellChangeTimes->{{3.395167874574985*^9, 3.395167900460574*^9}, { 374 | 3.395167945582859*^9, 3.3951679743408813`*^9}, {3.3962259645541067`*^9, 375 | 3.39622599610633*^9}, 3.396226038654255*^9, {3.8286973491634007`*^9, 376 | 3.8286973505115213`*^9}, {3.828698530678856*^9, 377 | 3.828698555647275*^9}},ExpressionUUID->"80be373e-3c43-47bf-a89c-\ 378 | 77e80d53f78e"] 379 | }, Open ]] 380 | }, Open ]], 381 | 382 | Cell[CellGroupData[{ 383 | 384 | Cell["Executing NetLogo commands", "Subsubsection", 385 | CellChangeTimes->{{3.395786744448927*^9, 3.39578674760189*^9}, { 386 | 3.395787472141404*^9, 3.3957874734573603`*^9}, {3.396226094208852*^9, 387 | 3.3962260955372*^9}},ExpressionUUID->"138b77c8-5106-485b-95f2-444a31404f4b"], 388 | 389 | Cell[TextData[{ 390 | StyleBox["The ", 391 | FontSize->13], 392 | StyleBox["NLCommand[]", 393 | FontFamily->"Courier", 394 | FontSize->13, 395 | FontWeight->"Bold"], 396 | StyleBox[" function lets you execute any NetLogo command as if you were \ 397 | typing from the command center.", 398 | FontSize->13] 399 | }], "Text", 400 | CellChangeTimes->{{3.3957867561085157`*^9, 3.395786783627163*^9}, 401 | 3.396760992447802*^9},ExpressionUUID->"d7bd9853-cd14-4189-877e-\ 402 | c5a79b86e890"], 403 | 404 | Cell[BoxData[ 405 | RowBox[{ 406 | RowBox[{"NLCommand", "[", "\"\\"", "]"}], ";"}]], "Input", 407 | CellChangeTimes->{{3.36940654733116*^9, 3.36940657441532*^9}, { 408 | 3.372441346579666*^9, 3.372441355986367*^9}, 3.395770499893862*^9, { 409 | 3.3961437400327587`*^9, 3.396143743318277*^9}, {3.396220690414427*^9, 410 | 3.396220690652315*^9}, {3.3962207907747393`*^9, 411 | 3.3962207916466017`*^9}},ExpressionUUID->"b2fcedb9-26ac-4f92-aae4-\ 412 | 2b92a9601051"], 413 | 414 | Cell[BoxData[ 415 | RowBox[{ 416 | RowBox[{"NLCommand", "[", "\"\\"", "]"}], ";"}]], "Input", 417 | CellChangeTimes->{{3.396220781340898*^9, 418 | 3.3962207888785677`*^9}},ExpressionUUID->"6cf8111f-3bf4-4fec-b47e-\ 419 | 12ea74e26d1b"], 420 | 421 | Cell[TextData[{ 422 | "The function ", 423 | StyleBox["NLCommand[]", 424 | FontFamily->"Courier", 425 | FontWeight->"Bold"], 426 | " automatically splices expression into NetLogo strings, making it easy to \ 427 | pass sequences of strings, numbers, lists, and colors into NetLogo without \ 428 | having to manually convert data types and join strings." 429 | }], "Text", 430 | CellChangeTimes->{{3.395787126151724*^9, 3.395787329525072*^9}, { 431 | 3.396181525528531*^9, 3.396181599041587*^9}, {3.3961817740530863`*^9, 432 | 3.396181777047739*^9}, {3.396220815820211*^9, 3.396220833344388*^9}, { 433 | 3.396760957768324*^9, 3.396760963860832*^9}, {3.396761101014472*^9, 434 | 3.3967611022270813`*^9}},ExpressionUUID->"9abdfabc-9b4b-4b3a-8331-\ 435 | e58f17f9e14e"], 436 | 437 | Cell[BoxData[ 438 | RowBox[{ 439 | RowBox[{"NLCommand", "[", 440 | RowBox[{"\"\\"", ",", "50"}], "]"}], ";"}]], "Input", 441 | CellChangeTimes->{{3.3957872466771183`*^9, 3.3957872554512987`*^9}, { 442 | 3.395787403987403*^9, 3.395787404128523*^9}, {3.3961437287031717`*^9, 443 | 3.396143736990491*^9}, {3.3962206827590427`*^9, 3.396220682972501*^9}, { 444 | 3.396220847482654*^9, 445 | 3.396220847555604*^9}},ExpressionUUID->"567cfee1-3ce8-4429-a3a4-\ 446 | bbec2a5333ce"], 447 | 448 | Cell[TextData[{ 449 | "Splicing can be very useful for setting NetLogo sliders using ", 450 | StyleBox["Mathematica", 451 | FontSlant->"Italic"], 452 | " variables" 453 | }], "Text", 454 | CellChangeTimes->{{3.396220897771734*^9, 455 | 3.396220922011002*^9}},ExpressionUUID->"f45caf3f-8872-4ac5-b4e5-\ 456 | d5f1a9ccaab4"], 457 | 458 | Cell[BoxData[{ 459 | RowBox[{ 460 | RowBox[{"d", "=", "65"}], ";"}], "\[IndentingNewLine]", 461 | RowBox[{ 462 | RowBox[{"NLCommand", "[", 463 | RowBox[{"\"\\"", ",", "d"}], "]"}], ";"}]}], "Input", 464 | CellChangeTimes->{{3.396220835414693*^9, 3.396220865456481*^9}, { 465 | 3.396220998103653*^9, 3.396221003055592*^9}, {3.396221069059395*^9, 466 | 3.3962210863218946`*^9}},ExpressionUUID->"598ec602-e835-4696-954b-\ 467 | 804acbb6d1b4"], 468 | 469 | Cell[TextData[{ 470 | "It is also possible to specify several command sequences using a single", 471 | StyleBox[" NLCommand[]", 472 | FontFamily->"Courier", 473 | FontWeight->"Bold"] 474 | }], "Text", 475 | CellChangeTimes->{{3.3962209422159243`*^9, 476 | 3.3962209737964983`*^9}},ExpressionUUID->"78a490c3-a73a-4fa2-a293-\ 477 | 268206d0b827"], 478 | 479 | Cell[BoxData[ 480 | RowBox[{ 481 | RowBox[{"NLCommand", "[", 482 | RowBox[{"\"\\"", ",", 483 | RowBox[{"d", "-", "10"}], ",", "\"\\"", ",", 484 | "\"\\""}], "]"}], ";"}]], "Input", 485 | CellChangeTimes->{{3.396220975868457*^9, 486 | 3.396221041776741*^9}},ExpressionUUID->"a3ab709b-ac6c-43da-8d2a-\ 487 | 9e3b5c457e75"] 488 | }, Open ]], 489 | 490 | Cell[CellGroupData[{ 491 | 492 | Cell["Repeatedly executing NetLogo commands", "Subsubsection", 493 | CellChangeTimes->{{3.395770587930881*^9, 494 | 3.395770602054427*^9}},ExpressionUUID->"d1dcd5b3-d556-451e-a4a3-\ 495 | e39b7b29e377"], 496 | 497 | Cell[CellGroupData[{ 498 | 499 | Cell[TextData[{ 500 | "This loop calls ", 501 | StyleBox["NLCommand[]", 502 | FontFamily->"Courier", 503 | FontWeight->"Bold"], 504 | " 10 times." 505 | }], "Text", 506 | CellChangeTimes->{{3.396224649308527*^9, 507 | 3.396224649388089*^9}},ExpressionUUID->"a5c7750a-df9a-4e76-bb53-\ 508 | 9916082dbd81"], 509 | 510 | Cell[BoxData[ 511 | RowBox[{ 512 | RowBox[{"Do", "[", 513 | RowBox[{ 514 | RowBox[{"NLCommand", "[", "\"\\"", "]"}], ",", 515 | RowBox[{"{", "10", "}"}]}], "]"}], ";"}]], "Input", 516 | CellChangeTimes->{{3.36940654733116*^9, 3.36940657441532*^9}, { 517 | 3.372441346579666*^9, 3.372441357346382*^9}, 3.395770514878862*^9, { 518 | 3.395770612815825*^9, 3.3957706469135113`*^9}, {3.396105874829711*^9, 519 | 3.3961058786449833`*^9}, {3.396106008563079*^9, 3.396106009775708*^9}, 520 | 3.396109758873501*^9, {3.396181439128929*^9, 3.39618144159147*^9}, { 521 | 3.396221111784404*^9, 3.396221144412883*^9}, {3.396224645287643*^9, 522 | 3.3962246509494553`*^9}},ExpressionUUID->"c59a3cb1-cafe-41b4-bd91-\ 523 | f0f68389dbb1"] 524 | }, Open ]], 525 | 526 | Cell[CellGroupData[{ 527 | 528 | Cell[TextData[{ 529 | StyleBox["The command", 530 | FontSize->13], 531 | StyleBox[" NLDoCommand[] ", 532 | FontFamily->"Courier", 533 | FontSize->13, 534 | FontWeight->"Bold"], 535 | StyleBox["is an easier and efficient way to execute a command repeatedly.", 536 | FontSize->13] 537 | }], "Text", 538 | CellChangeTimes->{{3.3957868042724953`*^9, 3.395786876134574*^9}, { 539 | 3.395786984353009*^9, 3.39578702807438*^9}, {3.395787441524115*^9, 540 | 3.395787445632443*^9}, {3.396224669757291*^9, 3.396224685126092*^9}, 541 | 3.396760880348172*^9, {3.396760917556632*^9, 542 | 3.3967609487321568`*^9}},ExpressionUUID->"b023b7c1-48e1-4c58-9dba-\ 543 | 7a7e5bf1feba"], 544 | 545 | Cell[BoxData[ 546 | RowBox[{ 547 | RowBox[{"NLDoCommand", "[", 548 | RowBox[{"\"\\"", ",", "10"}], "]"}], ";"}]], "Input", 549 | CellChangeTimes->{{3.396105886712628*^9, 3.3961058908052177`*^9}, 550 | 3.396106012816347*^9, 3.396109760880282*^9, {3.396181444721654*^9, 551 | 3.396181447191556*^9}, {3.3962211382240963`*^9, 3.396221142798656*^9}, { 552 | 3.396224652462543*^9, 553 | 3.396224656045616*^9}},ExpressionUUID->"e87c5764-5dc4-4475-b3cb-\ 554 | e62a743529d0"] 555 | }, Open ]] 556 | }, Open ]], 557 | 558 | Cell[CellGroupData[{ 559 | 560 | Cell["Reporting data from NetLogo", "Subsubsection", 561 | CellChangeTimes->{{3.395787508970413*^9, 3.395787517250642*^9}, { 562 | 3.396142137077729*^9, 3.396142146330214*^9}, 563 | 3.396142183548461*^9},ExpressionUUID->"1350427b-a511-4228-bfd4-\ 564 | d8550479ff07"], 565 | 566 | Cell[CellGroupData[{ 567 | 568 | Cell[TextData[{ 569 | StyleBox["You can retrieve data from NetLogo using", 570 | FontSize->13], 571 | StyleBox[" NLReport[]", 572 | FontFamily->"Courier", 573 | FontSize->13, 574 | FontWeight->"Bold"] 575 | }], "Text", 576 | CellChangeTimes->{{3.395787536812422*^9, 577 | 3.395787554435635*^9}},ExpressionUUID->"0fbcafbb-f3d5-4286-bdaf-\ 578 | 8a3a160b269c"], 579 | 580 | Cell[BoxData[ 581 | RowBox[{"NLReport", "[", "\"\\"", "]"}]], "Input", 582 | CellChangeTimes->{{3.395787558396426*^9, 583 | 3.395787563733197*^9}},ExpressionUUID->"38c82fc7-b91a-4108-a5a2-\ 584 | b2bd3b12cf9b"] 585 | }, Open ]] 586 | }, Open ]], 587 | 588 | Cell[CellGroupData[{ 589 | 590 | Cell[TextData[{ 591 | "Repeat reports ", 592 | StyleBox["n", 593 | FontSlant->"Italic"], 594 | " times" 595 | }], "Subsubsection", 596 | CellChangeTimes->{{3.395787508970413*^9, 3.395787517250642*^9}, { 597 | 3.396142137077729*^9, 3.396142146330214*^9}, 3.396142183548461*^9, { 598 | 3.396142276383976*^9, 3.3961422881506968`*^9}, {3.39614246218495*^9, 599 | 3.396142469126095*^9}, {3.396226111894239*^9, 600 | 3.3962261746675873`*^9}},ExpressionUUID->"e08900b1-25d1-4862-9357-\ 601 | ba4b1af5240a"], 602 | 603 | Cell[TextData[{ 604 | "One of the simplest uses of the NetLogo-", 605 | StyleBox["Mathematica", 606 | FontSlant->"Italic"], 607 | " link is to repeat a command and report information after each successive \ 608 | command." 609 | }], "Text", 610 | CellChangeTimes->{{3.395787536812422*^9, 3.395787554435635*^9}, { 611 | 3.396142314177737*^9, 3.396142318959796*^9}, 3.396225334490507*^9, { 612 | 3.396225403157055*^9, 3.396225529534943*^9}, {3.396225573578827*^9, 613 | 3.396225601632896*^9}, {3.39622618888653*^9, 3.39622618984551*^9}, 614 | 3.396226367295566*^9},ExpressionUUID->"d07221ef-ec46-4ec1-87f6-\ 615 | 8268ae3d8b28"], 616 | 617 | Cell[CellGroupData[{ 618 | 619 | Cell[TextData[{ 620 | "A way carry out these kinds of repetitive tasks is to use ", 621 | StyleBox["NLCommand[]", 622 | FontFamily->"Courier", 623 | FontWeight->"Bold"], 624 | " and ", 625 | StyleBox["NLReport[]", 626 | FontFamily->"Courier", 627 | FontWeight->"Bold"], 628 | " in combination with ", 629 | StyleBox["Table[]", 630 | FontFamily->"Courier", 631 | FontWeight->"Bold"], 632 | "." 633 | }], "Text", 634 | CellChangeTimes->{{3.395787536812422*^9, 3.395787554435635*^9}, { 635 | 3.396142314177737*^9, 3.396142318959796*^9}, 3.396225334490507*^9, { 636 | 3.396225403157055*^9, 3.396225529534943*^9}, {3.396225573578827*^9, 637 | 3.396225601632896*^9}, {3.39622618888653*^9, 3.39622618984551*^9}, { 638 | 3.396226367295566*^9, 639 | 3.396226413915408*^9}},ExpressionUUID->"3e0a865c-90de-4f41-ae6e-\ 640 | baa52bfa3887"], 641 | 642 | Cell[BoxData[ 643 | RowBox[{"Table", "[", 644 | RowBox[{ 645 | RowBox[{ 646 | RowBox[{"NLCommand", "[", "\"\\"", "]"}], ";", 647 | RowBox[{ 648 | "NLReport", "[", "\"\<(burned-trees / initial-trees) * 100\>\"", "]"}]}], 649 | ",", 650 | RowBox[{"{", "20", "}"}]}], "]"}]], "Input", 651 | CellChangeTimes->{{3.396225534126436*^9, 652 | 3.39622555762532*^9}},ExpressionUUID->"38326f94-a23b-4a88-8b21-\ 653 | 1310b4b330a2"] 654 | }, Open ]], 655 | 656 | Cell[CellGroupData[{ 657 | 658 | Cell[TextData[{ 659 | "Tasks like these can be more easily and efficiently executed with ", 660 | StyleBox["NLDoReport[]", 661 | FontFamily->"Courier", 662 | FontSize->13, 663 | FontWeight->"Bold"], 664 | ", which will successively execute a command and return a reporter ", 665 | StyleBox["n", 666 | FontSlant->"Italic"], 667 | " times." 668 | }], "Text", 669 | CellChangeTimes->{{3.395787536812422*^9, 3.395787554435635*^9}, { 670 | 3.396142314177737*^9, 3.396142318959796*^9}, 3.396225334490507*^9, { 671 | 3.396225403157055*^9, 3.396225529534943*^9}, {3.396225609292789*^9, 672 | 3.39622569205997*^9}},ExpressionUUID->"b478cf38-7ff8-4923-9278-\ 673 | d3b1969734bd"], 674 | 675 | Cell[BoxData[ 676 | RowBox[{"NLDoReport", "[", 677 | RowBox[{ 678 | "\"\\"", ",", "\"\<(burned-trees / initial-trees) * 100\>\"", ",", 679 | "20"}], "]"}]], "Input", 680 | CellChangeTimes->{{3.396142299122642*^9, 3.396142299914708*^9}, { 681 | 3.3961423392228737`*^9, 3.396142346859209*^9}, {3.396143367644505*^9, 682 | 3.3961433680270967`*^9}, {3.396143523656822*^9, 3.3961435450989933`*^9}, { 683 | 3.396224986716126*^9, 3.396224987672153*^9}, {3.3962256967009974`*^9, 684 | 3.39622570459059*^9}, {3.396226425738071*^9, 685 | 3.396226426301919*^9}},ExpressionUUID->"d6a49373-0b60-4a6e-8fc2-\ 686 | 1d0a1141f511"] 687 | }, Open ]] 688 | }, Open ]], 689 | 690 | Cell[CellGroupData[{ 691 | 692 | Cell["Repeat reports until a condition is met", "Subsubsection", 693 | CellChangeTimes->{{3.395787508970413*^9, 3.395787517250642*^9}, { 694 | 3.396142137077729*^9, 3.396142146330214*^9}, 3.396142183548461*^9, { 695 | 3.396142276383976*^9, 3.3961422881506968`*^9}, {3.396142474766588*^9, 696 | 3.3961424809586067`*^9}, {3.396226180179728*^9, 697 | 3.396226180435758*^9}},ExpressionUUID->"72a4b853-eb8c-4c4e-b674-\ 698 | e00f8b3d6c41"], 699 | 700 | Cell[TextData[{ 701 | StyleBox["NLDoReportWhile[]", 702 | FontFamily->"Courier", 703 | FontSize->13, 704 | FontWeight->"Bold"], 705 | StyleBox[" ", 706 | FontSize->13, 707 | FontWeight->"Bold"], 708 | StyleBox["is similar to ", 709 | FontSize->13], 710 | StyleBox["NLDoReport[]", 711 | FontFamily->"Courier", 712 | FontWeight->"Bold"], 713 | StyleBox[", but rather than executing n times, it executes until a condition \ 714 | is [not] met.", 715 | FontSize->13] 716 | }], "Text", 717 | CellChangeTimes->{{3.395787536812422*^9, 3.395787554435635*^9}, { 718 | 3.396142314177737*^9, 3.396142318959796*^9}, {3.396142488377985*^9, 719 | 3.39614249695912*^9}, {3.396223885512533*^9, 3.396223888256866*^9}, { 720 | 3.396224538731619*^9, 3.3962245471622353`*^9}, {3.39622621287775*^9, 721 | 3.396226313505357*^9}, {3.3962263547582083`*^9, 722 | 3.396226356297778*^9}},ExpressionUUID->"d503067c-19da-4aac-8641-\ 723 | ca526e9e99df"] 724 | }, Open ]], 725 | 726 | Cell[CellGroupData[{ 727 | 728 | Cell[TextData[{ 729 | "The following executes \"", 730 | StyleBox["go", 731 | FontFamily->"Courier"], 732 | "\" and reports back the % of trees burned until there are no turtles \ 733 | (embers) left." 734 | }], "Text", 735 | CellChangeTimes->{{3.396226322846943*^9, 736 | 3.3962263502340803`*^9}},ExpressionUUID->"abfd5630-bf61-463f-9ab5-\ 737 | 46559035d4c3"], 738 | 739 | Cell[BoxData[{ 740 | RowBox[{ 741 | RowBox[{"NLCommand", "[", 742 | RowBox[{"\"\\"", ",", "\"\\"", ",", "55"}], "]"}], 743 | ";"}], "\[IndentingNewLine]", 744 | RowBox[{"NLDoReportWhile", "[", 745 | RowBox[{ 746 | "\"\\"", ",", "\"\<(burned-trees / initial-trees) * 100\>\"", ",", 747 | "\"\\""}], "]"}]}], "Input", 748 | CellChangeTimes->{{3.396142303723988*^9, 3.396142304474843*^9}, { 749 | 3.396143373288826*^9, 3.396143452088661*^9}, {3.3961435473339148`*^9, 750 | 3.396143549666856*^9}, {3.3962239063240643`*^9, 3.396223910868032*^9}, 751 | 3.3962245306555243`*^9, {3.3962249898491*^9, 3.396224990008513*^9}, 752 | 3.396226318325453*^9},ExpressionUUID->"015d9c7b-0a7b-417b-b87e-\ 753 | 5d78d5e0481f"] 754 | }, Open ]], 755 | 756 | Cell[CellGroupData[{ 757 | 758 | Cell["Defining a simple experiment", "Subsubsection", 759 | CellDingbat->"\[FilledSmallCircle]", 760 | CellChangeTimes->{{3.3957870874618053`*^9, 3.395787098493081*^9}, { 761 | 3.395787484654142*^9, 3.3957874887778788`*^9}, {3.3961425092685537`*^9, 762 | 3.396142515119495*^9}, {3.3961435989080257`*^9, 763 | 3.396143615235107*^9}},ExpressionUUID->"ab1d2c02-6aed-46c4-8d4f-\ 764 | 09561dfb23e3"], 765 | 766 | Cell[CellGroupData[{ 767 | 768 | Cell["\<\ 769 | An interesting phenomena in the Forest Fire model is the abrupt change that \ 770 | occurs in size of forest fires as the density increases. In this example, we \ 771 | will write a short function which sets up the model and returns a list of the \ 772 | percentage of trees burned at each time step, until all embers have burned \ 773 | out.\ 774 | \>", "Text", 775 | CellChangeTimes->{ 776 | 3.3962253296029177`*^9, {3.396226773301379*^9, 3.396226880922888*^9}, { 777 | 3.396274076728718*^9, 778 | 3.396274084018578*^9}},ExpressionUUID->"732a2bce-c6df-4809-a954-\ 779 | ac31d44aed20"], 780 | 781 | Cell[BoxData[ 782 | RowBox[{ 783 | RowBox[{ 784 | RowBox[{"FireTimeSeries", "[", "density_", "]"}], ":=", 785 | RowBox[{"Module", "[", 786 | RowBox[{ 787 | RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 788 | RowBox[{ 789 | RowBox[{"NLCommand", "[", 790 | RowBox[{ 791 | "\"\\"", ",", "density", ",", " ", "\"\\""}], 792 | "]"}], " ", ";", "\[IndentingNewLine]", 793 | RowBox[{"NLDoReportWhile", "[", 794 | RowBox[{ 795 | "\"\\"", ",", "\"\<(burned-trees / initial-trees) * 100\>\"", 796 | ",", "\"\\""}], "]"}]}]}], "\[IndentingNewLine]", 797 | "]"}]}], ";"}]], "Input", 798 | CellChangeTimes->{{3.372447046083118*^9, 3.3724470516348267`*^9}, { 799 | 3.386523593622555*^9, 3.386523595982008*^9}, {3.3927410595476313`*^9, 800 | 3.392741091493318*^9}, {3.396142566699893*^9, 3.3961425675078*^9}, 801 | 3.396142603622685*^9, {3.3962211970839653`*^9, 3.3962212028091707`*^9}, 802 | 3.3962244685878773`*^9},ExpressionUUID->"331e6a31-a129-48f3-8b88-\ 803 | 1e8d4050b3ff"], 804 | 805 | Cell[CellGroupData[{ 806 | 807 | Cell["\<\ 808 | Generate a list of densities to run the model with, ranging from 50 to 70 in \ 809 | increments of 2\ 810 | \>", "Text", 811 | CellChangeTimes->{{3.3962243749134283`*^9, 3.396224414044606*^9}, 812 | 3.3962276413312387`*^9},ExpressionUUID->"ad6b6dc3-e79c-4706-bd4d-\ 813 | b927b2773aaa"], 814 | 815 | Cell[BoxData[ 816 | RowBox[{"densities", "=", 817 | RowBox[{"Table", "[", 818 | RowBox[{"density", ",", 819 | RowBox[{"{", 820 | RowBox[{"density", ",", "50", ",", "70", ",", "2"}], "}"}]}], 821 | "]"}]}]], "Input", 822 | CellChangeTimes->{{3.396224415017231*^9, 823 | 3.39622443047917*^9}},ExpressionUUID->"52846d03-8a35-4018-81c8-\ 824 | 0612d5572ac8"] 825 | }, Open ]], 826 | 827 | Cell[CellGroupData[{ 828 | 829 | Cell[TextData[{ 830 | "Carry out the ", 831 | StyleBox["FireTimeSeries[]", 832 | FontFamily->"Courier", 833 | FontWeight->"Bold"], 834 | " function with each density" 835 | }], "Text", 836 | CellChangeTimes->{{3.3962244427115183`*^9, 3.396224461909689*^9}, { 837 | 3.396226917912079*^9, 838 | 3.396226942164394*^9}},ExpressionUUID->"ae097fe7-cb7c-4b08-ae86-\ 839 | 2981c2a6ba77"], 840 | 841 | Cell[BoxData[{ 842 | RowBox[{ 843 | RowBox[{"NLCommand", "[", "\"\\"", "]"}], 844 | ";"}], "\[IndentingNewLine]", 845 | RowBox[{ 846 | RowBox[{"fireData", "=", 847 | RowBox[{"Map", "[", 848 | RowBox[{"FireTimeSeries", ",", "densities"}], "]"}]}], ";"}]}], "Input", 849 | CellChangeTimes->{{3.372447046083118*^9, 3.3724470516348267`*^9}, { 850 | 3.386523593622555*^9, 3.386523595982008*^9}, {3.3927410595476313`*^9, 851 | 3.392741091493318*^9}, {3.396142566699893*^9, 3.3961425675078*^9}, 852 | 3.396142603622685*^9, 3.396143648650927*^9, {3.396224351730033*^9, 853 | 3.3962243678047113`*^9}},ExpressionUUID->"8d09a2bb-289d-4c88-8c0a-\ 854 | 2bec97fc182c"] 855 | }, Open ]] 856 | }, Open ]] 857 | }, Open ]], 858 | 859 | Cell[CellGroupData[{ 860 | 861 | Cell["Plot time dynamics of each run", "Subsubsection", 862 | CellDingbat->"\[FilledSmallCircle]", 863 | CellChangeTimes->{{3.396142623326745*^9, 3.396142640883491*^9}, 864 | 3.396180316861408*^9},ExpressionUUID->"9887d756-031c-48ca-8fba-\ 865 | a481b650bd17"], 866 | 867 | Cell[CellGroupData[{ 868 | 869 | Cell["\<\ 870 | Now that we have recorded the time dynamics of each configuration, let's take \ 871 | a look at how the fire spreads in first configuration (density = 70)\ 872 | \>", "Text", 873 | CellChangeTimes->{{3.3737352623597593`*^9, 3.3737352743996162`*^9}, { 874 | 3.396221551127593*^9, 3.3962215581811657`*^9}, {3.3962239718373117`*^9, 875 | 3.396223990947464*^9}, {3.3962240352321177`*^9, 876 | 3.3962240516299686`*^9}},ExpressionUUID->"a4206fb5-32b9-461c-848f-\ 877 | 88b6a5f89f92"], 878 | 879 | Cell[BoxData[ 880 | RowBox[{"ListPlot", "[", "\[IndentingNewLine]", 881 | RowBox[{ 882 | RowBox[{"First", "[", "fireData", "]"}], ",", "\[IndentingNewLine]", 883 | RowBox[{"AxesLabel", "\[Rule]", 884 | RowBox[{"{", 885 | RowBox[{"\"\\"", ",", "\"\<% Burned\>\""}], "}"}]}], ",", 886 | RowBox[{ 887 | "PlotLabel", "\[Rule]", " ", 888 | "\"\\""}]}], "\[IndentingNewLine]", 889 | "]"}]], "Input", 890 | CellChangeTimes->{{3.396223648947673*^9, 3.396223663016728*^9}, { 891 | 3.396223693430265*^9, 3.396223797656892*^9}, {3.396223993129858*^9, 892 | 3.396224013463269*^9}, {3.396224306144826*^9, 3.396224306715382*^9}, { 893 | 3.396224339825659*^9, 894 | 3.3962243399086933`*^9}},ExpressionUUID->"3af2c94f-a565-4d30-aa8a-\ 895 | 2e4ad2877cc6"] 896 | }, Open ]], 897 | 898 | Cell[CellGroupData[{ 899 | 900 | Cell["\<\ 901 | With a little bit more work, we can plot all the time series data \ 902 | simultaneously.\ 903 | \>", "Text", 904 | CellChangeTimes->{{3.396224127856937*^9, 905 | 3.396224211397675*^9}},ExpressionUUID->"66abf9a6-1026-4689-9221-\ 906 | 24329bde8d35"], 907 | 908 | Cell[BoxData[ 909 | RowBox[{ 910 | RowBox[{"(*", " ", 911 | RowBox[{ 912 | "create", " ", "a", " ", "color", " ", "for", " ", "each", " ", 913 | "density"}], " ", "*)"}], "\[IndentingNewLine]", 914 | RowBox[{ 915 | RowBox[{ 916 | RowBox[{"numColors", "=", 917 | RowBox[{"Length", "[", "densities", "]"}]}], ";"}], "\n", 918 | RowBox[{ 919 | RowBox[{"densityColors", "=", 920 | RowBox[{"Table", "[", 921 | RowBox[{ 922 | RowBox[{"Blend", "[", 923 | RowBox[{ 924 | RowBox[{"{", " ", 925 | RowBox[{ 926 | RowBox[{"{", 927 | RowBox[{"1", ",", "Yellow"}], "}"}], ",", 928 | RowBox[{"{", 929 | RowBox[{"numColors", ",", "Red"}], "}"}]}], "}"}], ",", "n"}], 930 | "]"}], ",", 931 | RowBox[{"{", 932 | RowBox[{"n", ",", "numColors"}], "}"}]}], "]"}]}], ";"}], " ", 933 | "\[IndentingNewLine]", "\[IndentingNewLine]", 934 | RowBox[{"(*", " ", 935 | RowBox[{"makes", " ", "each", " ", "run", " ", "equal", " ", "length"}], 936 | " ", "*)"}], "\[IndentingNewLine]", 937 | RowBox[{ 938 | RowBox[{"maxSteps", "=", 939 | RowBox[{"Max", "[", 940 | RowBox[{"Length", "/@", "fireData"}], "]"}]}], ";"}], 941 | "\[IndentingNewLine]", 942 | RowBox[{ 943 | RowBox[{"completedData", "=", 944 | RowBox[{ 945 | RowBox[{"(", 946 | RowBox[{ 947 | RowBox[{"PadRight", "[", 948 | RowBox[{"#", ",", "maxSteps", ",", 949 | RowBox[{"Last", "[", "#", "]"}]}], "]"}], "&"}], ")"}], "/@", 950 | "fireData"}]}], ";"}], "\n", "\[IndentingNewLine]", 951 | RowBox[{"ListLinePlot", "[", 952 | RowBox[{ 953 | RowBox[{"Thread", "[", 954 | RowBox[{"Tooltip", "[", 955 | RowBox[{"completedData", ",", "densities"}], "]"}], "]"}], ",", 956 | RowBox[{"PlotStyle", "\[Rule]", "densityColors"}], ",", 957 | RowBox[{"AxesLabel", "\[Rule]", 958 | RowBox[{"{", 959 | RowBox[{"\"\\"", ",", "\"\<% Burned\>\""}], "}"}]}], ",", 960 | RowBox[{ 961 | "PlotLabel", "\[Rule]", " ", 962 | "\"\\""}]}], 963 | "]"}]}]}]], "Input", 964 | CellChangeTimes->{{3.3724415964345818`*^9, 3.3724416190430803`*^9}, { 965 | 3.392741267126142*^9, 3.3927413199337387`*^9}, {3.392741351102785*^9, 966 | 3.3927413848336563`*^9}, 3.3927414295371733`*^9, {3.39274146601645*^9, 967 | 3.392741615664998*^9}, {3.392741911014789*^9, 3.3927420086459637`*^9}, { 968 | 3.396133230420497*^9, 3.396133233246003*^9}, {3.39613337804006*^9, 969 | 3.396133381158099*^9}, {3.396181090127962*^9, 3.39618118458204*^9}, { 970 | 3.396221227691143*^9, 971 | 3.396221239331773*^9}},ExpressionUUID->"2f1810af-b91a-4b9d-82be-\ 972 | 2d1144068ab4"], 973 | 974 | Cell["\<\ 975 | Each line represents the time dynamics of the Forest Fire model run with a \ 976 | different density. Lines are colored by density, ranging from low (yellow) \ 977 | to high (red). Put your mouse over a line to see a tooltip of the density \ 978 | used in each run.\ 979 | \>", "Text", 980 | CellChangeTimes->{{3.3962215651528063`*^9, 3.3962216230072403`*^9}, { 981 | 3.396223396768732*^9, 3.396223405088797*^9}, {3.396223535199917*^9, 982 | 3.396223626480432*^9}, {3.396224220403159*^9, 3.396224279632144*^9}, { 983 | 3.396274086404023*^9, 984 | 3.396274088618862*^9}},ExpressionUUID->"0fa7b4ef-3622-4a92-81a8-\ 985 | 36074dc1e17e"] 986 | }, Open ]] 987 | }, Open ]], 988 | 989 | Cell[CellGroupData[{ 990 | 991 | Cell["\<\ 992 | Plot the phase transition by plotting how (final states) % burned vary with \ 993 | density\ 994 | \>", "Subsubsection", 995 | CellDingbat->"\[FilledSmallCircle]", 996 | CellChangeTimes->{{3.3961426543817177`*^9, 3.3961426875169888`*^9}, { 997 | 3.396180340274786*^9, 998 | 3.39618037311681*^9}},ExpressionUUID->"4cd44617-d1d5-45f7-b826-\ 999 | 742e9bfcf491"], 1000 | 1001 | Cell[BoxData[ 1002 | RowBox[{ 1003 | RowBox[{"(*", 1004 | RowBox[{ 1005 | "pair", " ", "each", " ", "density", " ", "with", " ", "the", " ", "final", 1006 | " ", "%", " ", "burned", " ", "from", " ", "each", " ", "run"}], " ", 1007 | "*)"}], "\[IndentingNewLine]", 1008 | RowBox[{ 1009 | RowBox[{ 1010 | RowBox[{"finalStates", "=", 1011 | RowBox[{"Map", "[", 1012 | RowBox[{"Last", ",", "fireData"}], "]"}]}], ";"}], 1013 | "\[IndentingNewLine]", 1014 | RowBox[{ 1015 | RowBox[{"densityBurnedPairs", "=", 1016 | RowBox[{"Transpose", "[", 1017 | RowBox[{"{", 1018 | RowBox[{"densities", ",", "finalStates"}], "}"}], "]"}]}], ";"}], 1019 | "\[IndentingNewLine]", "\[IndentingNewLine]", 1020 | RowBox[{"ListPlot", "[", 1021 | RowBox[{"densityBurnedPairs", ",", 1022 | RowBox[{"AxesLabel", "\[Rule]", " ", 1023 | RowBox[{"{", 1024 | RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], 1025 | ",", 1026 | RowBox[{"PlotRange", "\[Rule]", " ", 1027 | RowBox[{"{", 1028 | RowBox[{"0", ",", "100"}], "}"}]}], ",", 1029 | RowBox[{ 1030 | "PlotLabel", "\[Rule]", " ", 1031 | "\"\\""}]}], 1032 | "]"}]}]}]], "Input", 1033 | CellChangeTimes->{{3.372441545799267*^9, 3.372441560762669*^9}, { 1034 | 3.372441641719913*^9, 3.3724417193805523`*^9}, {3.3724471214570312`*^9, 1035 | 3.372447126176771*^9}, {3.3737352074021482`*^9, 3.373735211985059*^9}, { 1036 | 3.3927409140826387`*^9, 3.392740917497984*^9}, {3.392741178144747*^9, 1037 | 3.392741239319141*^9}, {3.392742013534223*^9, 3.39274210366293*^9}, { 1038 | 3.3961812039944773`*^9, 3.396181228773465*^9}, {3.396221294884495*^9, 1039 | 3.396221340069619*^9}},ExpressionUUID->"03b0e4b7-5480-45ae-b07f-\ 1040 | 1c651cdb6e38"] 1041 | }, Open ]] 1042 | }, Open ]], 1043 | 1044 | Cell[CellGroupData[{ 1045 | 1046 | Cell["Comparing Empirical and Analytic Distributions in GasLab", "Section", 1047 | CellChangeTimes->{{3.396107921281371*^9, 1048 | 3.3961079408664217`*^9}},ExpressionUUID->"f0973b1c-15ee-4ccc-8e3d-\ 1049 | dec893aac668"], 1050 | 1051 | Cell[CellGroupData[{ 1052 | 1053 | Cell["\<\ 1054 | Load GasLab Free Gas, set it up with 100 particles, and let it run for a \ 1055 | little while\ 1056 | \>", "Text", 1057 | CellChangeTimes->{{3.396110297155974*^9, 3.396110297408245*^9}, { 1058 | 3.3962265399938707`*^9, 1059 | 3.396226555119564*^9}},ExpressionUUID->"b6446a58-bfdc-4edd-8ffb-\ 1060 | 68cc099a5493"], 1061 | 1062 | Cell[BoxData[{ 1063 | RowBox[{ 1064 | RowBox[{ 1065 | RowBox[{"NLLoadModel", "[", "\[IndentingNewLine]", 1066 | RowBox[{"ToFileName", "[", 1067 | RowBox[{ 1068 | RowBox[{"{", 1069 | RowBox[{ 1070 | "$NLModels", ",", "\"\\"", ",", 1071 | "\"\\"", ",", "\"\\""}], "}"}], ",", 1072 | "\"\\""}], "]"}], "\[IndentingNewLine]", "]"}], 1073 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1074 | RowBox[{ 1075 | RowBox[{"NLCommand", "[", 1076 | RowBox[{ 1077 | "\"\\"", ",", "\"\\"", ",", 1078 | "\"\\""}], "]"}], ";"}], "\[IndentingNewLine]", 1079 | RowBox[{ 1080 | RowBox[{"NLDoCommandWhile", "[", 1081 | RowBox[{"\"\\"", ",", "\"\\""}], "]"}], ";"}]}], "Input",\ 1082 | 1083 | CellChangeTimes->{{3.3951680303648453`*^9, 3.395168044513707*^9}, { 1084 | 3.396110303963766*^9, 3.3961103251571093`*^9}, {3.396114419471628*^9, 1085 | 3.396114447565287*^9}, {3.828697396553047*^9, 3.8286973975375566`*^9}, { 1086 | 3.8287001805192013`*^9, 1087 | 3.828700182078027*^9}},ExpressionUUID->"e6035862-95af-4ecc-a8ac-\ 1088 | cdc2ecfd7ea7"] 1089 | }, Open ]], 1090 | 1091 | Cell[CellGroupData[{ 1092 | 1093 | Cell["Reporting lists of values from NetLogo", "Subsubsection", 1094 | CellChangeTimes->{{3.396110522237137*^9, 3.396110523807201*^9}, { 1095 | 3.396110580705538*^9, 1096 | 3.396110601922619*^9}},ExpressionUUID->"d491c790-821e-4703-ba51-\ 1097 | fcff74ac96e9"], 1098 | 1099 | Cell[TextData[{ 1100 | StyleBox["The NetLogo-Mathematica link automatically converts NetLogo lists \ 1101 | into Mathematica lists.\n", 1102 | FontSize->13], 1103 | "This is can be useful for examining distributions. Here, we execute the \ 1104 | model for 20 \"ticks\" and report back the speed of each particle" 1105 | }], "Text", 1106 | CellChangeTimes->{{3.396110341959248*^9, 3.396110370354539*^9}, { 1107 | 3.39611047972845*^9, 3.396110509911014*^9}, {3.396110546379774*^9, 1108 | 3.396110577170083*^9}, {3.396760667756997*^9, 1109 | 3.3967606685502663`*^9}},ExpressionUUID->"e6ae631c-e5e3-4d71-b6b0-\ 1110 | 8062aaa48495"], 1111 | 1112 | Cell[BoxData[ 1113 | RowBox[{"NLReport", "[", "\"\<[speed] of particles\>\"", "]"}]], "Input", 1114 | CellChangeTimes->{{3.379267988860709*^9, 3.379267994704566*^9}, { 1115 | 3.396110445922349*^9, 3.3961104759676743`*^9}, {3.396114416845778*^9, 1116 | 3.396114417569456*^9}},ExpressionUUID->"ee07bfca-6411-4a8e-9b74-\ 1117 | 27de32763ad9"] 1118 | }, Open ]], 1119 | 1120 | Cell[CellGroupData[{ 1121 | 1122 | Cell["\<\ 1123 | Symbolic computing and NetLogo: validating the Maxwell-Boltzmann distribution\ 1124 | \ 1125 | \>", "Subsubsection", 1126 | CellDingbat->"\[FilledSmallCircle]", 1127 | CellChangeTimes->{{3.396110691980526*^9, 3.396110747696163*^9}, { 1128 | 3.396143314570972*^9, 3.396143320173112*^9}, {3.39622709658848*^9, 1129 | 3.3962271107708807`*^9}},ExpressionUUID->"bd55c7e6-ef31-4dac-bbdf-\ 1130 | b183018c3255"], 1131 | 1132 | Cell[CellGroupData[{ 1133 | 1134 | Cell["\<\ 1135 | Set up the model with 500 particles and collect 40 readings of each \ 1136 | particle's speed, every 50 steps. \ 1137 | \>", "Text", 1138 | CellChangeTimes->{{3.396110652567731*^9, 1139 | 3.396110684541054*^9}},ExpressionUUID->"93c7589f-2bd8-4360-848b-\ 1140 | b0a662513bb0"], 1141 | 1142 | Cell[BoxData[{ 1143 | RowBox[{ 1144 | RowBox[{ 1145 | RowBox[{"NLCommand", "[", 1146 | RowBox[{ 1147 | "\"\\"", ",", "\"\\"", ",", 1148 | "\"\\""}], "]"}], ";"}], 1149 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1150 | RowBox[{ 1151 | RowBox[{"speeds", "=", 1152 | RowBox[{"Flatten", "[", " ", 1153 | RowBox[{"NLDoReport", "[", 1154 | RowBox[{ 1155 | "\"\\"", ",", "\"\<[speed] of particles\>\"", ",", 1156 | "40"}], "]"}], " ", "]"}]}], ";"}]}], "Input", 1157 | CellChangeTimes->{{3.379268047038845*^9, 3.379268056723612*^9}, { 1158 | 3.396110380480146*^9, 3.396110382374926*^9}, {3.396110638401329*^9, 1159 | 3.39611063872645*^9}, {3.396114450725711*^9, 1160 | 3.3961144559242887`*^9}},ExpressionUUID->"cfc3e77b-38e9-4833-9850-\ 1161 | 902ac97df53e"] 1162 | }, Open ]], 1163 | 1164 | Cell[CellGroupData[{ 1165 | 1166 | Cell[TextData[{ 1167 | "Compare distribution of speeds with the theoretical Maxwell-Boltzmann \ 1168 | distribution for a 2D gas, ", 1169 | Cell[BoxData[ 1170 | FormBox[ 1171 | RowBox[{ 1172 | RowBox[{"B", "(", "v", ")"}], "=", 1173 | RowBox[{"v", " ", 1174 | SuperscriptBox["\[ExponentialE]", 1175 | FractionBox[ 1176 | RowBox[{ 1177 | RowBox[{"-", "m"}], " ", 1178 | SuperscriptBox["v", "2"]}], 1179 | RowBox[{"2", " ", "k", " ", "T"}]]]}]}], TraditionalForm]], 1180 | ExpressionUUID->"eaa43edd-f4fb-4ed1-97da-25e329f016f7"] 1181 | }], "Text", 1182 | CellChangeTimes->{ 1183 | 3.3957777625958757`*^9, {3.3961108260961113`*^9, 1184 | 3.396110841730488*^9}},ExpressionUUID->"e8293c0a-d59e-406d-ae1a-\ 1185 | bd0491a946f1"], 1186 | 1187 | Cell[CellGroupData[{ 1188 | 1189 | Cell[BoxData[ 1190 | RowBox[{ 1191 | RowBox[{ 1192 | RowBox[{"{", 1193 | RowBox[{"k", ",", "m", ",", "T"}], "}"}], "=", 1194 | RowBox[{"{", 1195 | RowBox[{"1", ",", "1", ",", 1196 | RowBox[{"NLReport", "[", "\"\\"", "]"}]}], 1197 | "}"}]}], ";"}]], "Input", 1198 | CellChangeTimes->{{3.36043477564152*^9, 3.36043477915644*^9}, 1199 | 3.373737411565402*^9, {3.379268113294259*^9, 3.379268117938326*^9}, { 1200 | 3.379268172752152*^9, 3.3792681841984663`*^9}, {3.392741702656081*^9, 1201 | 3.3927417172929907`*^9}, {3.392741752892951*^9, 3.392741794127122*^9}, { 1202 | 3.392741833058958*^9, 3.392741892364025*^9}, 3.396099646142276*^9, { 1203 | 3.3961101697582808`*^9, 3.396110172741024*^9}, {3.396110266244479*^9, 1204 | 3.396110266552348*^9}, {3.396112384310367*^9, 3.396112386956141*^9}, { 1205 | 3.3961359595606003`*^9, 1206 | 3.396135964258638*^9}},ExpressionUUID->"8fdfb5db-ced0-426e-8e32-\ 1207 | d22046952b0c"], 1208 | 1209 | Cell[BoxData[{ 1210 | RowBox[{ 1211 | RowBox[{ 1212 | RowBox[{"B", "[", "v_", "]"}], ":=", 1213 | RowBox[{"v", " ", 1214 | SuperscriptBox["E", 1215 | FractionBox[ 1216 | RowBox[{ 1217 | RowBox[{"-", "m"}], " ", 1218 | SuperscriptBox["v", "2"]}], 1219 | RowBox[{"2", "k", " ", "T"}]]]}]}], ";"}], "\[IndentingNewLine]", 1220 | RowBox[{ 1221 | RowBox[{"normalizer", "=", " ", 1222 | RowBox[{ 1223 | SubsuperscriptBox["\[Integral]", "0", "\[Infinity]"], 1224 | RowBox[{ 1225 | RowBox[{"B", "[", "v", "]"}], 1226 | RowBox[{"\[DifferentialD]", "v"}]}]}]}], ";"}], "\[IndentingNewLine]", 1227 | RowBox[{ 1228 | RowBox[{"theoretical", "=", 1229 | RowBox[{"Plot", "[", 1230 | RowBox[{ 1231 | FractionBox[ 1232 | RowBox[{"B", "[", "v", "]"}], "normalizer"], ",", 1233 | RowBox[{"{", 1234 | RowBox[{"v", ",", "0", ",", 1235 | RowBox[{"Max", "[", "speeds", "]"}]}], "}"}], ",", 1236 | RowBox[{"PlotStyle", "\[Rule]", " ", 1237 | RowBox[{"{", 1238 | RowBox[{ 1239 | RowBox[{"Darker", "[", "Red", "]"}], ",", 1240 | RowBox[{"Thickness", "[", "0.008", "]"}]}], "}"}]}]}], "]"}]}], 1241 | ";"}], "\[IndentingNewLine]", 1242 | RowBox[{ 1243 | RowBox[{ 1244 | RowBox[{"empirical", "=", 1245 | RowBox[{"Histogram", "[", 1246 | RowBox[{"speeds", ",", 1247 | RowBox[{"{", "1", "}"}], ",", " ", "\"\\""}], "]"}]}], ";"}], 1248 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1249 | RowBox[{"Show", "[", 1250 | RowBox[{"empirical", ",", "theoretical", ",", 1251 | RowBox[{ 1252 | "PlotLabel", "\[Rule]", " ", 1253 | "\"\\""}]}], "]"}]}], "Input", 1255 | CellChangeTimes->{{3.36043477564152*^9, 3.36043477915644*^9}, 1256 | 3.373737411565402*^9, {3.379268113294259*^9, 3.379268117938326*^9}, { 1257 | 3.379268172752152*^9, 3.3792681841984663`*^9}, {3.392741702656081*^9, 1258 | 3.3927417172929907`*^9}, {3.392741752892951*^9, 3.392741794127122*^9}, { 1259 | 3.392741833058958*^9, 3.392741892364025*^9}, 3.396099646142276*^9, { 1260 | 3.3961101697582808`*^9, 3.396110172741024*^9}, {3.396110266244479*^9, 1261 | 3.396110266552348*^9}, {3.396112384310367*^9, 3.396112386956141*^9}, { 1262 | 3.3961359595606003`*^9, 3.396135964258638*^9}, 3.396143334903572*^9, { 1263 | 3.828697415425758*^9, 1264 | 3.828697419874448*^9}},ExpressionUUID->"e8495ab0-4b5a-49c5-9e13-\ 1265 | a2ad141da18e"] 1266 | }, Open ]] 1267 | }, Open ]] 1268 | }, Open ]] 1269 | }, Open ]], 1270 | 1271 | Cell[CellGroupData[{ 1272 | 1273 | Cell["Screenshot Sequences with Termites", "Section", 1274 | CellChangeTimes->{{3.395788123593336*^9, 3.395788129069022*^9}, { 1275 | 3.396108216457284*^9, 3.3961082309724607`*^9}, 3.396180758502833*^9, { 1276 | 3.3962205354740877`*^9, 1277 | 3.3962205622064734`*^9}},ExpressionUUID->"4c072799-96f1-4c2e-aed2-\ 1278 | 076730b8fd83"], 1279 | 1280 | Cell[BoxData[{ 1281 | RowBox[{ 1282 | RowBox[{"NLLoadModel", "[", 1283 | RowBox[{"ToFileName", "[", 1284 | RowBox[{ 1285 | RowBox[{"{", 1286 | RowBox[{ 1287 | "$NLModels", ",", "\"\\"", ",", "\"\\""}], 1288 | "}"}], ",", "\"\\""}], "]"}], "]"}], 1289 | ";"}], "\[IndentingNewLine]", 1290 | RowBox[{ 1291 | RowBox[{"NLCommand", "[", 1292 | RowBox[{"\"\\"", ",", "\"\\""}], "]"}], 1293 | ";"}]}], "Input", 1294 | CellChangeTimes->{{3.3951681368278418`*^9, 3.395168142180542*^9}, { 1295 | 3.3961108562093487`*^9, 3.3961108584350357`*^9}, {3.396143809421916*^9, 1296 | 3.396143815484503*^9}, {3.8286983210579844`*^9, 3.8286983228205957`*^9}, { 1297 | 3.828700513119526*^9, 1298 | 3.8287005150919456`*^9}},ExpressionUUID->"499094e7-5280-41c9-9df5-\ 1299 | a9e270ae3d7f"], 1300 | 1301 | Cell[CellGroupData[{ 1302 | 1303 | Cell["Capturing NetLogo patch colors", "Subsubsection", 1304 | CellChangeTimes->{{3.3961108684114027`*^9, 1305 | 3.396110883235055*^9}},ExpressionUUID->"75d88cec-141c-4622-9556-\ 1306 | 0f513ae071ec"], 1307 | 1308 | Cell[TextData[{ 1309 | StyleBox["One can use ", 1310 | FontSize->13], 1311 | StyleBox["NLGetPatches[] ", 1312 | FontFamily->"Courier", 1313 | FontSize->13, 1314 | FontWeight->"Bold"], 1315 | StyleBox["to get values from patches.", 1316 | FontSize->13], 1317 | "\nIn this case we are reporting back NetLogo patch colors." 1318 | }], "Text", 1319 | CellChangeTimes->{{3.396110913172263*^9, 3.39611095554125*^9}, { 1320 | 3.396111265168193*^9, 3.396111267637093*^9}, {3.396111557464848*^9, 1321 | 3.396111570086865*^9}, {3.396181302454051*^9, 3.3961813049974623`*^9}, { 1322 | 3.396760627210186*^9, 3.396760628785536*^9}, {3.3967612267387667`*^9, 1323 | 3.3967612271019783`*^9}},ExpressionUUID->"79796eeb-1825-4c97-80e6-\ 1324 | 917220f4a0ab"], 1325 | 1326 | Cell[BoxData[ 1327 | RowBox[{"ArrayPlot", "[", 1328 | RowBox[{ 1329 | RowBox[{"NLGetPatches", "[", "\"\\"", "]"}], ",", 1330 | RowBox[{"ColorRules", "\[Rule]", " ", 1331 | RowBox[{"{", 1332 | RowBox[{ 1333 | RowBox[{"0.", "\[Rule]", " ", "Black"}], ",", 1334 | RowBox[{"45.", "\[Rule]", " ", "Yellow"}]}], "}"}]}]}], "]"}]], "Input",\ 1335 | 1336 | CellChangeTimes->{{3.386524206052829*^9, 1337 | 3.386524213176352*^9}},ExpressionUUID->"3bbc9511-b764-4512-bcdc-\ 1338 | b81fefa2c583"] 1339 | }, Open ]], 1340 | 1341 | Cell[CellGroupData[{ 1342 | 1343 | Cell["Collecting multiple \"screenshots\"", "Subsubsection", 1344 | CellDingbat->"\[FilledSmallCircle]", 1345 | CellChangeTimes->{{3.396111698132924*^9, 3.396111715124728*^9}, { 1346 | 3.396112223003499*^9, 3.396112235422488*^9}, {3.39614315399354*^9, 1347 | 3.396143155164239*^9}},ExpressionUUID->"ce76dc78-d761-47b6-b064-\ 1348 | 6fb190ca5cae"], 1349 | 1350 | Cell[CellGroupData[{ 1351 | 1352 | Cell[TextData[{ 1353 | StyleBox["CaptureTermiteProgress[] ", 1354 | FontFamily->"Courier", 1355 | FontWeight->"Bold"], 1356 | "asks the turtles to ", 1357 | StyleBox["\"go\"", 1358 | FontFamily->"Courier"], 1359 | " 20 times and take a \"screenshot\" using ", 1360 | StyleBox["NLGetPatches[]", 1361 | FontFamily->"Courier", 1362 | FontWeight->"Bold"], 1363 | "." 1364 | }], "Text", 1365 | CellChangeTimes->{{3.392742349283717*^9, 3.39274235003467*^9}, { 1366 | 3.3927424075512753`*^9, 3.392742412989387*^9}, {3.392742511496426*^9, 1367 | 3.392742557385543*^9}, {3.396111758233015*^9, 3.396111789048123*^9}, { 1368 | 3.396226627958653*^9, 3.396226628898368*^9}, {3.396760403906468*^9, 1369 | 3.3967604048185787`*^9}, {3.396760605732288*^9, 1370 | 3.396760612617296*^9}},ExpressionUUID->"0bd0b641-de60-4ea1-a2f2-\ 1371 | 7f5e9037713c"], 1372 | 1373 | Cell[BoxData[ 1374 | RowBox[{ 1375 | RowBox[{ 1376 | RowBox[{"CaptureTermiteProgress", "[", "]"}], ":=", 1377 | RowBox[{"Module", "[", 1378 | RowBox[{ 1379 | RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 1380 | RowBox[{ 1381 | RowBox[{"NLDoCommand", "[", 1382 | RowBox[{"\"\\"", ",", "20"}], "]"}], ";", 1383 | "\[IndentingNewLine]", 1384 | RowBox[{"NLGetPatches", "[", "\"\\"", "]"}]}]}], 1385 | "\[IndentingNewLine]", "]"}]}], ";"}]], "Input", 1386 | CellChangeTimes->{{3.373734209937935*^9, 3.373734258929878*^9}, { 1387 | 3.392742378550687*^9, 3.392742392245348*^9}, 3.396111611228149*^9, { 1388 | 3.3961116587089453`*^9, 1389 | 3.3961116726442633`*^9}},ExpressionUUID->"181b4a79-d081-4650-893f-\ 1390 | 481e0cb485e0"] 1391 | }, Open ]], 1392 | 1393 | Cell[CellGroupData[{ 1394 | 1395 | Cell[TextData[{ 1396 | "Set up the model, and repeat ", 1397 | StyleBox["CaptureTermiteProgress[] ", 1398 | FontFamily->"Courier", 1399 | FontWeight->"Bold"], 1400 | "six times to capture several \"screen shots\"." 1401 | }], "Text", 1402 | CellChangeTimes->{{3.396226644869935*^9, 3.396226679308428*^9}, { 1403 | 3.3967604206437893`*^9, 1404 | 3.3967604219150763`*^9}},ExpressionUUID->"0829599b-a521-4746-b606-\ 1405 | c21fec580558"], 1406 | 1407 | Cell[BoxData[{ 1408 | RowBox[{"NLCommand", "[", "\"\\"", "]"}], "\[IndentingNewLine]", 1409 | RowBox[{ 1410 | RowBox[{"patchShots", "=", 1411 | RowBox[{"Table", "[", 1412 | RowBox[{ 1413 | RowBox[{"CaptureTermiteProgress", "[", "]"}], ",", 1414 | RowBox[{"{", "6", "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", 1415 | RowBox[{ 1416 | RowBox[{"renderedShots", "=", 1417 | RowBox[{"Map", "[", 1418 | RowBox[{ 1419 | RowBox[{ 1420 | RowBox[{"Rasterize", "[", 1421 | RowBox[{"ArrayPlot", "[", 1422 | RowBox[{"#", ",", 1423 | RowBox[{"ColorRules", "\[Rule]", " ", 1424 | RowBox[{"{", 1425 | RowBox[{ 1426 | RowBox[{"0.", "\[Rule]", " ", "Black"}], ",", 1427 | RowBox[{"45.", "\[Rule]", " ", "Yellow"}]}], "}"}]}]}], "]"}], 1428 | "]"}], "&"}], ",", "patchShots"}], "]"}]}], ";"}]}], "Input", 1429 | CellChangeTimes->{{3.373734282518489*^9, 3.3737343004493017`*^9}, { 1430 | 3.373734450313445*^9, 3.37373445211784*^9}, {3.392742374942038*^9, 1431 | 3.392742375326643*^9}, 3.396111676233756*^9, {3.396111895074296*^9, 1432 | 3.396111909888338*^9}, {3.3961120549043207`*^9, 3.3961120599233627`*^9}, { 1433 | 3.39622668376633*^9, 1434 | 3.396226684744618*^9}},ExpressionUUID->"4654274e-5a25-4138-8d33-\ 1435 | f33b63486191"] 1436 | }, Open ]], 1437 | 1438 | Cell[CellGroupData[{ 1439 | 1440 | Cell["Display screenshot simultaneously in a grid", "Subsubsection", 1441 | CellDingbat->"\[FilledSmallCircle]", 1442 | CellChangeTimes->{{3.396111698132924*^9, 3.396111715124728*^9}, { 1443 | 3.396112223003499*^9, 3.396112235422488*^9}, {3.39614315399354*^9, 1444 | 3.396143188181542*^9}},ExpressionUUID->"0793d1c4-19f5-418f-84fc-\ 1445 | 726a10bf0987"], 1446 | 1447 | Cell["Display each consecutive screenshot simultaneously in a grid", "Text", 1448 | CellChangeTimes->{{3.3961119268588877`*^9, 1449 | 3.396111948484036*^9}},ExpressionUUID->"be58639b-2f2f-4470-8270-\ 1450 | be3d806da7e5"], 1451 | 1452 | Cell[BoxData[ 1453 | RowBox[{"GraphicsGrid", "[", 1454 | RowBox[{ 1455 | RowBox[{"Partition", "[", 1456 | RowBox[{"renderedShots", ",", "3"}], "]"}], ",", 1457 | RowBox[{"ImageSize", "\[Rule]", " ", "500"}]}], "]"}]], "Input", 1458 | CellChangeTimes->{{3.373734353515912*^9, 3.373734399413227*^9}, { 1459 | 3.373734454919944*^9, 3.373734464559782*^9}, {3.373734512851533*^9, 1460 | 3.3737345147459393`*^9}, 3.37373455863293*^9, {3.3927424641964684`*^9, 1461 | 3.3927424803115587`*^9}, 3.39611191284937*^9, {3.3961121384452*^9, 1462 | 3.396112146812389*^9}, 1463 | 3.396760213897159*^9},ExpressionUUID->"eb7f4ccf-d133-46a1-a53e-\ 1464 | bf874d93694c"] 1465 | }, Open ]], 1466 | 1467 | Cell[CellGroupData[{ 1468 | 1469 | Cell["Animate screenshots", "Subsubsection", 1470 | CellDingbat->"\[FilledSmallCircle]", 1471 | CellChangeTimes->{{3.396111698132924*^9, 3.396111715124728*^9}, { 1472 | 3.396112223003499*^9, 3.396112235422488*^9}, {3.39614315399354*^9, 1473 | 3.396143155164239*^9}, {3.396143197737247*^9, 1474 | 3.396143204981821*^9}},ExpressionUUID->"e287bf28-934d-4afb-bc2f-\ 1475 | a52dc2d25dec"], 1476 | 1477 | Cell["\<\ 1478 | Animate the screenshots and replay the model backwards and forwards\ 1479 | \>", "Text", 1480 | CellChangeTimes->{{3.396111953321178*^9, 1481 | 3.3961119691249332`*^9}},ExpressionUUID->"725b5b3f-d627-482b-a98c-\ 1482 | d2418593fbbc"], 1483 | 1484 | Cell[BoxData[ 1485 | RowBox[{"ListAnimate", "[", "renderedShots", "]"}]], "Input", 1486 | CellChangeTimes->{{3.3961118600269213`*^9, 3.3961118625225677`*^9}, { 1487 | 3.3961119988624973`*^9, 3.396112016527835*^9}, 3.396112185610132*^9, { 1488 | 3.396760202267214*^9, 1489 | 3.3967602028826637`*^9}},ExpressionUUID->"5c1e8396-7f97-4fd6-8954-\ 1490 | b0828479bb19"] 1491 | }, Open ]] 1492 | }, Open ]] 1493 | }, Open ]], 1494 | 1495 | Cell[CellGroupData[{ 1496 | 1497 | Cell["Plotting Terrain in 3D", "Section", 1498 | CellChangeTimes->{{3.396180812395071*^9, 1499 | 3.3961808126593027`*^9}},ExpressionUUID->"ae3205ea-19de-400d-b2d9-\ 1500 | 8dba6fb685a3"], 1501 | 1502 | Cell["Load the erosion model and set it up", "Text", 1503 | CellChangeTimes->{{3.396142924957655*^9, 3.3961429283566628`*^9}, 1504 | 3.3961429700308313`*^9},ExpressionUUID->"047d2537-c4b4-43e1-94a0-\ 1505 | 4c97617cbf91"], 1506 | 1507 | Cell[BoxData[{ 1508 | RowBox[{"NLLoadModel", "[", 1509 | RowBox[{"ToFileName", "[", 1510 | RowBox[{ 1511 | RowBox[{"{", 1512 | RowBox[{ 1513 | "$NLModels", ",", "\"\\"", ",", 1514 | "\"\\""}], "}"}], ",", "\"\\""}], "]"}], 1515 | "]"}], "\[IndentingNewLine]", 1516 | RowBox[{"NLCommand", "[", 1517 | RowBox[{ 1518 | "\"\\"", ",", "\"\\"", ",", 1519 | "\"\\"", ",", " ", "\"\\"", ",", 1520 | "\"\\""}], "]"}], "\[IndentingNewLine]", 1521 | RowBox[{"NLDoCommand", "[", 1522 | RowBox[{"\"\\"", ",", "120"}], "]"}]}], "Input", 1523 | CellChangeTimes->{{3.3961317209028587`*^9, 3.396131723366119*^9}, { 1524 | 3.3961429632977858`*^9, 3.396142967219677*^9}, {3.396181323257717*^9, 1525 | 3.396181343328477*^9}, {3.396760250251439*^9, 3.3967602503454113`*^9}, { 1526 | 3.8287005568415318`*^9, 1527 | 3.8287005577331333`*^9}},ExpressionUUID->"83101098-7ee6-4d9f-bd96-\ 1528 | 2d5fbf4a0bbe"], 1529 | 1530 | Cell["Execute with the new setup", "Text",ExpressionUUID->"e4da9e2b-b571-4ab4-b2c1-350eb3ec62c2"], 1531 | 1532 | Cell["Plotting elevation information in 3D", "Subsubsection", 1533 | CellDingbat->"\[FilledSmallCircle]", 1534 | CellChangeTimes->{{3.396111698132924*^9, 3.396111715124728*^9}, { 1535 | 3.396112223003499*^9, 3.396112235422488*^9}, {3.39614294818438*^9, 1536 | 3.3961429565419083`*^9}},ExpressionUUID->"e82ce3c9-c202-43be-8856-\ 1537 | b6d0471ec54d"], 1538 | 1539 | Cell[TextData[{ 1540 | StyleBox["NLGetPatches[]", 1541 | FontFamily->"Courier", 1542 | FontWeight->"Bold"], 1543 | " can report any kind of patch data, not just colors. For example, one can \ 1544 | plot the patch variable ", 1545 | StyleBox["elevation", 1546 | FontSlant->"Italic"], 1547 | " to construct a 3D terrain plot." 1548 | }], "Text", 1549 | CellChangeTimes->{{3.396114505563499*^9, 1550 | 3.396114580340993*^9}},ExpressionUUID->"4c91c17a-3240-45d0-9b2d-\ 1551 | 55e9eaee0f2d"], 1552 | 1553 | Cell[BoxData[{ 1554 | RowBox[{ 1555 | RowBox[{ 1556 | RowBox[{"elevations", "=", 1557 | RowBox[{"NLGetPatches", "[", "\"\\"", "]"}]}], ";"}], 1558 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1559 | RowBox[{"ListPlot3D", "[", 1560 | RowBox[{"elevations", ",", 1561 | RowBox[{"Mesh", "\[Rule]", " ", "None"}], ",", 1562 | RowBox[{"ColorFunction", "\[Rule]", "\"\\""}], ",", 1563 | RowBox[{"Mesh", "\[Rule]", " ", "None"}], ",", 1564 | RowBox[{"Axes", "\[Rule]", " ", "None"}], ",", 1565 | RowBox[{"Boxed", "\[Rule]", " ", "False"}], ",", 1566 | RowBox[{"ViewPoint", "\[Rule]", 1567 | RowBox[{"{", 1568 | RowBox[{"0.8", ",", 1569 | RowBox[{"-", "1.5"}], ",", "2.9"}], "}"}]}]}], "]"}]}], "Input", 1570 | CellChangeTimes->{{3.3927439156625967`*^9, 3.392743933542281*^9}, 1571 | 3.394478305472227*^9, {3.396142984588194*^9, 1572 | 3.3961429867618523`*^9}},ExpressionUUID->"ffb96276-1ec6-41a5-81c0-\ 1573 | 8133dfd07aa2"] 1574 | }, Open ]], 1575 | 1576 | Cell[CellGroupData[{ 1577 | 1578 | Cell["Plotting Networks with Preferential Attachment", "Section", 1579 | CellChangeTimes->{{3.36051111157344*^9, 3.36051112495524*^9}, { 1580 | 3.396180767101864*^9, 1581 | 3.396180774121359*^9}},ExpressionUUID->"00b9613a-b38e-4f97-af5d-\ 1582 | 0b11cfc19de8"], 1583 | 1584 | Cell[CellGroupData[{ 1585 | 1586 | Cell["Load the Preferential Attachment model", "Text", 1587 | CellChangeTimes->{{3.36051131546008*^9, 1588 | 3.36051133028997*^9}},ExpressionUUID->"9ee58d67-f01d-4435-96ca-\ 1589 | c85dfb8054fa"], 1590 | 1591 | Cell[BoxData[ 1592 | RowBox[{"NLLoadModel", "[", 1593 | RowBox[{"ToFileName", "[", 1594 | RowBox[{ 1595 | RowBox[{"{", 1596 | RowBox[{ 1597 | "$NLModels", ",", "\"\\"", ",", "\"\\""}], 1598 | "}"}], ",", "\"\\""}], "]"}], 1599 | "]"}]], "Input", 1600 | CellChangeTimes->{{3.3951682416989393`*^9, 3.395168254827293*^9}, { 1601 | 3.828700577273048*^9, 1602 | 3.8287005779403343`*^9}},ExpressionUUID->"1aa8e85d-ac83-4dfd-931d-\ 1603 | ea10d98cff49"], 1604 | 1605 | Cell["Set up the model and generate about 2000 nodes.", "Text", 1606 | CellChangeTimes->{{3.396114610766127*^9, 3.396114621918466*^9}, { 1607 | 3.396136756041065*^9, 1608 | 3.396136766800248*^9}},ExpressionUUID->"13017292-2794-4885-bee2-\ 1609 | ccf620b14ee7"], 1610 | 1611 | Cell[BoxData[{ 1612 | RowBox[{ 1613 | RowBox[{ 1614 | "NLCommand", "[", 1615 | "\"\\"", "]"}], 1616 | ";"}], "\[IndentingNewLine]", 1617 | RowBox[{ 1618 | RowBox[{"NLDoCommand", "[", 1619 | RowBox[{"\"\\"", ",", "2000"}], "]"}], ";"}]}], "Input", 1620 | CellChangeTimes->{{3.3605111438509*^9, 3.36051114633301*^9}, { 1621 | 3.36051118816163*^9, 3.36051119169433*^9}, {3.36051140091979*^9, 1622 | 3.36051140433519*^9}, {3.36051146280069*^9, 3.36051146373706*^9}, { 1623 | 3.3737350009525146`*^9, 3.3737350050885677`*^9}, {3.373735531090149*^9, 1624 | 3.3737355335698843`*^9}, {3.3737374622173853`*^9, 3.373737470518716*^9}, { 1625 | 3.396114606088084*^9, 3.396114607033658*^9}, {3.3961367494546967`*^9, 1626 | 3.396136771538135*^9}},ExpressionUUID->"6ef9de3f-bf0a-4290-93f9-\ 1627 | cc39eda8b0f8"], 1628 | 1629 | Cell[CellGroupData[{ 1630 | 1631 | Cell["Capturing Graphs in NetLogo", "Subsubsection", 1632 | CellChangeTimes->{{3.396114644917355*^9, 3.396114677320225*^9}, { 1633 | 3.396114778511674*^9, 3.396114780963026*^9}, {3.3961400935699778`*^9, 1634 | 3.396140099303857*^9}, 1635 | 3.396140577695508*^9},ExpressionUUID->"0b431835-28a7-4eac-84dc-\ 1636 | 365c1c2eaa50"], 1637 | 1638 | Cell[TextData[{ 1639 | StyleBox["Capture the network with", 1640 | FontSize->13], 1641 | " ", 1642 | StyleBox["NLGetGraph[]", 1643 | FontFamily->"Courier", 1644 | FontSize->14, 1645 | FontWeight->"Bold"] 1646 | }], "Text", 1647 | CellChangeTimes->{{3.392744029550304*^9, 3.392744055639029*^9}, { 1648 | 3.396114746172495*^9, 3.396114750505921*^9}, {3.396140111777721*^9, 1649 | 3.396140120432976*^9}, 3.3961405776957817`*^9, 1650 | 3.3962276751733313`*^9},ExpressionUUID->"2189bb3d-e5e4-492f-8530-\ 1651 | 62fa7b9bbfed"], 1652 | 1653 | Cell[BoxData[ 1654 | RowBox[{ 1655 | RowBox[{"network", "=", 1656 | RowBox[{"NLGetGraph", "[", "\"\\"", "]"}]}], ";"}]], "Input", 1657 | CellChangeTimes->{{3.36051115190955*^9, 3.36051115219736*^9}, { 1658 | 3.36051138464014*^9, 3.36051138490074*^9}, {3.3605114244651*^9, 1659 | 3.36051142600582*^9}, {3.392744007190115*^9, 3.392744009575431*^9}, { 1660 | 3.396099540729026*^9, 3.396099544318714*^9}, {3.396114603937306*^9, 1661 | 3.3961146289440413`*^9}, 3.396136778618438*^9, {3.396140027964641*^9, 1662 | 3.3961400286265707`*^9}, 1663 | 3.3961405776961946`*^9},ExpressionUUID->"da03a136-b56c-48ff-9d09-\ 1664 | 898c8196f8bb"], 1665 | 1666 | Cell[TextData[{ 1667 | "By default, ", 1668 | StyleBox["NLGetGraph[] ", 1669 | FontFamily->"Courier", 1670 | FontWeight->"Bold"], 1671 | "uses the generic link breed, ", 1672 | StyleBox["links", 1673 | FontSlant->"Italic"] 1674 | }], "Text", 1675 | CellChangeTimes->{{3.3961401066377983`*^9, 3.396140137953661*^9}, 1676 | 3.3961405776979933`*^9},ExpressionUUID->"0ea81582-b302-44da-8645-\ 1677 | fbad01766947"], 1678 | 1679 | Cell[BoxData[ 1680 | RowBox[{ 1681 | RowBox[{"network", "=", 1682 | RowBox[{"NLGetGraph", "[", "]"}]}], ";"}]], "Input", 1683 | CellChangeTimes->{{3.3961401436758423`*^9, 3.396140149741847*^9}, 1684 | 3.396140577698303*^9},ExpressionUUID->"50396e56-a24b-4a6e-914d-\ 1685 | 025b7f6ef2d0"], 1686 | 1687 | Cell[TextData[{ 1688 | StyleBox["NLGetGraph[] ", 1689 | FontFamily->"Courier", 1690 | FontWeight->"Bold"], 1691 | "returns a list of rules of the form ", 1692 | StyleBox["outNode\[Rule] inNode, ", 1693 | FontSlant->"Italic"], 1694 | "which can be used by NetLogo's visualization functions, where ", 1695 | StyleBox["outNode and inNode ", 1696 | FontSlant->"Italic"], 1697 | "are the who numbers of agents in the network." 1698 | }], "Text", 1699 | CellChangeTimes->{{3.3961394079897537`*^9, 3.396139479599832*^9}, { 1700 | 3.396140066903664*^9, 3.3961400866877127`*^9}, 3.396140577699924*^9, { 1701 | 3.396140634148568*^9, 3.396140689801903*^9}, 1702 | 3.396274106814314*^9},ExpressionUUID->"5532cd75-cd35-4c6d-aceb-\ 1703 | f00f02c0c723"], 1704 | 1705 | Cell[BoxData[ 1706 | RowBox[{"Short", "[", "network", "]"}]], "Input", 1707 | CellChangeTimes->{{3.3961367907485847`*^9, 3.396136792977703*^9}, { 1708 | 3.3961400435584393`*^9, 3.39614004601884*^9}, 1709 | 3.3961405777002296`*^9},ExpressionUUID->"0459db0f-0b7f-4fed-9ff7-\ 1710 | b8d194b60652"] 1711 | }, Open ]], 1712 | 1713 | Cell[CellGroupData[{ 1714 | 1715 | Cell["Visualizing NetLogo graphs", "Subsubsection", 1716 | CellDingbat->"\[FilledSmallCircle]", 1717 | CellChangeTimes->{{3.3961402501662188`*^9, 3.396140267808736*^9}, 1718 | 3.39614057770438*^9},ExpressionUUID->"c85cf354-5931-4bec-8e52-\ 1719 | c74598438e0e"], 1720 | 1721 | Cell[TextData[{ 1722 | "Let ", 1723 | StyleBox["Mathematica", 1724 | FontSlant->"Italic"], 1725 | " automatically pick a layout." 1726 | }], "Text", 1727 | CellChangeTimes->{{3.36051123278595*^9, 3.36051129045675*^9}, { 1728 | 3.392744016470289*^9, 3.392744016877804*^9}, {3.39274406347952*^9, 1729 | 3.3927440908962317`*^9}, {3.396136925665863*^9, 3.396136940821527*^9}, 1730 | 3.3961405777045727`*^9},ExpressionUUID->"5724fd29-9a7a-4f2e-8267-\ 1731 | 5970b7c549d9"], 1732 | 1733 | Cell[BoxData[ 1734 | RowBox[{"GraphPlot", "[", "network", "]"}]], "Input", 1735 | CellChangeTimes->{{3.36051127187267*^9, 3.36051130249795*^9}, { 1736 | 3.36051136930371*^9, 3.36051138044128*^9}, {3.36051241838748*^9, 1737 | 3.36051242883335*^9}, {3.373735025252874*^9, 3.3737350366178827`*^9}, { 1738 | 3.373735548992836*^9, 3.373735592030375*^9}, {3.392744006061533*^9, 1739 | 3.392744014199319*^9}, 3.395830598574294*^9, {3.396099566991637*^9, 1740 | 3.396099567614917*^9}, {3.396140211388867*^9, 3.396140212164154*^9}, 1741 | 3.396140577704924*^9},ExpressionUUID->"70a6d227-7a34-4d5f-a9b7-\ 1742 | 1d1c478555dc"], 1743 | 1744 | Cell["Or choose your own layout", "Text", 1745 | CellChangeTimes->{{3.39274409505231*^9, 3.392744098672556*^9}, 1746 | 3.396140577715411*^9},ExpressionUUID->"f3dff587-dc41-4533-a19d-\ 1747 | a7d47dc3fbb6"], 1748 | 1749 | Cell[BoxData[ 1750 | RowBox[{"GraphPlot", "[", 1751 | RowBox[{"network", ",", 1752 | RowBox[{"Method", "\[Rule]", " ", "\"\\""}]}], 1753 | "]"}]], "Input", 1754 | CellChangeTimes->{{3.373735599959284*^9, 3.3737356080030947`*^9}, { 1755 | 3.396099571992097*^9, 3.396099572645857*^9}, {3.39614021832726*^9, 1756 | 3.39614021901005*^9}, 1757 | 3.396140577715699*^9},ExpressionUUID->"cdca1da3-f606-4baf-962d-\ 1758 | a542a406bb61"] 1759 | }, Open ]] 1760 | }, Open ]], 1761 | 1762 | Cell[CellGroupData[{ 1763 | 1764 | Cell["Sparse matrix representation of NetLogo graphs", "Subsubsection", 1765 | CellDingbat->"\[FilledSmallCircle]", 1766 | CellChangeTimes->{{3.39613933202522*^9, 1767 | 3.3961393828286543`*^9}},ExpressionUUID->"47737341-5b69-4dd2-b137-\ 1768 | 2cb4ea3bcb12"], 1769 | 1770 | Cell[BoxData[ 1771 | RowBox[{ 1772 | RowBox[{"Needs", "[", "\"\\"", "]"}], ";"}]], "Input", 1773 | CellChangeTimes->{{3.396139228745968*^9, 3.396139247164282*^9}, { 1774 | 3.3961402952584763`*^9, 1775 | 3.396140310080078*^9}},ExpressionUUID->"84714ff9-fc8c-4fd7-b036-\ 1776 | 4aa71758673c"], 1777 | 1778 | Cell[TextData[{ 1779 | "Rule-based network specifications, like the ones returned by ", 1780 | StyleBox["NLGetGraph[]", 1781 | FontFamily->"Courier", 1782 | FontWeight->"Bold"], 1783 | " can easily be converted into sparse matrices" 1784 | }], "Text", 1785 | CellChangeTimes->{{3.396139251533133*^9, 3.396139265816544*^9}, { 1786 | 3.396139491186124*^9, 3.396139503056478*^9}, {3.3961403481537247`*^9, 1787 | 3.396140390561335*^9}, 1788 | 3.396227688308981*^9},ExpressionUUID->"b841eb59-8950-4d1e-92d9-\ 1789 | 1ad7424fa51e"], 1790 | 1791 | Cell[BoxData[ 1792 | RowBox[{"netMatrix", "=", 1793 | RowBox[{"AdjacencyMatrix", "[", "network", "]"}]}]], "Input", 1794 | CellChangeTimes->{{3.396139271560814*^9, 3.3961392735471687`*^9}, { 1795 | 3.396140317849527*^9, 1796 | 3.396140321280302*^9}},ExpressionUUID->"d7e1f223-d19f-4817-861b-\ 1797 | 85988ebf1e1e"], 1798 | 1799 | Cell["Plot the adjacency matrix", "Text", 1800 | CellChangeTimes->{{3.3961392808426123`*^9, 1801 | 3.396139285273981*^9}},ExpressionUUID->"d5759e8f-41f0-4747-b44e-\ 1802 | 6233451e45eb"], 1803 | 1804 | Cell[BoxData[ 1805 | RowBox[{"MatrixPlot", "[", "netMatrix", "]"}]], "Input", 1806 | CellChangeTimes->{{3.396137182142939*^9, 3.39613718485977*^9}, { 1807 | 3.396140327555563*^9, 1808 | 3.396140328992268*^9}},ExpressionUUID->"83b8979f-7cf5-471c-bd62-\ 1809 | 109ccd749c3f"] 1810 | }, Open ]], 1811 | 1812 | Cell[CellGroupData[{ 1813 | 1814 | Cell["Comparing binning methods to find power laws in networks", \ 1815 | "Subsubsection", 1816 | CellDingbat->"\[FilledSmallCircle]", 1817 | CellChangeTimes->{{3.396140397473156*^9, 1818 | 3.396140424586383*^9}},ExpressionUUID->"866d1527-3032-4d42-919a-\ 1819 | 7fdf4863aaf2"], 1820 | 1821 | Cell[TextData[{ 1822 | StyleBox["Mathematica", 1823 | FontSlant->"Italic"], 1824 | " can operate on sparse matrices to find power laws in networks and other \ 1825 | related phenomena" 1826 | }], "Text", 1827 | CellChangeTimes->{{3.3961404878095512`*^9, 3.396140524260408*^9}, 1828 | 3.396227689756404*^9},ExpressionUUID->"0c73e8c8-8814-4d62-b2e6-\ 1829 | 2766eb77f305"], 1830 | 1831 | Cell[BoxData[{ 1832 | RowBox[{ 1833 | RowBox[{"linearBinPlot", "=", 1834 | RowBox[{"ListLogLogPlot", "[", 1835 | RowBox[{ 1836 | RowBox[{"BinCounts", "[", 1837 | RowBox[{"Total", "/@", "netMatrix"}], "]"}], ",", 1838 | RowBox[{"PlotStyle", "\[Rule]", " ", 1839 | RowBox[{"PointSize", "[", "0.019", "]"}]}], ",", 1840 | RowBox[{ 1841 | "PlotLabel", "\[Rule]", " ", 1842 | "\"\\""}]}], "]"}]}], 1843 | ";"}], "\[IndentingNewLine]", 1844 | RowBox[{ 1845 | RowBox[{"bins", "=", 1846 | RowBox[{"Table", "[", 1847 | RowBox[{ 1848 | SuperscriptBox["2", "i"], ",", 1849 | RowBox[{"{", 1850 | RowBox[{"i", ",", "8"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", 1851 | RowBox[{ 1852 | RowBox[{ 1853 | RowBox[{"expBinPlot", "=", 1854 | RowBox[{"ListLogLogPlot", "[", 1855 | RowBox[{ 1856 | RowBox[{"Transpose", "[", 1857 | RowBox[{"{", 1858 | RowBox[{"bins", ",", 1859 | RowBox[{"PadRight", "[", 1860 | RowBox[{ 1861 | RowBox[{"BinCounts", "[", 1862 | RowBox[{ 1863 | RowBox[{"Total", "/@", "netMatrix"}], ",", 1864 | RowBox[{"{", "bins", "}"}]}], "]"}], ",", "8"}], "]"}]}], "}"}], 1865 | "]"}], ",", 1866 | RowBox[{"PlotStyle", "\[Rule]", " ", 1867 | RowBox[{"PointSize", "[", "0.019", "]"}]}], ",", 1868 | RowBox[{ 1869 | "PlotLabel", "\[Rule]", " ", 1870 | "\"\\""}]}], "]"}]}], 1871 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1872 | RowBox[{"GraphicsRow", "[", 1873 | RowBox[{ 1874 | RowBox[{"{", 1875 | RowBox[{"linearBinPlot", ",", "expBinPlot"}], "}"}], ",", 1876 | RowBox[{"ImageSize", "\[Rule]", " ", "600"}]}], "]"}]}], "Input", 1877 | CellChangeTimes->{{3.3961374150934772`*^9, 3.396137428364057*^9}, { 1878 | 3.396138097434504*^9, 3.396138119530472*^9}, {3.396138982621381*^9, 1879 | 3.396139038608863*^9}, {3.396140427741434*^9, 3.396140466953677*^9}, 1880 | 3.396227193973851*^9, {3.396760228126617*^9, 3.396760228393236*^9}, { 1881 | 3.396761275762184*^9, 1882 | 3.3967612941656322`*^9}},ExpressionUUID->"2230a629-c0d5-4d98-b9f6-\ 1883 | 1aeb2beffb8a"] 1884 | }, Open ]] 1885 | }, Open ]], 1886 | 1887 | Cell[CellGroupData[{ 1888 | 1889 | Cell["Advanced Features: Headless Mode", "Section", 1890 | CellChangeTimes->{{3.395787919563747*^9, 3.395787923230283*^9}, { 1891 | 3.396114839426405*^9, 1892 | 3.3961148456052513`*^9}},ExpressionUUID->"734a7ea7-ee13-42d7-900c-\ 1893 | ca02f781d58d"], 1894 | 1895 | Cell[TextData[{ 1896 | StyleBox["To begin in headless mode, use option", 1897 | FontSize->13], 1898 | " ", 1899 | StyleBox["Headless\[VeryThinSpace]\[Rule]\[ThinSpace]True", 1900 | FontFamily->"Courier", 1901 | FontWeight->"Bold"] 1902 | }], "Text", 1903 | CellChangeTimes->{ 1904 | 3.379252057619041*^9, {3.3967604904157267`*^9, 1905 | 3.3967605121257477`*^9}},ExpressionUUID->"d0264a63-591a-4977-b7de-\ 1906 | 34838718baa3"], 1907 | 1908 | Cell[BoxData[ 1909 | RowBox[{"NLStart", "[", 1910 | RowBox[{"$NLHome", ",", 1911 | RowBox[{"Headless", "\[Rule]", " ", "True"}]}], "]"}]], "Input", 1912 | CellChangeTimes->{{3.3792676276472588`*^9, 3.379267631148417*^9}, 1913 | 3.392740806213889*^9, 1914 | 3.392740843276425*^9},ExpressionUUID->"eed21470-df0c-4286-ab5b-\ 1915 | 127ac3fa200d"], 1916 | 1917 | Cell["\<\ 1918 | This mode is preferable for situations in which you do not need to interact \ 1919 | directly with the NetLogo graphical interface.\ 1920 | \>", "Text", 1921 | CellChangeTimes->{{3.396108264193264*^9, 1922 | 3.396108293998686*^9}},ExpressionUUID->"0de28f81-a67e-4407-b97c-\ 1923 | 39f8b5278c11"] 1924 | }, Open ]], 1925 | 1926 | Cell[CellGroupData[{ 1927 | 1928 | Cell["Troubleshooting", "Section", 1929 | CellChangeTimes->{{3.704208502039298*^9, 3.7042085298648977`*^9}}, 1930 | CellTags-> 1931 | "troubleshooting",ExpressionUUID->"9c48f645-15c5-4c6b-a9ce-2a47845b66a7"], 1932 | 1933 | Cell[TextData[{ 1934 | "Sometimes, things go wrong with Mathematica Link. Not to fear, we have some \ 1935 | helpful tools to assist in debugging. If you\[CloseCurlyQuote]re having \ 1936 | problems and you\[CloseCurlyQuote]ve never used Mathematica Link before, see ", 1937 | ButtonBox["general troubleshooting", 1938 | BaseStyle->"Hyperlink", 1939 | ButtonData->"general-troubleshooting"], 1940 | ". If you have used Mathematica Link before, see ", 1941 | ButtonBox["clearing cached versions", 1942 | BaseStyle->"Hyperlink", 1943 | ButtonData->"clearing-cached-versions"], 1944 | " first, then ", 1945 | ButtonBox["general troubleshooting", 1946 | BaseStyle->"Hyperlink", 1947 | ButtonData->"general-troubleshooting"], 1948 | " if that doesn\[CloseCurlyQuote]t resolve your problems." 1949 | }], "Text", 1950 | CellChangeTimes->{{3.704208536044156*^9, 3.704208748393077*^9}, { 1951 | 3.704208906549464*^9, 3.7042089357466516`*^9}, {3.7042091062505703`*^9, 1952 | 3.7042092411054573`*^9}, {3.70420928183891*^9, 3.704209282483639*^9}, { 1953 | 3.7042104589702*^9, 1954 | 3.704210512922271*^9}},ExpressionUUID->"509d989c-b2f2-468a-b8a6-\ 1955 | 446822e08c35"], 1956 | 1957 | Cell[CellGroupData[{ 1958 | 1959 | Cell["General Troubleshooting", "Subsubsection", 1960 | CellChangeTimes->{{3.704209252923634*^9, 3.704209257347364*^9}, { 1961 | 3.704209369181203*^9, 3.704209374107252*^9}}, 1962 | CellTags-> 1963 | "general-troubleshooting",ExpressionUUID->"2ac466da-46a8-4011-a547-\ 1964 | e0f8d9a2c50e"], 1965 | 1966 | Cell["\<\ 1967 | The most common error when starting Mathematica Link is being unable to find \ 1968 | the appropriate NetLogo jars. You can check the locations that NetLogo is \ 1969 | looking for jars by using NLDiagnostics. The path to NetLogo 6.2.0 on a Mac \ 1970 | is used below, Windows users will want to adapt this example for their \ 1971 | NetLogo installation:\ 1972 | \>", "Text", 1973 | CellChangeTimes->{{3.704209378263135*^9, 3.704209496567993*^9}, { 1974 | 3.704210302437591*^9, 3.704210319763315*^9}, {3.704210380937344*^9, 1975 | 3.704210421843747*^9}, {3.7111026036231213`*^9, 3.711102603733569*^9}, 1976 | 3.828700133926713*^9},ExpressionUUID->"f0b1de6f-dce0-4060-acad-\ 1977 | 0f778bc02da2"], 1978 | 1979 | Cell[CellGroupData[{ 1980 | 1981 | Cell[BoxData[ 1982 | RowBox[{"NLDiagnostics", "[", "\"\\"", 1983 | "]"}]], "Input", 1984 | CellChangeTimes->{{3.704209501092416*^9, 3.7042095585660543`*^9}, { 1985 | 3.70421033406502*^9, 3.7042103386310663`*^9}, 3.711102610273225*^9, 1986 | 3.828700137485118*^9},ExpressionUUID->"2ea3876a-b56f-4671-ac88-\ 1987 | d4c6aa672bb5"], 1988 | 1989 | Cell[BoxData[ 1990 | RowBox[{"\[LeftAssociation]", 1991 | RowBox[{ 1992 | RowBox[{ 1993 | "\"\\"", "\[Rule]", "\"\\""}], 1994 | ",", 1995 | RowBox[{"\"\\"", "\[Rule]", 1996 | RowBox[{"{", 1997 | RowBox[{ 1998 | "\"\\"", ",", 1999 | "\"\\""}], "}"}]}], ",", 2001 | RowBox[{"\"\\"", "\[Rule]", 2002 | RowBox[{"{", 2003 | RowBox[{ 2004 | "\"\\"", ",", 2005 | "\"\\""}], "}"}]}], ",", 2007 | RowBox[{"\"\\"", "\[Rule]", 2008 | RowBox[{"{", "}"}]}]}], "\[RightAssociation]"}]], "Input", 2009 | CellChangeTimes->{{3.7111026116542253`*^9, 3.711102615301227*^9}, { 2010 | 3.828700138614234*^9, 2011 | 3.8287001476567373`*^9}},ExpressionUUID->"d13415f1-367e-4205-ab12-\ 2012 | 9871bc9f4c5d"] 2013 | }, Open ]], 2014 | 2015 | Cell[TextData[{ 2016 | "This will return a key-value associative array listing several items values \ 2017 | which can help diagnose a problem. If the value at the key \ 2018 | \[OpenCurlyDoubleQuote]missingJars\[CloseCurlyDoubleQuote] is empty, \ 2019 | Mathematica Link has found the necessary jars. If it ", 2020 | StyleBox["isn\[CloseCurlyQuote]t", 2021 | FontSlant->"Italic"], 2022 | " empty, check that the path at provided is correct and that no files have \ 2023 | accidentally been removed from your NetLogo installation." 2024 | }], "Text", 2025 | CellChangeTimes->{{3.704209575234748*^9, 3.7042095848087606`*^9}, { 2026 | 3.704209639440988*^9, 3.704209718740284*^9}, {3.7042103576195927`*^9, 2027 | 3.7042103700456257`*^9}},ExpressionUUID->"2a7db7a8-5d75-4b0d-b53e-\ 2028 | f03b03423745"], 2029 | 2030 | Cell["\<\ 2031 | Assuming everything looks good with NLDiagnostics and you are still having \ 2032 | problems opening Mathematica Link, you can check \ 2033 | Mathematica\[CloseCurlyQuote]s Java configuration with:\ 2034 | \>", "Text", 2035 | CellChangeTimes->{{3.704209828304311*^9, 2036 | 3.704209867858671*^9}},ExpressionUUID->"4c79f617-5b03-4d3c-9f12-\ 2037 | f4483843b274"], 2038 | 2039 | Cell[CellGroupData[{ 2040 | 2041 | Cell[BoxData[ 2042 | RowBox[{"NLJavaDiagnostics", "[", "]"}]], "Input", 2043 | CellChangeTimes->{{3.7042098740951147`*^9, 2044 | 3.704209877795979*^9}},ExpressionUUID->"fb419de2-b875-4798-8a76-\ 2045 | b4509155b9ad"], 2046 | 2047 | Cell[BoxData[ 2048 | RowBox[{"\[LeftAssociation]", 2049 | RowBox[{ 2050 | RowBox[{"\<\"javaVersion\"\>", "\[Rule]", "\<\"1.8.0_92\"\>"}], ",", 2051 | RowBox[{"\<\"javaArchitecture\"\>", "\[Rule]", "\<\"64\"\>"}]}], 2052 | "\[RightAssociation]"}]], "Output", 2053 | CellChangeTimes->{ 2054 | 3.704209883637909*^9},ExpressionUUID->"4b9e374a-8d70-456c-84a1-\ 2055 | 411874a67576"] 2056 | }, Open ]], 2057 | 2058 | Cell[TextData[{ 2059 | "The precise \[OpenCurlyDoubleQuote]javaVersion\[CloseCurlyDoubleQuote] \ 2060 | doesn\[CloseCurlyQuote]t need to be identical, but should start with \ 2061 | \[OpenCurlyDoubleQuote]1.8.0\[CloseCurlyDoubleQuote]. If it doesn\ 2062 | \[CloseCurlyQuote]t, you may need to install java 8 or adjust your Java \ 2063 | configuration (the ", 2064 | ButtonBox["options available for InstallJava", 2065 | BaseStyle->"Hyperlink", 2066 | ButtonData->{ 2067 | URL["https://reference.wolfram.com/language/JLink/ref/InstallJava.html"], 2068 | None}, 2069 | ButtonNote-> 2070 | "https://reference.wolfram.com/language/JLink/ref/InstallJava.html"], 2071 | " can be passed to NLStart)." 2072 | }], "Text", 2073 | CellChangeTimes->{{3.7042098958516407`*^9, 3.704209999842455*^9}, { 2074 | 3.7042101495188217`*^9, 2075 | 3.7042101776827707`*^9}},ExpressionUUID->"2b7da929-9463-4ce4-a432-\ 2076 | cfa3f0548052"], 2077 | 2078 | Cell[TextData[{ 2079 | "If you continue to have problems, please contact ", 2080 | ButtonBox["bugs@ccl.northwestern.edu", 2081 | BaseStyle->"Hyperlink", 2082 | ButtonData->{ 2083 | URL["mailto:bugs@ccl.northwestern.edu"], None}, 2084 | ButtonNote->"mailto:bugs@ccl.northwestern.edu"], 2085 | " for further assistance. If you contact us, please include information on \ 2086 | your operating system, Mathematica Version, NetLogo Version, and the output \ 2087 | of the NLDiagnostics and NLJavaDiagnostics commands." 2088 | }], "Text", 2089 | CellChangeTimes->{{3.704209979847088*^9, 3.7042099871508512`*^9}, { 2090 | 3.704210182765356*^9, 2091 | 3.704210254291533*^9}},ExpressionUUID->"55b9195a-dfa0-4916-a49f-\ 2092 | ace60e1971b4"] 2093 | }, Open ]], 2094 | 2095 | Cell[CellGroupData[{ 2096 | 2097 | Cell["Clearing Cached Versions", "Subsubsection", 2098 | CellChangeTimes->{{3.7042092716949997`*^9, 3.70420927957448*^9}}, 2099 | CellTags-> 2100 | "clearing-cached-versions",ExpressionUUID->"7268c46e-3649-43d2-8738-\ 2101 | 31d1bea8d06b"], 2102 | 2103 | Cell["\<\ 2104 | If you've worked with Mathematica link in an old version of NetLogo, you may \ 2105 | have an old \"NetLogo.m\" package cached in your system which will prevent \ 2106 | loading of the most recent Mathematica Link package. Mathematica stores these \ 2107 | files in one or both of the following locations:\ 2108 | \>", "Text", 2109 | CellChangeTimes->{{3.704208536044156*^9, 3.704208748393077*^9}, { 2110 | 3.704208906549464*^9, 3.7042089357466516`*^9}, {3.7042091062505703`*^9, 2111 | 3.7042091204438972`*^9}},ExpressionUUID->"61b318dd-da19-4150-a2bf-\ 2112 | 592368fa43df"], 2113 | 2114 | Cell[BoxData[{ 2115 | RowBox[{"FileNameJoin", "[", 2116 | RowBox[{"{", 2117 | RowBox[{ 2118 | "$BaseDirectory", ",", " ", "\"\\"", ",", " ", 2119 | "\"\\""}], "}"}], "]"}], "\n", 2120 | RowBox[{"FileNameJoin", "[", 2121 | RowBox[{"{", 2122 | RowBox[{ 2123 | "$UserBaseDirectory", ",", " ", "\"\\"", ",", " ", 2124 | "\"\\""}], "}"}], "]"}]}], "Input", 2125 | CellChangeTimes->{{3.704208795001275*^9, 3.704208846533988*^9}, 2126 | 3.704208876559905*^9},ExpressionUUID->"376b7dd9-aca1-4276-b0be-\ 2127 | 14798196b960"], 2128 | 2129 | Cell[TextData[{ 2130 | "Check both locations. If you find a file in either, delete it and reinstall \ 2131 | the NetLogo packages (per directions in ", 2132 | ButtonBox["installing", 2133 | BaseStyle->"Hyperlink", 2134 | ButtonData->"installing"], 2135 | ")." 2136 | }], "Text", 2137 | CellChangeTimes->{{3.704208948687892*^9, 3.70420897613317*^9}, { 2138 | 3.7042090200576687`*^9, 3.704209020060487*^9}, {3.704209061466508*^9, 2139 | 3.7042090955435038`*^9}},ExpressionUUID->"c8937c23-4195-42c1-a3f3-\ 2140 | c1a111bf39dc"] 2141 | }, Open ]] 2142 | }, Open ]] 2143 | }, 2144 | AutoGeneratedPackage->None, 2145 | WindowToolbars->"EditBar", 2146 | CellGrouping->Manual, 2147 | WindowSize->{1440., 872.25}, 2148 | WindowMargins->{{-1440, Automatic}, {Automatic, 27.75}}, 2149 | PrintingCopies->1, 2150 | PrintingPageRange->{1, Automatic}, 2151 | PageHeaders->{{ 2152 | Cell[ 2153 | TextData[{ 2154 | Cell[ 2155 | TextData[{ 2156 | CounterBox["Page"]}], "PageNumber"], " ", 2157 | Cell[ 2158 | " ", "Header", CellFrame -> {{0.5, 0}, {0, 0}}, CellFrameMargins -> 4], 2159 | 2160 | Cell[ 2161 | TextData[{ 2162 | ValueBox["FileName"]}], "Header"]}], 2163 | CellMargins -> {{0, Inherited}, {Inherited, Inherited}}], None, None}, { 2164 | None, None, None}}, 2165 | PrintingOptions->{"FacingPages"->False, 2166 | "FirstPageHeader"->True, 2167 | "PaperOrientation"->"Portrait", 2168 | "PrintCellBrackets"->False, 2169 | "PrintMultipleHorizontalPages"->False, 2170 | "PrintRegistrationMarks"->False, 2171 | "PrintingMargins"->36}, 2172 | ShowSelection->True, 2173 | CellLabelAutoDelete->True, 2174 | ShowCellTags->True, 2175 | FrontEndVersion->"12.2 for Linux x86 (64-bit) (December 12, 2020)", 2176 | StyleDefinitions->Notebook[{ 2177 | Cell[ 2178 | StyleData[StyleDefinitions -> "Default.nb"]], 2179 | Cell[ 2180 | StyleData["Section"], FontSize -> 22, FontWeight -> Bold, FontColor -> 2181 | RGBColor[0.712923, 0.178409, 0.0498421]], 2182 | Cell[ 2183 | StyleData["Subsection"], FontSize -> 18, FontWeight -> Bold, FontColor -> 2184 | RGBColor[0.641154, 0.223011, 0.0623026]], 2185 | Cell[ 2186 | StyleData["Subsubsection"], FontSize -> 14, FontWeight -> Bold, FontColor -> 2187 | RGBColor[0.641154, 0.223011, 0.0623026]], 2188 | Cell[ 2189 | StyleData["Title"], FontSize -> 36, FontWeight -> Bold, FontColor -> 2190 | RGBColor[0.712923, 0.178409, 0.0498421]], 2191 | Cell[ 2192 | StyleData[All]], 2193 | Cell[ 2194 | StyleData["Input"]], 2195 | Cell[ 2196 | StyleData["Output"]]}, Visible -> False, FrontEndVersion -> 2197 | "12.2 for Linux x86 (64-bit) (December 12, 2020)", StyleDefinitions -> 2198 | "PrivateStylesheetFormatting.nb"], 2199 | ExpressionUUID->"0fb6a7a0-a50a-4c53-8781-28699c268815" 2200 | ] 2201 | (* End of Notebook Content *) 2202 | 2203 | (* Internal cache information *) 2204 | (*CellTagsOutline 2205 | CellTagsIndex->{ 2206 | "installing"->{ 2207 | Cell[3304, 96, 359, 10, 72, "Section",ExpressionUUID->"cf89693c-1762-4b2b-aaaa-80eea3b3423e", 2208 | CellTags->"installing"]}, 2209 | "troubleshooting"->{ 2210 | Cell[67752, 1927, 190, 3, 72, "Section",ExpressionUUID->"9c48f645-15c5-4c6b-a9ce-2a47845b66a7", 2211 | CellTags->"troubleshooting"]}, 2212 | "general-troubleshooting"->{ 2213 | Cell[69004, 1958, 261, 5, 52, "Subsubsection",ExpressionUUID->"2ac466da-46a8-4011-a547-e0f8d9a2c50e", 2214 | CellTags->"general-troubleshooting"]}, 2215 | "clearing-cached-versions"->{ 2216 | Cell[74376, 2096, 215, 4, 52, "Subsubsection",ExpressionUUID->"7268c46e-3649-43d2-8738-31d1bea8d06b", 2217 | CellTags->"clearing-cached-versions"]} 2218 | } 2219 | *) 2220 | (*CellTagsIndex 2221 | CellTagsIndex->{ 2222 | {"installing", 78156, 2205}, 2223 | {"troubleshooting", 78303, 2208}, 2224 | {"general-troubleshooting", 78465, 2211}, 2225 | {"clearing-cached-versions", 78642, 2214} 2226 | } 2227 | *) 2228 | (*NotebookFileOutline 2229 | Notebook[{ 2230 | Cell[558, 20, 620, 17, 128, "Title",ExpressionUUID->"eacb4ec8-43f4-403b-825b-c3d2a3df1381"], 2231 | Cell[1181, 39, 688, 13, 58, "Text",ExpressionUUID->"698b9b16-b219-4d10-b3b0-d652402cdbef"], 2232 | Cell[1872, 54, 1407, 38, 79, "Text",ExpressionUUID->"63d9cc59-cef9-4904-a0f1-2665dfda7175"], 2233 | Cell[CellGroupData[{ 2234 | Cell[3304, 96, 359, 10, 72, "Section",ExpressionUUID->"cf89693c-1762-4b2b-aaaa-80eea3b3423e", 2235 | CellTags->"installing"], 2236 | Cell[3666, 108, 2049, 55, 127, "Text",ExpressionUUID->"b113e1ef-5b9e-4cd1-9902-8d76280961d5"] 2237 | }, Open ]], 2238 | Cell[CellGroupData[{ 2239 | Cell[5752, 168, 209, 4, 59, "Section",ExpressionUUID->"53b6a1ea-2960-44c3-82b2-48fb85ba5fea"], 2240 | Cell[CellGroupData[{ 2241 | Cell[5986, 176, 312, 7, 35, "Text",ExpressionUUID->"fd224ba7-f6fb-4147-9839-c4ad8bce8d51"], 2242 | Cell[6301, 185, 229, 5, 29, "Input",ExpressionUUID->"76201619-afc4-4fb2-8865-dc60b2271a79"] 2243 | }, Open ]], 2244 | Cell[CellGroupData[{ 2245 | Cell[6567, 195, 842, 14, 58, "Text",ExpressionUUID->"c704b4f5-b7f9-4a52-bd4a-36c5bf976564"], 2246 | Cell[7412, 211, 183, 4, 29, "Input",ExpressionUUID->"11a31024-496b-4843-b3ed-651f017d982f"] 2247 | }, Open ]], 2248 | Cell[CellGroupData[{ 2249 | Cell[7632, 220, 535, 16, 35, "Text",ExpressionUUID->"75280f20-54bd-427a-8b03-8af7c712c674"], 2250 | Cell[8170, 238, 394, 9, 51, "Input",ExpressionUUID->"6c233054-858e-401b-a820-3f979dca5b94"] 2251 | }, Open ]] 2252 | }, Open ]], 2253 | Cell[8591, 251, 577, 14, 35, "Text",ExpressionUUID->"9d48a520-cae3-4303-8742-21e81e18d876"], 2254 | Cell[9171, 267, 729, 16, 55, "Code",ExpressionUUID->"e64b844f-c2aa-4f99-ab93-b46177895c5b", 2255 | Evaluatable->False], 2256 | Cell[CellGroupData[{ 2257 | Cell[9925, 287, 238, 6, 35, "Text",ExpressionUUID->"8af1c074-959e-4eeb-a3ec-a78c455044ed"], 2258 | Cell[10166, 295, 203, 4, 29, "Input",ExpressionUUID->"224035f1-822a-4640-966a-537c944e9f28"] 2259 | }, Open ]], 2260 | Cell[10384, 302, 298, 8, 35, "Text",ExpressionUUID->"c6eed7d8-941f-4a33-bf34-99f6b55724d7"], 2261 | Cell[10685, 312, 381, 9, 29, "Input",ExpressionUUID->"fda5a45b-ed88-40d5-9fcb-26c5b13bdb56"], 2262 | Cell[CellGroupData[{ 2263 | Cell[11091, 325, 351, 9, 59, "Section",ExpressionUUID->"9a73e35f-249d-4bc2-8855-7abf4eb6e09d"], 2264 | Cell[CellGroupData[{ 2265 | Cell[11467, 338, 227, 4, 39, "Subsubsection",ExpressionUUID->"43fb015c-52dc-43fc-a389-ac3bb522ed50"], 2266 | Cell[CellGroupData[{ 2267 | Cell[11719, 346, 505, 14, 32, "Text",ExpressionUUID->"1e14ac98-5fab-41c7-9606-52514fd4c89d"], 2268 | Cell[12227, 362, 644, 15, 29, "Input",ExpressionUUID->"80be373e-3c43-47bf-a89c-77e80d53f78e"] 2269 | }, Open ]] 2270 | }, Open ]], 2271 | Cell[CellGroupData[{ 2272 | Cell[12920, 383, 269, 3, 39, "Subsubsection",ExpressionUUID->"138b77c8-5106-485b-95f2-444a31404f4b"], 2273 | Cell[13192, 388, 427, 13, 32, "Text",ExpressionUUID->"d7bd9853-cd14-4189-877e-c5a79b86e890"], 2274 | Cell[13622, 403, 441, 8, 29, "Input",ExpressionUUID->"b2fcedb9-26ac-4f92-aae4-2b92a9601051"], 2275 | Cell[14066, 413, 229, 5, 29, "Input",ExpressionUUID->"6cf8111f-3bf4-4fec-b47e-12ea74e26d1b"], 2276 | Cell[14298, 420, 699, 14, 58, "Text",ExpressionUUID->"9abdfabc-9b4b-4b3a-8331-e58f17f9e14e"], 2277 | Cell[15000, 436, 450, 9, 29, "Input",ExpressionUUID->"567cfee1-3ce8-4429-a3a4-bbec2a5333ce"], 2278 | Cell[15453, 447, 283, 8, 35, "Text",ExpressionUUID->"f45caf3f-8872-4ac5-b4e5-d5f1a9ccaab4"], 2279 | Cell[15739, 457, 416, 9, 51, "Input",ExpressionUUID->"598ec602-e835-4696-954b-804acbb6d1b4"], 2280 | Cell[16158, 468, 306, 8, 35, "Text",ExpressionUUID->"78a490c3-a73a-4fa2-a293-268206d0b827"], 2281 | Cell[16467, 478, 330, 8, 29, "Input",ExpressionUUID->"a3ab709b-ac6c-43da-8d2a-9e3b5c457e75"] 2282 | }, Open ]], 2283 | Cell[CellGroupData[{ 2284 | Cell[16834, 491, 188, 3, 39, "Subsubsection",ExpressionUUID->"d1dcd5b3-d556-451e-a4a3-e39b7b29e377"], 2285 | Cell[CellGroupData[{ 2286 | Cell[17047, 498, 261, 9, 35, "Text",ExpressionUUID->"a5c7750a-df9a-4e76-bb53-9916082dbd81"], 2287 | Cell[17311, 509, 686, 13, 29, "Input",ExpressionUUID->"c59a3cb1-cafe-41b4-bd91-f0f68389dbb1"] 2288 | }, Open ]], 2289 | Cell[CellGroupData[{ 2290 | Cell[18034, 527, 603, 15, 32, "Text",ExpressionUUID->"b023b7c1-48e1-4c58-9dba-7a7e5bf1feba"], 2291 | Cell[18640, 544, 441, 9, 29, "Input",ExpressionUUID->"e87c5764-5dc4-4475-b3cb-e62a743529d0"] 2292 | }, Open ]] 2293 | }, Open ]], 2294 | Cell[CellGroupData[{ 2295 | Cell[19130, 559, 251, 4, 39, "Subsubsection",ExpressionUUID->"1350427b-a511-4228-bfd4-d8550479ff07"], 2296 | Cell[CellGroupData[{ 2297 | Cell[19406, 567, 312, 10, 32, "Text",ExpressionUUID->"0fbcafbb-f3d5-4286-bdaf-8a3a160b269c"], 2298 | Cell[19721, 579, 207, 4, 29, "Input",ExpressionUUID->"38c82fc7-b91a-4108-a5a2-b2bd3b12cf9b"] 2299 | }, Open ]] 2300 | }, Open ]], 2301 | Cell[CellGroupData[{ 2302 | Cell[19977, 589, 453, 11, 39, "Subsubsection",ExpressionUUID->"e08900b1-25d1-4862-9357-ba4b1af5240a"], 2303 | Cell[20433, 602, 574, 12, 35, "Text",ExpressionUUID->"d07221ef-ec46-4ec1-87f6-8268ae3d8b28"], 2304 | Cell[CellGroupData[{ 2305 | Cell[21032, 618, 738, 21, 35, "Text",ExpressionUUID->"3e0a865c-90de-4f41-ae6e-baa52bfa3887"], 2306 | Cell[21773, 641, 391, 11, 29, "Input",ExpressionUUID->"38326f94-a23b-4a88-8b21-1310b4b330a2"] 2307 | }, Open ]], 2308 | Cell[CellGroupData[{ 2309 | Cell[22201, 657, 603, 15, 35, "Text",ExpressionUUID->"b478cf38-7ff8-4923-9278-d3b1969734bd"], 2310 | Cell[22807, 674, 577, 11, 29, "Input",ExpressionUUID->"d6a49373-0b60-4a6e-8fc2-1d0a1141f511"] 2311 | }, Open ]] 2312 | }, Open ]], 2313 | Cell[CellGroupData[{ 2314 | Cell[23433, 691, 413, 6, 39, "Subsubsection",ExpressionUUID->"72a4b853-eb8c-4c4e-b674-e00f8b3d6c41"], 2315 | Cell[23849, 699, 823, 23, 33, "Text",ExpressionUUID->"d503067c-19da-4aac-8641-ca526e9e99df"] 2316 | }, Open ]], 2317 | Cell[CellGroupData[{ 2318 | Cell[24709, 727, 316, 9, 35, "Text",ExpressionUUID->"abfd5630-bf61-463f-9ab5-46559035d4c3"], 2319 | Cell[25028, 738, 701, 14, 51, "Input",ExpressionUUID->"015d9c7b-0a7b-417b-b87e-5d78d5e0481f"] 2320 | }, Open ]], 2321 | Cell[CellGroupData[{ 2322 | Cell[25766, 757, 369, 6, 39, "Subsubsection",ExpressionUUID->"ab1d2c02-6aed-46c4-8d4f-09561dfb23e3"], 2323 | Cell[CellGroupData[{ 2324 | Cell[26160, 767, 547, 11, 58, "Text",ExpressionUUID->"732a2bce-c6df-4809-a954-ac31d44aed20"], 2325 | Cell[26710, 780, 985, 22, 92, "Input",ExpressionUUID->"331e6a31-a129-48f3-8b88-1e8d4050b3ff"], 2326 | Cell[CellGroupData[{ 2327 | Cell[27720, 806, 271, 6, 35, "Text",ExpressionUUID->"ad6b6dc3-e79c-4706-bd4d-b927b2773aaa"], 2328 | Cell[27994, 814, 327, 9, 29, "Input",ExpressionUUID->"52846d03-8a35-4018-81c8-0612d5572ac8"] 2329 | }, Open ]], 2330 | Cell[CellGroupData[{ 2331 | Cell[28358, 828, 332, 10, 35, "Text",ExpressionUUID->"ae097fe7-cb7c-4b08-ae86-2981c2a6ba77"], 2332 | Cell[28693, 840, 625, 13, 51, "Input",ExpressionUUID->"8d09a2bb-289d-4c88-8c0a-2bec97fc182c"] 2333 | }, Open ]] 2334 | }, Open ]] 2335 | }, Open ]], 2336 | Cell[CellGroupData[{ 2337 | Cell[29379, 860, 242, 4, 39, "Subsubsection",ExpressionUUID->"9887d756-031c-48ca-8fba-a481b650bd17"], 2338 | Cell[CellGroupData[{ 2339 | Cell[29646, 868, 454, 8, 35, "Text",ExpressionUUID->"a4206fb5-32b9-461c-848f-88b6a5f89f92"], 2340 | Cell[30103, 878, 733, 16, 92, "Input",ExpressionUUID->"3af2c94f-a565-4d30-aa8a-2e4ad2877cc6"] 2341 | }, Open ]], 2342 | Cell[CellGroupData[{ 2343 | Cell[30873, 899, 233, 6, 35, "Text",ExpressionUUID->"66abf9a6-1026-4689-9221-24329bde8d35"], 2344 | Cell[31109, 907, 2494, 64, 216, "Input",ExpressionUUID->"2f1810af-b91a-4b9d-82be-2d1144068ab4"], 2345 | Cell[33606, 973, 596, 11, 58, "Text",ExpressionUUID->"0fa7b4ef-3622-4a92-81a8-36074dc1e17e"] 2346 | }, Open ]] 2347 | }, Open ]], 2348 | Cell[CellGroupData[{ 2349 | Cell[34251, 990, 334, 8, 39, "Subsubsection",ExpressionUUID->"4cd44617-d1d5-45f7-b826-742e9bfcf491"], 2350 | Cell[34588, 1000, 1625, 39, 113, "Input",ExpressionUUID->"03b0e4b7-5480-45ae-b07f-1c651cdb6e38"] 2351 | }, Open ]] 2352 | }, Open ]], 2353 | Cell[CellGroupData[{ 2354 | Cell[36262, 1045, 203, 3, 59, "Section",ExpressionUUID->"f0973b1c-15ee-4ccc-8e3d-dec893aac668"], 2355 | Cell[CellGroupData[{ 2356 | Cell[36490, 1052, 288, 7, 35, "Text",ExpressionUUID->"b6446a58-bfdc-4edd-8ffb-68cc099a5493"], 2357 | Cell[36781, 1061, 1084, 26, 133, "Input",ExpressionUUID->"e6035862-95af-4ecc-a8ac-cdc2ecfd7ea7"] 2358 | }, Open ]], 2359 | Cell[CellGroupData[{ 2360 | Cell[37902, 1092, 238, 4, 39, "Subsubsection",ExpressionUUID->"d491c790-821e-4703-ba51-fcff74ac96e9"], 2361 | Cell[38143, 1098, 566, 11, 55, "Text",ExpressionUUID->"e6ae631c-e5e3-4d71-b6b0-8062aaa48495"], 2362 | Cell[38712, 1111, 311, 5, 29, "Input",ExpressionUUID->"ee07bfca-6411-4a8e-9b74-27de32763ad9"] 2363 | }, Open ]], 2364 | Cell[CellGroupData[{ 2365 | Cell[39060, 1121, 372, 8, 39, "Subsubsection",ExpressionUUID->"bd55c7e6-ef31-4dac-bbdf-b183018c3255"], 2366 | Cell[CellGroupData[{ 2367 | Cell[39457, 1133, 254, 6, 35, "Text",ExpressionUUID->"93c7589f-2bd8-4360-848b-b0a662513bb0"], 2368 | Cell[39714, 1141, 757, 19, 71, "Input",ExpressionUUID->"cfc3e77b-38e9-4833-9850-902ac97df53e"] 2369 | }, Open ]], 2370 | Cell[CellGroupData[{ 2371 | Cell[40508, 1165, 659, 19, 43, "Text",ExpressionUUID->"e8293c0a-d59e-406d-ae1a-bd0491a946f1"], 2372 | Cell[CellGroupData[{ 2373 | Cell[41192, 1188, 880, 18, 29, "Input",ExpressionUUID->"8fdfb5db-ced0-426e-8e32-d22046952b0c"], 2374 | Cell[42075, 1208, 2199, 56, 179, "Input",ExpressionUUID->"e8495ab0-4b5a-49c5-9e13-a2ad141da18e"] 2375 | }, Open ]] 2376 | }, Open ]] 2377 | }, Open ]] 2378 | }, Open ]], 2379 | Cell[CellGroupData[{ 2380 | Cell[44347, 1272, 308, 5, 59, "Section",ExpressionUUID->"4c072799-96f1-4c2e-aed2-076730b8fd83"], 2381 | Cell[44658, 1279, 758, 19, 51, "Input",ExpressionUUID->"499094e7-5280-41c9-9df5-a9e270ae3d7f"], 2382 | Cell[CellGroupData[{ 2383 | Cell[45441, 1302, 183, 3, 39, "Subsubsection",ExpressionUUID->"75d88cec-141c-4622-9556-0f513ae071ec"], 2384 | Cell[45627, 1307, 653, 16, 55, "Text",ExpressionUUID->"79796eeb-1825-4c97-80e6-917220f4a0ab"], 2385 | Cell[46283, 1325, 449, 12, 29, "Input",ExpressionUUID->"3bbc9511-b764-4512-bcdc-b81fefa2c583"] 2386 | }, Open ]], 2387 | Cell[CellGroupData[{ 2388 | Cell[46769, 1342, 318, 5, 39, "Subsubsection",ExpressionUUID->"ce76dc78-d761-47b6-b064-6fb190ca5cae"], 2389 | Cell[CellGroupData[{ 2390 | Cell[47112, 1351, 730, 19, 35, "Text",ExpressionUUID->"0bd0b641-de60-4ea1-a2f2-7f5e9037713c"], 2391 | Cell[47845, 1372, 703, 17, 92, "Input",ExpressionUUID->"181b4a79-d081-4650-893f-481e0cb485e0"] 2392 | }, Open ]], 2393 | Cell[CellGroupData[{ 2394 | Cell[48585, 1394, 377, 10, 35, "Text",ExpressionUUID->"0829599b-a521-4746-b606-c21fec580558"], 2395 | Cell[48965, 1406, 1180, 28, 71, "Input",ExpressionUUID->"4654274e-5a25-4138-8d33-f33b63486191"] 2396 | }, Open ]], 2397 | Cell[CellGroupData[{ 2398 | Cell[50182, 1439, 326, 5, 39, "Subsubsection",ExpressionUUID->"0793d1c4-19f5-418f-84fc-726a10bf0987"], 2399 | Cell[50511, 1446, 204, 3, 35, "Text",ExpressionUUID->"be58639b-2f2f-4470-8270-be3d806da7e5"], 2400 | Cell[50718, 1451, 602, 12, 29, "Input",ExpressionUUID->"eb7f4ccf-d133-46a1-a53e-bf874d93694c"] 2401 | }, Open ]], 2402 | Cell[CellGroupData[{ 2403 | Cell[51357, 1468, 351, 6, 39, "Subsubsection",ExpressionUUID->"e287bf28-934d-4afb-bc2f-a52dc2d25dec"], 2404 | Cell[51711, 1476, 219, 5, 35, "Text",ExpressionUUID->"725b5b3f-d627-482b-a98c-d2418593fbbc"], 2405 | Cell[51933, 1483, 333, 6, 29, "Input",ExpressionUUID->"5c1e8396-7f97-4fd6-8954-b0828479bb19"] 2406 | }, Open ]] 2407 | }, Open ]] 2408 | }, Open ]], 2409 | Cell[CellGroupData[{ 2410 | Cell[52327, 1496, 169, 3, 59, "Section",ExpressionUUID->"ae3205ea-19de-400d-b2d9-8dba6fb685a3"], 2411 | Cell[52499, 1501, 205, 3, 35, "Text",ExpressionUUID->"047d2537-c4b4-43e1-94a0-4c97617cbf91"], 2412 | Cell[52707, 1506, 945, 21, 71, "Input",ExpressionUUID->"83101098-7ee6-4d9f-bd96-2d5fbf4a0bbe"], 2413 | Cell[53655, 1529, 97, 0, 35, "Text",ExpressionUUID->"e4da9e2b-b571-4ab4-b2c1-350eb3ec62c2"], 2414 | Cell[53755, 1531, 321, 5, 39, "Subsubsection",ExpressionUUID->"e82ce3c9-c202-43be-8856-b6d0471ec54d"], 2415 | Cell[54079, 1538, 418, 12, 31, "Text",ExpressionUUID->"4c91c17a-3240-45d0-9b2d-55e9eaee0f2d"], 2416 | Cell[54500, 1552, 877, 20, 71, "Input",ExpressionUUID->"ffb96276-1ec6-41a5-81c0-8133dfd07aa2"] 2417 | }, Open ]], 2418 | Cell[CellGroupData[{ 2419 | Cell[55414, 1577, 238, 4, 59, "Section",ExpressionUUID->"00b9613a-b38e-4f97-af5d-0b11cfc19de8"], 2420 | Cell[CellGroupData[{ 2421 | Cell[55677, 1585, 178, 3, 35, "Text",ExpressionUUID->"9ee58d67-f01d-4435-96ca-c85dfb8054fa"], 2422 | Cell[55858, 1590, 459, 12, 29, "Input",ExpressionUUID->"1aa8e85d-ac83-4dfd-931d-ea10d98cff49"], 2423 | Cell[56320, 1604, 238, 4, 35, "Text",ExpressionUUID->"13017292-2794-4885-bee2-ccf620b14ee7"], 2424 | Cell[56561, 1610, 778, 16, 51, "Input",ExpressionUUID->"6ef9de3f-bf0a-4290-93f9-cc39eda8b0f8"], 2425 | Cell[CellGroupData[{ 2426 | Cell[57364, 1630, 303, 5, 39, "Subsubsection",ExpressionUUID->"0b431835-28a7-4eac-84dc-365c1c2eaa50"], 2427 | Cell[57670, 1637, 452, 13, 35, "Text",ExpressionUUID->"2189bb3d-e5e4-492f-8530-62fa7b9bbfed"], 2428 | Cell[58125, 1652, 589, 11, 29, "Input",ExpressionUUID->"da03a136-b56c-48ff-9d09-898c8196f8bb"], 2429 | Cell[58717, 1665, 348, 11, 35, "Text",ExpressionUUID->"0ea81582-b302-44da-8645-fbad01766947"], 2430 | Cell[59068, 1678, 257, 6, 29, "Input",ExpressionUUID->"50396e56-a24b-4a6e-914d-025b7f6ef2d0"], 2431 | Cell[59328, 1686, 652, 16, 35, "Text",ExpressionUUID->"5532cd75-cd35-4c6d-aceb-f00f02c0c723"], 2432 | Cell[59983, 1704, 268, 5, 29, "Input",ExpressionUUID->"0459db0f-0b7f-4fed-9ff7-b8d194b60652"] 2433 | }, Open ]], 2434 | Cell[CellGroupData[{ 2435 | Cell[60288, 1714, 239, 4, 39, "Subsubsection",ExpressionUUID->"c85cf354-5931-4bec-8e52-c74598438e0e"], 2436 | Cell[60530, 1720, 414, 10, 35, "Text",ExpressionUUID->"5724fd29-9a7a-4f2e-8267-5970b7c549d9"], 2437 | Cell[60947, 1732, 577, 9, 29, "Input",ExpressionUUID->"70a6d227-7a34-4d5f-a9b7-1d1c478555dc"], 2438 | Cell[61527, 1743, 189, 3, 35, "Text",ExpressionUUID->"f3dff587-dc41-4533-a19d-a7d47dc3fbb6"], 2439 | Cell[61719, 1748, 415, 9, 29, "Input",ExpressionUUID->"cdca1da3-f606-4baf-962d-a542a406bb61"] 2440 | }, Open ]] 2441 | }, Open ]], 2442 | Cell[CellGroupData[{ 2443 | Cell[62183, 1763, 236, 4, 39, "Subsubsection",ExpressionUUID->"47737341-5b69-4dd2-b137-2cb4ea3bcb12"], 2444 | Cell[62422, 1769, 275, 6, 29, "Input",ExpressionUUID->"84714ff9-fc8c-4fd7-b036-4aa71758673c"], 2445 | Cell[62700, 1777, 467, 11, 35, "Text",ExpressionUUID->"b841eb59-8950-4d1e-92d9-1ad7424fa51e"], 2446 | Cell[63170, 1790, 282, 6, 29, "Input",ExpressionUUID->"d7e1f223-d19f-4817-861b-85988ebf1e1e"], 2447 | Cell[63455, 1798, 169, 3, 35, "Text",ExpressionUUID->"d5759e8f-41f0-4747-b44e-6233451e45eb"], 2448 | Cell[63627, 1803, 245, 5, 29, "Input",ExpressionUUID->"83b8979f-7cf5-471c-bd62-109ccd749c3f"] 2449 | }, Open ]], 2450 | Cell[CellGroupData[{ 2451 | Cell[63909, 1813, 247, 5, 39, "Subsubsection",ExpressionUUID->"866d1527-3032-4d42-919a-7fdf4863aaf2"], 2452 | Cell[64159, 1820, 323, 8, 35, "Text",ExpressionUUID->"0c73e8c8-8814-4d62-b2e6-2766eb77f305"], 2453 | Cell[64485, 1830, 1994, 52, 135, "Input",ExpressionUUID->"2230a629-c0d5-4d98-b9f6-1aeb2beffb8a"] 2454 | }, Open ]] 2455 | }, Open ]], 2456 | Cell[CellGroupData[{ 2457 | Cell[66528, 1888, 228, 4, 59, "Section",ExpressionUUID->"734a7ea7-ee13-42d7-900c-ca02f781d58d"], 2458 | Cell[66759, 1894, 365, 11, 35, "Text",ExpressionUUID->"d0264a63-591a-4977-b7de-34838718baa3"], 2459 | Cell[67127, 1907, 311, 7, 29, "Input",ExpressionUUID->"eed21470-df0c-4286-ab5b-127ac3fa200d"], 2460 | Cell[67441, 1916, 274, 6, 35, "Text",ExpressionUUID->"0de28f81-a67e-4407-b97c-39f8b5278c11"] 2461 | }, Open ]], 2462 | Cell[CellGroupData[{ 2463 | Cell[67752, 1927, 190, 3, 72, "Section",ExpressionUUID->"9c48f645-15c5-4c6b-a9ce-2a47845b66a7", 2464 | CellTags->"troubleshooting"], 2465 | Cell[67945, 1932, 1034, 22, 58, "Text",ExpressionUUID->"509d989c-b2f2-468a-b8a6-446822e08c35"], 2466 | Cell[CellGroupData[{ 2467 | Cell[69004, 1958, 261, 5, 52, "Subsubsection",ExpressionUUID->"2ac466da-46a8-4011-a547-e0f8d9a2c50e", 2468 | CellTags->"general-troubleshooting"], 2469 | Cell[69268, 1965, 648, 11, 58, "Text",ExpressionUUID->"f0b1de6f-dce0-4060-acad-0f778bc02da2"], 2470 | Cell[CellGroupData[{ 2471 | Cell[69941, 1980, 327, 6, 29, "Input",ExpressionUUID->"2ea3876a-b56f-4671-ac88-d4c6aa672bb5"], 2472 | Cell[70271, 1988, 952, 23, 94, "Input",ExpressionUUID->"d13415f1-367e-4205-ab12-9871bc9f4c5d"] 2473 | }, Open ]], 2474 | Cell[71238, 2014, 719, 13, 58, "Text",ExpressionUUID->"2a7db7a8-5d75-4b0d-b53e-f03b03423745"], 2475 | Cell[71960, 2029, 333, 7, 35, "Text",ExpressionUUID->"4c79f617-5b03-4d3c-9f12-f4483843b274"], 2476 | Cell[CellGroupData[{ 2477 | Cell[72318, 2040, 193, 4, 29, "Input",ExpressionUUID->"fb419de2-b875-4798-8a76-b4509155b9ad"], 2478 | Cell[72514, 2046, 338, 8, 33, "Output",ExpressionUUID->"4b9e374a-8d70-456c-84a1-411874a67576"] 2479 | }, Open ]], 2480 | Cell[72867, 2057, 816, 18, 58, "Text",ExpressionUUID->"2b7da929-9463-4ce4-a432-cfa3f0548052"], 2481 | Cell[73686, 2077, 653, 14, 58, "Text",ExpressionUUID->"55b9195a-dfa0-4916-a49f-ace60e1971b4"] 2482 | }, Open ]], 2483 | Cell[CellGroupData[{ 2484 | Cell[74376, 2096, 215, 4, 52, "Subsubsection",ExpressionUUID->"7268c46e-3649-43d2-8738-31d1bea8d06b", 2485 | CellTags->"clearing-cached-versions"], 2486 | Cell[74594, 2102, 535, 9, 58, "Text",ExpressionUUID->"61b318dd-da19-4150-a2bf-592368fa43df"], 2487 | Cell[75132, 2113, 517, 13, 51, "Input",ExpressionUUID->"376b7dd9-aca1-4276-b0be-14798196b960"], 2488 | Cell[75652, 2128, 460, 11, 35, "Text",ExpressionUUID->"c8937c23-4195-42c1-a3f3-c1a111bf39dc"] 2489 | }, Open ]] 2490 | }, Open ]] 2491 | } 2492 | ] 2493 | *) 2494 | 2495 | -------------------------------------------------------------------------------- /NetLogo-Mathematica Tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NetLogo/Mathematica-Link/ea1eca2b1e3ae01a9dd42bb206ec6bc048ed7c1d/NetLogo-Mathematica Tutorial.pdf -------------------------------------------------------------------------------- /NetLogo.m: -------------------------------------------------------------------------------- 1 | (* ::Package:: *) 2 | 3 | BeginPackage["NetLogo`",{"JLink`"}] 4 | 5 | SetAttributes[Headless, Protected]; 6 | 7 | $NLHome = ""; 8 | 9 | JLink`InstallJava`Private`$disablePrefs = False; 10 | 11 | Headless::usage := "Headless is an option for NLStart[] that specifies whether or not NetLogo should be run with a graphical interface. By default, Headless is False." 12 | 13 | NLStart::usage := "NLStart[NetLogoHome] starts the J/Link interface and launches the version of NetLogo (6.2 or later) installed in the directory NetLogoHome. By default, the NetLogo-Mathematica Link runs in GUI-mode. By specifying the option Headless->True, NetLogo may operate in headless mode. This is recommended for conducting large experiments"; 14 | 15 | NLQuit::usage := "NLQuit[] quits J/Link"; 16 | 17 | 18 | NLSequence::usage := \ 19 | "NLSequence[{\!\(\*SubscriptBox[ 20 | StyleBox[\"expr\",\nFontSlant->\"Italic\"], \"1\"]\), \!\(\*SubscriptBox[ 21 | StyleBox[\"expr\",\nFontSlant->\"Italic\"], \"2\"]\), ...}] splices a list of Mathematica expressions into a string readable by NetLogo. NetLogo-Mathematica Link functions, such as NLCommand[], NLReport[], and their variants automatically apply NLSequence to their command and reporter arguments. All atoms are converted to a NetLogo-readable string. Real numbers are rounded to 6 decimals of precision. RGBColor[] and Hue[] expressions are converted to NetLogo color specifications. Any Mathematica Lists contained in \!\(\*SubscriptBox[ 22 | StyleBox[\"expr\",\nFontSlant->\"Italic\"], \"1\"]\), \!\(\*SubscriptBox[ 23 | StyleBox[\"expr\",\nFontSlant->\"Italic\"], \"2\"]\), etc are recursively converted into NetLogo-formated lists. All data are eventually converted to strings followed by a blank space"; 24 | 25 | 26 | NLLoadModel::usage := \ 27 | "NLLoadModel[\!\(\* 28 | StyleBox[\"path\",\nFontSlant->\"Italic\"]\)] opens the NetLogo model in the specified path"; 29 | NLCommand::usage := \ 30 | "NLCommand[\!\(\* 31 | StyleBox[SubscriptBox[ 32 | StyleBox[\"command\",\nFontSlant->\"Italic\"], \"1\"],\nFontSlant->\"Italic\"]\)\!\(\* 33 | StyleBox[\",\",\nFontSlant->\"Italic\"]\)\!\(\* 34 | StyleBox[\" \",\nFontSlant->\"Italic\"]\)\!\(\* 35 | StyleBox[SubscriptBox[ 36 | StyleBox[\"command\",\nFontSlant->\"Italic\"], \"2\"],\nFontSlant->\"Italic\"]\)\!\(\* 37 | StyleBox[\",\",\nFontSlant->\"Italic\"]\)\!\(\* 38 | StyleBox[\"...\",\nFontSlant->\"Italic\"]\)] tells NetLogo to execute a series of commands. The sequence of commands are automatically spliced into NetLogo expressions using NLSequence[]."; 39 | NLReport::usage := "NLReport[\!\(\* 40 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"]\)] reports the value of given string."; 41 | NLReportList::usage := \ 42 | "NLReportList[{\!\(\*SubscriptBox[ 43 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"1\"]\), \!\(\*SubscriptBox[ 44 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"2\"]\), ...}] returns a list of values reportered by each reporter, \!\(\*SubscriptBox[ 45 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"1\"]\), \!\(\*SubscriptBox[ 46 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"2\"]\), \[Ellipsis]. If \!\(\*SubscriptBox[ 47 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], 48 | StyleBox[\"i\",\nFontSlant->\"Italic\"]]\) is a list, it will automatically be spliced into a NetLogo string using NLSequence[]."; 49 | 50 | NLDoCommand::usage := \ 51 | "NLDoCommand[\!\(\* 52 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\), n] tells NetLogo to repeat a \!\(\* 53 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\) \!\(\* 54 | StyleBox[\"n\",\nFontSlant->\"Italic\"]\) times."; 55 | NLDoCommandWhile::usage = \ 56 | "NLDoCommandWhile[\!\(\* 57 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\), \!\(\* 58 | StyleBox[\"condition\",\nFontSlant->\"Italic\"]\)] tells NetLogo to repeat a \!\(\* 59 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\) until the NetLogo \!\(\* 60 | StyleBox[\"condition\",\nFontSlant->\"Italic\"]\) is met."; 61 | 62 | NLDoReport::usage = \ 63 | "NLDoReport[\!\(\* 64 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\), \!\(\* 65 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"]\), \!\(\* 66 | StyleBox[\"n\",\nFontSlant->\"Italic\"]\)] returns a list generated by instructing NetLogo to execute a \!\(\* 67 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\) and returning the result of \!\(\* 68 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"]\), \!\(\* 69 | StyleBox[\"n\",\nFontSlant->\"Italic\"]\) times."; 70 | 71 | NLDoReportList::usage = \ 72 | "NLDoReport[\!\(\* 73 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\)\!\(\* 74 | StyleBox[\",\",\nFontSlant->\"Italic\"]\)\!\(\* 75 | StyleBox[\" \",\nFontSlant->\"Italic\"]\){\!\(\*SubscriptBox[ 76 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"1\"]\), \!\(\*SubscriptBox[ 77 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"2\"]\), ...}, \!\(\* 78 | StyleBox[\"n\",\nFontSlant->\"Italic\"]\)] returns a list generated by instructing NetLogo to execute a \!\(\* 79 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\) and returning the results given by a list of reporters, \!\(\* 80 | StyleBox[\"n\",\nFontSlant->\"Italic\"]\) times. If \!\(\*SubscriptBox[ 81 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], 82 | StyleBox[\"i\",\nFontSlant->\"Italic\"]]\) is a list, it will automatically be spliced into a NetLogo string using NLSequence[]."; 83 | 84 | NLDoReportWhile::usage = "NLDoReport[\!\(\* 85 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\), \!\(\* 86 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"]\), \!\(\* 87 | StyleBox[\"condition\",\nFontSlant->\"Italic\"]\)] returns a list generated by instructing NetLogo to execute a \!\(\* 88 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\) and returning the result of \!\(\* 89 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"]\) until the condition given by \!\(\* 90 | StyleBox[\"test\",\nFontSlant->\"Italic\"]\) in NetLogo is satisfied."; 91 | NLDoReportListWhile::usage = \ 92 | "NLDoReport[\!\(\* 93 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\), \!\(\* 94 | StyleBox[\"{\",\nFontSlant->\"Italic\"]\)\!\(\* 95 | StyleBox[SubscriptBox[ 96 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"1\"],\nFontSlant->\"Italic\"]\)\!\(\* 97 | StyleBox[\",\",\nFontSlant->\"Italic\"]\)\!\(\* 98 | StyleBox[\" \",\nFontSlant->\"Italic\"]\)\!\(\* 99 | StyleBox[SubscriptBox[ 100 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], \"2\"],\nFontSlant->\"Italic\"]\)\!\(\* 101 | StyleBox[\",\",\nFontSlant->\"Italic\"]\)\!\(\* 102 | StyleBox[\" \",\nFontSlant->\"Italic\"]\)\!\(\* 103 | StyleBox[\"...\",\nFontSlant->\"Italic\"]\)\!\(\* 104 | StyleBox[\"}\",\nFontSlant->\"Italic\"]\), \!\(\* 105 | StyleBox[\"n\",\nFontSlant->\"Italic\"]\)] returns a list generated by instructing NetLogo to execute a \!\(\* 106 | StyleBox[\"command\",\nFontSlant->\"Italic\"]\) and returning the results given by a list of reporters, n times. If \!\(\*SubscriptBox[ 107 | StyleBox[\"reporter\",\nFontSlant->\"Italic\"], 108 | StyleBox[\"i\",\nFontSlant->\"Italic\"]]\) is a list, it will automatically be spliced into a NetLogo string using NLSequence[]."; 109 | 110 | 111 | NLGetGraph::usage = \ 112 | "NLGetGraph[] returns the graph of a network as a list of pairs of who numbers of agents that have links belonging to the generic \!\(\* 113 | StyleBox[\"link\",\nFontWeight->\"Bold\"]\) breed. 114 | NLGetGraph[\!\(\* 115 | StyleBox[\"linkSet\",\nFontSlant->\"Italic\"]\)] returns the graph of a network as a list of pairs of who numbers of agents that have links belonging to the \!\(\* 116 | StyleBox[\"linkSet\",\nFontSlant->\"Italic\"]\) agentset."; 117 | 118 | NLGetPatches::usage = \ 119 | "NLGetPatches[\!\(\* 120 | StyleBox[\"patchVariable\",\nFontSlant->\"Italic\"]\)] returns a matrix whose entries are the variable \!\(\* 121 | StyleBox[\"patchVariable\",\nFontSlant->\"Italic\"]\) of each patch in the world"; 122 | 123 | NLDiagnostics::usage = \ 124 | "NLDiagnostics[\!\(\* 125 | StyleBox[\"nlHome\",\nFontSlant->\"Italic\"]\)] returns information useful in diagnosing problems with NetLogo Mathematica Link. 126 | Pass the desired home directory to it as an argument to see where it's looking for files and whether they are found"; 127 | 128 | NLJavaDiagnostics::usage = \ 129 | "NLJavaDiagnostics[] returns information about the java environment used in running NetLogo"; 130 | 131 | 132 | Options[NLStart] = {Headless -> False}; 133 | (*$MessagePrePrint=.*) 134 | 135 | Begin["`Private`"] 136 | 137 | 138 | 139 | 140 | (* Mathematica to NetLogo conversion utilities *) 141 | colorConversionRules = {RGBColor[r_,g_,b_]:>(" (rgb "<>ToString[255.*r]<>" "<>ToString[255.*g]<>" "<>ToString[255.*b]<>") "), 142 | Hue[h_]:>("hsb "<>ToString[255.*h]<>" 1 1" ), 143 | Hue[h_,s_,b_]:>(" hsb "<>ToString[255.*h]<>" "<>ToString[255.*h]<>" "<>ToString[255.*b]<>" ")}; 144 | 145 | NLSequence[l_] := 146 | StringJoin[(If[ 147 | StringTake[#, -1] === " ", #, # <> 148 | " "]) & /@ ((ToString[ 149 | If[! AtomQ[#], "[" <> NLSequence[#] <> "]", 150 | If[NumericQ[#] && ! IntegerQ[#], N[#, 6], #]]] &) /@ (l /.colorConversionRules))]; 151 | NLSequence[s_String] := s; 152 | 153 | 154 | 155 | 156 | (* Exception Handling *) 157 | NetLogo::compilerException="`1`"; 158 | NetLogo::engineException="`1`"; 159 | NetLogo::unknownException="`1`"; 160 | 161 | NLCompilerExceptionQ[s_] := StringMatchQ[s, __ ~~"org.nlogo.compiler.Compiler.exception"~~___]; 162 | ParseCompilerException[s_] := StringReplace[s, error__~~" at position"~~___ :> error]; 163 | 164 | NLEngineExceptionQ[s_] := StringMatchQ[s, ___ ~~ "org.nlogo.nvm.EngineException" ~~ ___]; 165 | ParseEngineException[s_]:= StringReplace[First[StringSplit[s,"\n"]], "org.nlogo.nvm.EngineException:" ~~ error__ :> error]; 166 | 167 | (* executes an NetLogo-related function and handles exceptions*) 168 | 169 | SetAttributes[HandleNLExceptions,HoldAll]; 170 | HandleNLExceptions[NLFunction_]:= Block[{exString, javaException, $JavaExceptionHandler, result, $MessagePrePrint}, 171 | $MessagePrePrint =.; 172 | $JavaExceptionHandler = (exString = #3)&; 173 | result = NLFunction; 174 | javaException = GetJavaException[]; 175 | If[UnsameQ[javaException, Null], 176 | ReleaseJavaObject[javaException]; 177 | Which[ 178 | NLCompilerExceptionQ[exString], Message[NetLogo::compilerException, ParseCompilerException[exString]], 179 | NLEngineExceptionQ[exString], Message[NetLogo::engineException, ParseEngineException[exString]], 180 | True, Message[NetLogo::unknownException, exString] 181 | ]; 182 | $Failed, 183 | result 184 | ] 185 | ]; 186 | 187 | 188 | NLLoadModel::notfound = "The model located at `1` could not be found"; 189 | NLStart::netlogonotfound = "NetLogo could not be found in: `1`"; 190 | NLStart::nopath = "NetLogo cannot be started without a valid NetLogo 6.2 path"; 191 | 192 | NLLoadModel[path_String] := If[FileNames[path] == {}, 193 | Message[NLLoadModel::notfound, path];, 194 | NLink@loadModel[path]; 195 | ]; 196 | NLCommand[c_String] := HandleNLExceptions[NLink@command[c]]; 197 | NLCommand[cl_List] := HandleNLExceptions[NLink@command[NLSequence[cl]]]; 198 | NLCommand[params___] := HandleNLExceptions[NLink@command[NLSequence[List[params]]]]; 199 | NLReport[reporter_] := HandleNLExceptions[NLink@report[NLSequence[reporter]]]; 200 | NLReportList[reporters_List] := HandleNLExceptions[NLink@report[NLSequence /@ reporters]]; 201 | NLDoCommand[c_, imax_] := 202 | NLCommand[NLSequence[{"repeat ", imax, "[", c, "]"}]]; 203 | NLDoCommandWhile[c_, test_String] := 204 | NLCommand[{"while [ ", test, "] [", c, "]"}]; 205 | NLDoReport[c_, reporter_, imax_] := 206 | HandleNLExceptions[NLink@doReport[NLSequence[c], NLSequence[reporter], imax]]; 207 | NLDoReportList[c_, reporters_List, imax_] := 208 | HandleNLExceptions[NLink@doReport[NLSequence[c], NLSequence /@ reporters, imax]]; 209 | NLDoReportWhile[c_, reporter_, test_] := 210 | HandleNLExceptions[NLink@doReportWhile[NLSequence[c], NLSequence[reporter], test]]; 211 | NLDoReportListWhile[c_, reporters_List, test_] := 212 | HandleNLExceptions[NLink@doReportWhile[NLSequence[c], NLSequence /@ reporters, test]]; 213 | 214 | NLGetGraph[linkAgentSet_String] := (#[[1]] -> #[[2]]) & /@ 215 | (Floor/@NLReport["[list ([who] of end1) ([who] of end2)] of "<>linkAgentSet]); 216 | NLGetGraph[] := NLGetGraph["links"]; 217 | 218 | NLGetPatches[patchVariable_] := Partition[NLReport["map [ [p] -> ["<>patchVariable<>"] of p ] sort patches"],Floor[NLReport["world-width"]]]; 219 | 220 | Clear[NLJarPaths]; 221 | Clear[NLDiagnostics]; 222 | Clear[NLJavaDiagnostics]; 223 | Clear[NLStart]; 224 | 225 | NLJarPaths[nlPath_] := 226 | Module[{NLPath = nlPath, NLJarDir = If[StringMatchQ[$System,"*Mac*"], FileNameJoin[{nlPath,"Java"}], FileNameJoin[{nlPath,"app"}]]}, 227 | List[SelectFirst[FileNames["netlogo-*.jar", NLJarDir], Not @* StringContainsQ["mac"]], FileNameJoin[{NLPath,"Mathematica Link","mathematica-link.jar"}]]]; 228 | 229 | Options[NLStart] = {Headless -> False, CommandLine -> Automatic}; 230 | 231 | NLStart[opts:OptionsPattern[]] := NLStart[$NLHome] /; ValueQ[$NLHome]; 232 | NLStart[opts:OptionsPattern[]] := NLStart[""] /; !ValueQ[$NLHome]; 233 | 234 | NLStart[NetLogoPath_String, opts:OptionsPattern[]] := 235 | Module[{NLPath = NetLogoPath, alreadySetPathQ = False}, 236 | (* No NetLogo path specified: ask user to locate path *) 237 | If[ NLPath == "", 238 | NLPath = SystemDialogInput["Directory", WindowTitle->"Please locate your NetLogo installation directory"]; 239 | alreadySetPathQ = True; 240 | ]; 241 | 242 | (* NetLogo path specified is bogus in some way *) 243 | If[!alreadySetPathQ && !AllTrue[NLJarPaths[NLPath], FileExistsQ] 244 | && ChoiceDialog["Mathematica could not find your NetLogo installation directory in: "<> NLPath <> ". Would you like to locate it?"], 245 | NLPath = SystemDialogInput["Directory", WindowTitle->"Please locate your NetLogo installation directory"]; 246 | ]; 247 | 248 | If[NLPath == $Canceled, (* throw error and return if user does not specify a path *) 249 | Message[NLStart::nopath]; 250 | Return[$Failed]; 251 | ]; 252 | 253 | (* Report back error for users that still cannot get cannot find the right path *) 254 | If[! AllTrue[NLJarPaths[NLPath], FileExistsQ], 255 | Message[NLStart::netlogonotfound, NLPath]; 256 | Return[$Failed]; 257 | ]; 258 | 259 | (* Reinitialize NLink *) 260 | (* only set after all paths are legit *) 261 | $NLHome = NLPath; 262 | Apply[AddToClassPath, NLJarPaths[NLPath]]; 263 | ReinstallJava[FilterRules[{opts}, Options[ReinstallJava]]]; 264 | NLink = JavaNew[LoadJavaClass["NLink"], ! OptionValue[Headless]]; 265 | ]; 266 | 267 | NLDiagnostics[NetLogoPath_String] := 268 | Module[{nlPath = NetLogoPath}, 269 | Module[{jarPaths = NLJarPaths[nlPath]}, 270 | 271 | <| "providedPath" -> nlPath, 272 | "jarLookupPaths" -> jarPaths, 273 | "foundJars" -> Select[jarPaths, FileExistsQ], 274 | "missingJars" -> Select[jarPaths, Not[FileExistsQ]] |> 275 | ] 276 | ]; 277 | 278 | 279 | NLJavaDiagnostics[opts:OptionsPattern[]] := 280 | Module[{}, 281 | ReinstallJava[FilterRules[{opts}, Options[ReinstallJava]]]; 282 | LoadJavaClass["java.lang.System"]; 283 | 284 | <| "javaVersion" -> System`getProperty["java.version"], 285 | "javaArchitecture" -> System`getProperty["sun.arch.data.model"] |> 286 | ]; 287 | 288 | NLQuit[] := UninstallJava[]; 289 | 290 | End[] 291 | 292 | EndPackage[] 293 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NetLogo-Mathematica Link 2 | 3 | This package allows Mathematica to control NetLogo (and not vice versa) 4 | 5 | ## Using 6 | 7 | The Mathematica Link comes with NetLogo. For more information, see the NetLogo User Manual. 8 | 9 | ## Building 10 | 11 | A `build.sbt` file is provided. You'll need to have a copy of JLink.jar from the Mathematica installation in order to build. If compilation succeeds, `NLink.class` and several other `.class` files will be created. 12 | 13 | ## Credits 14 | 15 | The primary developer of the NetLogo-Mathematica link was Eytan Bakshy. 16 | 17 | To refer to this package in academic publications, please use: Bakshy, E., Wilensky, U. (2007). NetLogo-Mathematica Link. http://ccl.northwestern.edu/netlogo/mathematica.html . Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. 18 | 19 | ## Terms of Use 20 | 21 | [![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/) 22 | 23 | The NetLogo-Mathematica Link is in the public domain. To the extent possible under law, Uri Wilensky has waived all copyright and related or neighboring rights. 24 | -------------------------------------------------------------------------------- /build.sbt: -------------------------------------------------------------------------------- 1 | import java.nio.file.{ Files, Path, Paths } 2 | 3 | name := "Mathematica-Link" 4 | 5 | javaSource in Compile := baseDirectory.value / "src" / "main" 6 | 7 | crossPaths := false 8 | 9 | version := "6.1.2" 10 | 11 | javacOptions ++= 12 | "-g -deprecation -encoding us-ascii -Werror -Xlint:all -Xlint:-serial -Xlint:-fallthrough -Xlint:-path --release 11 ".split(" ").toSeq 13 | 14 | val netLogoVersion = settingKey[String]("version of NetLogo to depend on") 15 | 16 | netLogoVersion := "6.2.0-d27b502" 17 | 18 | artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) => 19 | "mathematica-link.jar" 20 | } 21 | 22 | // this section is copied from the NetLogo extension plugin 23 | val netLogoDep = { 24 | val netLogoJarFile = 25 | Option(System.getProperty("netlogo.jar.file")) 26 | .map { f => 27 | val jar = file(f) 28 | val testJar = file(f.replaceAllLiterally(".jar", "-tests.jar")) 29 | Seq(unmanagedJars in Compile ++= Seq(jar, testJar)) 30 | } 31 | 32 | val netLogoJarURL = 33 | Option(System.getProperty("netlogo.jar.url")) 34 | .map { url => 35 | val urlVersion = url.split("/").last 36 | .stripPrefix("NetLogo") 37 | .stripPrefix("-") 38 | .stripSuffix(".jar") 39 | val version = if (urlVersion == "") "DEV" else urlVersion 40 | val testUrl = url.replaceAllLiterally(".jar", "-tests.jar") 41 | Seq(libraryDependencies ++= Seq( 42 | "org.nlogo" % "NetLogo" % version changing() from url, 43 | "org.nlogo" % "NetLogo-tests" % version changing() from testUrl, 44 | "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.5" 45 | )) 46 | } 47 | 48 | (netLogoJarFile orElse netLogoJarURL).getOrElse { 49 | Seq( 50 | resolvers += "netlogo" at "https://dl.cloudsmith.io/public/netlogo/netlogo/maven/", 51 | libraryDependencies ++= Seq( 52 | "org.nlogo" % "netlogo" % netLogoVersion.value intransitive, 53 | "org.nlogo" % "netlogo" % netLogoVersion.value % "test" intransitive() classifier "tests")) 54 | } 55 | } 56 | 57 | netLogoDep 58 | 59 | libraryDependencies += 60 | "com.wolfram.jlink" % "JLink" % "10.3.1" from s"file:///${(baseDirectory.value / "JLink.jar").toString}" 61 | 62 | lazy val copyJLinkJar = taskKey[Unit]("copies the JLink.jar to local for easier builds") 63 | 64 | copyJLinkJar := { 65 | // We could update this to switch to the Windows path when necessary, but this should work fine if we're 66 | // building out of the same folder for NetLogo releases. -Jeremy B November 2020 67 | val jLinkJarDestPath = (baseDirectory.value / "JLink.jar").toPath 68 | if (!Files.exists(jLinkJarDestPath)) { 69 | val jLinkJarSources = List("/Applications/Mathematica.app/Contents/SystemFiles/Links/JLink/JLink.jar", 70 | "/Applications/Mathematica 2.app/Contents/SystemFiles/Links/JLink/JLink.jar") 71 | val jLinkJarSourcePaths = jLinkJarSources.map(Paths.get(_)) 72 | val jLinkJarSourcePath: Option[Path] = jLinkJarSourcePaths.find(n => Files.exists(n)) 73 | jLinkJarSourcePath match { 74 | case Some(s) => Files.copy(s, jLinkJarDestPath) 75 | case _ => throw new Exception(s"JLink.jar not found, is Mathematica installed? (${jLinkJarSourcePaths.mkString(",")})") 76 | } 77 | } 78 | } 79 | 80 | update := (update dependsOn copyJLinkJar).value 81 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.13 2 | -------------------------------------------------------------------------------- /src/main/NLink.java: -------------------------------------------------------------------------------- 1 | import com.wolfram.jlink.*; 2 | import org.nlogo.headless.HeadlessWorkspace; 3 | import org.nlogo.core.CompilerException; 4 | import org.nlogo.core.LogoList; 5 | import org.nlogo.nvm.EngineException; 6 | import org.nlogo.api.LogoException; 7 | import org.nlogo.app.App; 8 | import java.awt.EventQueue; 9 | 10 | public class NLink { 11 | private String modelLocation; 12 | private org.nlogo.workspace.Controllable workspace = null; 13 | private java.io.IOException caughtEx = null; 14 | private boolean isGUIworkspace; 15 | 16 | public NLink(boolean isGUImode) 17 | { 18 | isGUIworkspace = isGUImode; 19 | if( isGUImode ) { 20 | App.main( new String[] { } ) ; 21 | workspace = App.app(); 22 | org.nlogo.api.Exceptions.setHandler 23 | ( new org.nlogo.api.Exceptions.Handler() { 24 | public void handle( Throwable t ) { 25 | throw new RuntimeException(t.getMessage()); 26 | } } ); 27 | } 28 | else 29 | workspace = HeadlessWorkspace.newInstance() ; 30 | } 31 | 32 | public void loadModel(final String path) 33 | throws java.io.IOException, LogoException, CompilerException, InterruptedException 34 | { 35 | caughtEx = null; 36 | if ( isGUIworkspace ) { 37 | try { 38 | EventQueue.invokeAndWait ( 39 | new Runnable() { 40 | public void run() { 41 | try 42 | { App.app().open(path, true); } 43 | catch( java.io.IOException ex) 44 | { caughtEx = ex; } 45 | } } ); 46 | } 47 | catch( java.lang.reflect.InvocationTargetException ex ) { 48 | throw new RuntimeException(ex.getMessage()); 49 | } 50 | if( caughtEx != null ) { 51 | throw caughtEx; 52 | } 53 | } 54 | else { 55 | try { 56 | if (workspace != null) 57 | ((HeadlessWorkspace)workspace).dispose(); 58 | workspace = HeadlessWorkspace.newInstance() ; 59 | workspace.open(path, true); 60 | } 61 | // if we cannot open a NetLogo model for some reason, throw an exception 62 | // and start a new workspace 63 | catch( java.io.IOException ex) { 64 | if (workspace != null) 65 | ((HeadlessWorkspace)workspace).dispose(); 66 | workspace = HeadlessWorkspace.newInstance() ; 67 | throw ex; 68 | } 69 | } 70 | } 71 | 72 | 73 | 74 | /* returns the value of a reporter. if it is a LogoList, it will be 75 | recursively converted to an array of Objects */ 76 | public Expr report(final String s) 77 | throws LogoException, CompilerException 78 | { 79 | return logoToExpr(workspace.report(s)); 80 | } 81 | 82 | /* returns an evaluated list of reporters */ 83 | public Expr report(final String s[]) 84 | throws LogoException, CompilerException 85 | { 86 | Expr[] results = new Expr[s.length]; 87 | for( int i = 0; i < s.length; i++ ) 88 | results[i] = logoToExpr(workspace.report(s[i])); 89 | return (new Expr(new Expr(Expr.SYMBOL, "List"), results)); 90 | } 91 | 92 | public void command(final String s) 93 | throws LogoException, CompilerException 94 | { 95 | workspace.command(s); 96 | } 97 | 98 | public void command(final String[] s) 99 | throws LogoException, CompilerException 100 | { 101 | for(int i = 0; i < s.length; i++) 102 | workspace.command(s[i]); 103 | } 104 | 105 | 106 | /* Repeats a command and returns a single reporter for n interations */ 107 | public Expr doReport(final String s, final String var, final int repeats) 108 | throws LogoException, CompilerException 109 | { 110 | Expr[] results = new Expr[repeats]; 111 | for(int i=0; i < repeats; i++) { 112 | workspace.command(s); 113 | results[i] = report(var); 114 | } 115 | return (new Expr(new Expr(Expr.SYMBOL, "List"), results)); 116 | } 117 | 118 | /* Repeats a command and returns a list of reporters for n interations */ 119 | public Expr doReport(final String s, final String[] vars, final int repeats) 120 | throws LogoException, CompilerException 121 | { 122 | int i; 123 | Expr[] results = new Expr[repeats]; 124 | for(i=0; i < repeats; i++) { 125 | workspace.command(s); 126 | results[i] = report(vars); 127 | } 128 | return (new Expr(new Expr(Expr.SYMBOL, "List"), results)); 129 | } 130 | 131 | 132 | 133 | /* Repeats a command and returns a reporter until a condition is met */ 134 | public Expr doReportWhile(final String s, final String var, final String condition) 135 | throws LogoException, CompilerException 136 | { 137 | java.util.ArrayList varList = new java.util.ArrayList(); 138 | for(int i=0; ((Boolean)workspace.report(condition)).booleanValue(); i++) { 139 | workspace.command(s); 140 | varList.add(report(var)); 141 | } 142 | Object[] objArray = varList.toArray(); 143 | Expr[] exprArray = new Expr[objArray.length]; 144 | for (int j=0; j < exprArray.length; j++) 145 | exprArray[j] = (Expr)objArray[j]; 146 | return (new Expr(new Expr(Expr.SYMBOL, "List"), exprArray)); 147 | } 148 | 149 | /* Repeats a command and returns a list of reporters until a condition is met */ 150 | public Expr doReportWhile(final String s, final String[] vars, final String condition) 151 | throws LogoException, CompilerException 152 | { 153 | java.util.ArrayList varList = new java.util.ArrayList(); 154 | Expr[] reports; 155 | for(int i=0; ((Boolean)workspace.report(condition)).booleanValue(); i++) { 156 | workspace.command(s); 157 | varList.add(report(vars)); 158 | } 159 | Object[] objArray = varList.toArray(); 160 | Expr[] exprArray = new Expr[objArray.length]; 161 | for (int j=0; j < exprArray.length; j++) 162 | exprArray[j] = (Expr)objArray[j]; 163 | return (new Expr(new Expr(Expr.SYMBOL, "List"), exprArray)); 164 | } 165 | 166 | /* Recursively converts LogoList into an Expr object representing a Mathematica List*/ 167 | private Expr NLArray( LogoList l ) { 168 | Expr[] exprArray = new Expr[l.size()]; 169 | for(int i = 0; i < l.size(); i++) 170 | exprArray[i] = logoToExpr(l.get(i)); 171 | return (new Expr(new Expr(Expr.SYMBOL, "List"), exprArray)); 172 | } 173 | 174 | /* Converts datatypes returned from NetLogo controlling API into Mathematica 175 | Expression objects 176 | */ 177 | private Expr logoToExpr( Object o ) { 178 | if(o instanceof LogoList) 179 | return NLArray((LogoList)o); 180 | else if (o instanceof String) 181 | return new Expr((String)o); 182 | else if (o instanceof Integer) 183 | return new Expr(((Integer)o).intValue()); 184 | else if (o instanceof Double) 185 | return new Expr(((Double)o).doubleValue()); 186 | else if (o instanceof Boolean) { 187 | if ( ((Boolean)o).booleanValue() ) 188 | return new Expr(Expr.SYMBOL, "True"); 189 | else 190 | return new Expr(Expr.SYMBOL, "False"); 191 | } 192 | else 193 | return new Expr("Unknown data type"); 194 | } 195 | } 196 | --------------------------------------------------------------------------------