NetLogo Web

NetLogo Web is a version of the NetLogo modeling environment that runs entirely in the browser. One of the immediate goals of the project is to provide a suitable replacement for the NetLogo applet functionality, and, in doing so, once again make NetLogo models easy for users to put on the web for others to try. NetLogo Web runs on more platforms than Desktop NetLogo, including tablets, phones and Chromebooks. In the longer run, NetLogo Web will have most of the features of Desktop NetLogo.

The desktop edition of NetLogo is more polished and fully-featured than NetLogo Web. So, for now, we recommend using NetLogo Web only if one or more of the following describes your desired use of NetLogo:

  • I want to use NetLogo on a platform that it does not otherwise run on (e.g., iPad, iPhone, Android, Chromebook)
  • I want to embed a NetLogo model in a web page
  • I want to distribute a NetLogo model without requiring my audience to have an existing NetLogo installation

The quality gap between NetLogo Web and NetLogo is fairly large right now, but we intend to greatly narrow that gap over the course of the coming years, prioritizing features that are important to large portions of the user community. Even if NetLogo Web doesn't meet all of your needs today, be sure to stay tuned as we work to improve NetLogo Web and expand its feature set.

  • Most of the NetLogo programming language
  • Plotting
  • The Command Center
  • Editable "Code" and "Info" tabs
  • Functioning widgets of all kinds
  • The ability to export models for use in the desktop edition of NetLogo
  • The ability to export models as standalone HTML pages
  • Many of the less-common NetLogo language primitives
  • High performance
  • An interface editor
  • Extensions
  • Reading from and writing to external files
  • 3D models and the "3D View" of 2D models
  • HubNet
  • BehaviorSpace
  • Other less-central NetLogo features (e.g., System Dynamics Modeler)
  • Some less-common widget configurations (e.g., vertical sliders)

That said, there are very few things in NetLogo that have been left out of the long-term development plan for NetLogo Web. If support for your favorite primitive or feature is not currently available, it is likely forthcoming. We appreciate your patience as we work to reproduce functionality that has been developed and honed over more than fifteen years of NetLogo development, in our goal to make NetLogo Web the best product we can.

NetLogo Web opens with a randomly selected model. To load another model, you may select a model from the drop-down menu of models from the NetLogo Web Models Library (Search the Models Library) or use the button next to "Upload a Model" to open a Desktop NetLogo model of your own.

Most NetLogo library models work in NetLogo Web. In the NetLogo Web models library drop-down menu, models that work in NetLogo Web are selectable, whereas the models that don't yet work in NetLogo Web are grayed out. Some selectable models may not work exactly as their NetLogo counterparts. Some grayed out models can easily be modified in Desktop NetLogo so that they run in NetLogo Web.

To evaluate whether a model of your own will run in NetLogo Web today, you can use the "Upload a Model" button to open it in NetLogo Web. If the conversion process encounters an error, you will get feedback about what aspects of your model are not yet supported.

That said, here are some general rules for telling ahead of time whether or not a model will work in the current version of NetLogo Web:

  • If your model only uses NetLogo features that are commonly used in the NetLogo Models Library, it is very likely that your model will work
  • If your model uses extensions, file primitives, movie primitives, or any of the other currently-unimplemented primitives, it will not work
  • If your model uses the wait or display primitives, it generally will not work

If you're still not sure if your model will work or not, we encourage you to simply open your model in NetLogo Web and see for yourself.

NetLogo Web is in continuous development. As NetLogo features are ported over to NetLogo Web, many models that previously could not be opened in NetLogo Web will automatically become runnable.

Long story short: You can't (yet).

NetLogo Web allows you to edit model code and "Info" content, but it is not currently possible to create or edit interface widgets (e.g., buttons, sliders, monitors, etc.), which severely limits the authoring power available within NetLogo Web. This is one of the foremost things that we intend to improve in the near future. For now, though, all serious model-authoring tasks can only be handled in the standard, desktop edition of NetLogo. The "Upload a Model" button in NetLogo Web can be used to open models created in the desktop edition of NetLogo.

First, a model must be opened in NetLogo Web. This can be done by choosing a model from the Models Library dropdown, or by clicking the file-selection button next to "Upload a Model" to navigate to a model located on your computer and open it in NetLogo Web. Note that opening a model in this way does not save your model remotely anywhere. In fact, when doing this, the model never leaves your computer at all.

If you would like to save the model that is currently open in NetLogo Web (including any changes that you might have made to it), NetLogo Web offers two different ways of doing so.

If you would like to keep your model as a NetLogo Web model and share it with others to view in the browser, you can click the "Export: HTML" button in NetLogo Web to generate a single HTML file of your model. Like any other HTML file, files generated in this way can then be hosted on a website and viewed in any modern browser.

If you are interested in saving the model for use in the desktop version of NetLogo, the "Export: NetLogo" button can be used to do so. This will generate a traditional ".nlogo" file that has a name of your choosing, which will be placed in your computer's "downloads" directory and can then be opened once again in either NetLogo or NetLogo Web.

With a model downloaded from NetLogo Web, you can use the desktop version of NetLogo to make whatever changes to the model that you would like, save those changes, and then open the new version of the model in NetLogo Web (using "Upload a Model" in NetLogo Web, like before).

Using the desktop version of NetLogo to edit models can be especially helpful for working around NetLogo Web's currently-limited functionality for editing models (e.g., the lack of widget authoring), and this, for now, is the recommended way of improving your models for use in NetLogo Web. We do recognize that this workflow is somewhat inconvenient, and we have plans to improve it soon.

Unfortunately, free and simple-to-use hosting services are surprisingly few in number these days. We realize that this makes things difficult for many of our users, and we definitely plan to provide our own service that makes this easier for people in the future. For the time being, though, there are still a couple of options that we can suggest, based on what kind of files you would like hosted.

If you're just looking to host .nlogo files, you can use Dropbox or GitHub or basically any service that allows linking directly to hosted files. Once your .nlogo file has been hosted somewhere, follow the page-generation instructions, and share the //netlogoweb.org/web?modelURL link, using the .nlogo file URL from your hosting service as the modelURL value.

Another option for linking directly to pages containing NetLogo Web models is to use the Modeling Commons, which is a public space for uploading, sharing, and discussing NetLogo models. All models uploaded to the Modeling Commons have integration with NetLogo Web through the "Run in NetLogo Web" tab on the model's page. For any model, if you open that "Run" tab and then copy your browser's current URL, that URL can be used for direct access to the NetLogo Web version of the model.

If you want to host an HTML standalone model (as generated by following the instructions in the section about "Export: HTML", then your options are more limited. One option is to use GitHub Pages, or some other static web host. Advanced users might even be comfortable with simply hosting the HTML files for themselves on a public-facing web server.

That said, hosting a .nlogo file on your own web server is more complicated, though. To do that, host the file, and make sure that your web server allows it to be accessed cross-origin. To do this, you might need to have the server set the Access-Control-Allow-Origin header in the .nlogo file's HTTP response to either * or whichever NetLogo Web domain you're using (i.e. http://netlogoweb.org or https://netlogoweb.org or http://netlogo-web.org or https://netlogo-web.org). Then, follow the instructions given here, and share your model through the //netlogoweb.org/web?modelURL link, using the URL of the model on the web server for the modelURL value.

You can link to //netlogoweb.org/web?modelURL (where modelURL is the URL of your model). Everytime someone goes to that link (or an iframe is loaded that uses that link as the source URL), the most recent version of your model will be fetched from modelURL and turned into a simple model page.

While this generally should not be a problem, this method requires having an active connection to our website (netlogoweb.org) in order to work, unlike normal standalone NetLogo Web pages, which can be hosted entirely on your own server.

If you enter code into the Command Center and that code is invalid in NetLogo Web, you will receive an error message, and your code may not get fully executed.

If you get an error when the model is first loaded up, but can't tell what's going wrong, it's probably because one of the widgets (e.g. a Plot or Slider) contains code that is currently invalid in NetLogo Web. The widget will not work correctly, but the parts of the model that did not generate errors will continue to be operable.

If you get an error only when you click a button, it usually suggests that the particular button contains code that is currently invalid in NetLogo Web. That button will be unusable, but the parts of the model that did not generate errors will continue to be operable.

A type error in general indicates that a function received one or more arguments that it didn't know how to operate on. One example of a type error in NetLogo code would be (turtle 0) + (turtle 1), since the + function doesn't know how to add turtles together.

When we talk about a type error occurring in the simulation engine, we mean that this kind of error happened in the JavaScript code that is running in the browser. The fact that these errors occurred in JavaScript, though, does not necessarily indicate that the simulation engine is the culprit. In fact, the vast majority of these sorts of errors are caused by ill-formed NetLogo code for which the engine does not yet know how to report nice errors. In desktop NetLogo, you always get informative type errors, but, unfortunately, NetLogo Web's error-reporting functionality is not yet complete enough to always give smart errors.

The area where NetLogo Web's error-reporting is poorest at the moment is in cases like ask n [] (where n is a number, or really anything but an agent or agentset). If ask were passed a literal value instead of a variable like n, the compiler would usually just refuse to compile code that doesn't typecheck, and it would tell you exactly what went wrong. Unfortunately, in NetLogo, static typechecking goes out the window when variables are introduced, forcing the engine to fall back on runtime typechecking. Even more unfortunately, NetLogo Web's runtime typechecking is very poor at the moment.

As for how to fix these errors, that is difficult for now. There is not a lot that the average user can reasonably be expected to do until we implement proper error-reporting for type errors. Advanced users might find some hints in the JavaScript error that gets printed out. We recommend reproducing the error in desktop NetLogo to get a proper error message, or, if that's not possible, then trying to bisect your model's code until you find the source of the error.

If the error message is "Models must have 12 sections, this had 1", the problem is likely that the uploaded file is not actually a NetLogo model. Please verify that you can open this file in the desktop version of NetLogo before proceeding.

If you got the "Couldn't find corresponding reader" error or the "Models must have 12 sections" error with a number at the end other than 1, this usually indicates an attempt to load a model that was saved in an old version of NetLogo. Please note that NetLogo Web only guarantees compatibility with the latest version of NetLogo.

The easiest way to fix this problem is to open the model in the latest version of NetLogo, allow NetLogo to automatically convert the old model, save the auto-converted model, and attempt to open the newly-converted version of the model in NetLogo Web.

If NetLogo Web complains that it cannot load this newly-converted model due to unimplemented primitives (especially those whose names start with underscores), you may need to slightly rewrite some of the code. See the NetLogo transition guide for more details on how to do that for the particular version of NetLogo that your model came from.

Your computer is working very hard to execute some NetLogo Web code. This is especially likely to occur when trying to do something that involves a very large number of agents. Unless you've done something to enter an infinite loop, we recommend just giving NetLogo Web some time to finish its task. If you have entered an infinite loop, the recommended solution is to terminate the browser tab.

There are a couple of reasons for this. One of the big ones is that the the desktop edition of NetLogo has about fifteen years of development work behind it, and a lot of that was spent on improving performance. With NetLogo Web, our foremost concern has been feature parity. NetLogo Web is still very young and has a lot of catching up to do, so we don't plan to focus hard on performance for a while yet.

Another of the reasons has to do with the maturity of the platforms that these software packages run on. The desktop edition of NetLogo runs on the Java Virtual Machine, whereas NetLogo Web, in the browser, runs on a variety of different JavaScript engines. The Java Virtual Machine tends to be faster than any JavaScript engine, and some JavaScript engines are substantially faster than others. We find that Google Chrome tends to offer the best performance with NetLogo Web.

We recommend first trying to solve the problem by refreshing the page. If that doesn't fix it, we encourage you to report your problem to us at bugs@ccl.northwestern.edu.

One of the great things about running directly in the browser is how easy it is to modify content. If you want to tinker with things in NetLogo Web, go for it! You're entirely free to save a standalone NetLogo Web page and create your own stylesheets or mess with the page's JavaScript—at your own risk, of course. We do ask that you leave the "powered by NetLogo" text in its place. If you think the changes you've made would be useful for others, you might even consider contributing them to NetLogo Web proper (see the next topic, below).

Like NetLogo, NetLogo Web is open-source and hosted on GitHub. The relevant repositories for the project are Galapagos (for the web interface), Tortoise (for the simulation engine and compiler back-end), and NetLogo-Headless (for the compiler front-end).

Pull requests to these repositories are welcome. If you would like to talk to any of the NetLogo team about some proposed changes of yours, feel free to drop by the relevant repository's chat room on Gitter, where we'll be glad to discuss things with you.

One important source of NetLogo Web's funding is generous community donations. If you're interested in making a donation to the NetLogo project, please visit our donation page here.

Above all else, we gratefully acknowledge that the National Science Foundation has been the primary funder of NetLogo Web (grant number IIS-1147621). We also appreciate the support from Concord Consortium.

NetLogo Web was also made by possible by building on top of the previous two decades of NetLogo funding. Much of the support over the years came from the National Science Foundation -- grant numbers REC-9814682 and REC-0126227, with further support from REC-0003285, REC-0115699, DRL-0196044, CCF-ITR-0326542, DRL-REC/ROLE-0440113, SBE-0624318, EEC-0648316, IIS-0713619, DRL-RED-9552950, DRL-REC-9632612, DRL-DRK12-1020101, IIS-1441552, CNS-1441016, CNS-1441041, IIS-1438813, and REC-1343873. Yet more support for NetLogo over the years was provided by the Spencer Foundation, Texas Instruments, the Brady Fund, and the Northwestern Institute on Complex Systems.

Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

For NetLogo or NetLogo Web feedback, please send email to feedback@ccl.northwestern.edu and for bug reports, please send email to bugs@ccl.northwestern.edu. We greatly value your comments, feature requests, observations, and bug reports. Please make sure to specify in your email that you are using NetLogo Web. You can also consult this page to determine where best to get in touch.